Skip to content

Commit e0abc62

Browse files
author
Satish Ramachandran
committed
Incorporate review comments
1 parent a1383eb commit e0abc62

File tree

3 files changed

+31
-31
lines changed

3 files changed

+31
-31
lines changed

netctl/commands.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -279,14 +279,14 @@ var Commands = []cli.Command{
279279
Name: "rm",
280280
Aliases: []string{"delete"},
281281
Usage: "Delete external contracts",
282-
Flags: []cli.Flag{tenantFlag},
282+
Flags: []cli.Flag{tenantFlag},
283283
Action: deleteExternalContracts,
284284
},
285285
{
286286
Name: "create",
287287
Usage: "Create external contracts",
288288
Flags: []cli.Flag{
289-
tenantFlag,
289+
tenantFlag,
290290
cli.BoolFlag{
291291
Name: "consumed, c",
292292
Usage: "External contracts type - consumed",

netctl/netctl.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ func listExternalContracts(ctx *cli.Context) {
819819
extContractsGroups, err := getClient(ctx).ExtContractsGroupList()
820820
errCheck(ctx, err)
821821

822-
tenant := ctx.String("tenant")
822+
tenant := ctx.String("tenant")
823823

824824
if ctx.Bool("json") {
825825
dumpJSONList(ctx, extContractsGroups)
@@ -833,9 +833,9 @@ func listExternalContracts(ctx *cli.Context) {
833833
writer := tabwriter.NewWriter(os.Stdout, 0, 2, 2, ' ', 0)
834834
defer writer.Flush()
835835
for _, extContractsGroup := range *extContractsGroups {
836-
if extContractsGroup.TenantName != tenant {
837-
continue
838-
}
836+
if extContractsGroup.TenantName != tenant {
837+
continue
838+
}
839839
writer.Write([]byte(fmt.Sprintf(" Name: %s\t\tType: %s\n", extContractsGroup.ContractsGroupName, extContractsGroup.ContractsType)))
840840
writer.Write([]byte(fmt.Sprintf(" Contracts:\n")))
841841
for _, contract := range extContractsGroup.Contracts {
@@ -848,7 +848,7 @@ func listExternalContracts(ctx *cli.Context) {
848848
func deleteExternalContracts(ctx *cli.Context) {
849849
argCheck(1, ctx)
850850
contractsGroupName := ctx.Args()[0]
851-
tenant := ctx.String("tenant")
851+
tenant := ctx.String("tenant")
852852

853853
logrus.Infof("Deleting external contracts group %s in tenant %s", contractsGroupName, tenant)
854854
errCheck(ctx, getClient(ctx).ExtContractsGroupDelete(tenant, contractsGroupName))
@@ -868,8 +868,8 @@ func createExternalContracts(ctx *cli.Context) {
868868
} else {
869869
errExit(ctx, exitHelp, "Either provided or consumed must be specified", false)
870870
}
871-
872-
tenant := ctx.String("tenant")
871+
872+
tenant := ctx.String("tenant")
873873

874874
contracts := strings.Split(ctx.String("contracts"), ",")
875875
if ctx.String("contracts") == "" {
@@ -879,7 +879,7 @@ func createExternalContracts(ctx *cli.Context) {
879879
contractsGroupName := ctx.Args()[0]
880880

881881
errCheck(ctx, getClient(ctx).ExtContractsGroupPost(&contivClient.ExtContractsGroup{
882-
TenantName: tenant,
882+
TenantName: tenant,
883883
ContractsGroupName: contractsGroupName,
884884
ContractsType: contractsType,
885885
Contracts: contracts,

netmaster/objApi/extContracts.go

+21-21
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ func extContractsGrpValidateAndRegister(epg *contivModel.EndpointGroup,
8888
// Cleanup external contracts from an epg.
8989
func cleanupExternalContracts(endpointGroup *contivModel.EndpointGroup) error {
9090
// Cleanup consumed external contracts
91-
tenant := endpointGroup.TenantName
91+
tenant := endpointGroup.TenantName
9292
for _, consExtContractsGrp := range endpointGroup.ConsExtContractsGrps {
93-
contractsGrpKey := tenant + ":" + consExtContractsGrp
93+
contractsGrpKey := tenant + ":" + consExtContractsGrp
9494
contractsGrp := contivModel.FindExtContractsGroup(contractsGrpKey)
9595
err := extContractsGrpDeregister(endpointGroup, contractsGrp, "consumed")
9696
if err != nil {
@@ -103,7 +103,7 @@ func cleanupExternalContracts(endpointGroup *contivModel.EndpointGroup) error {
103103

104104
// Cleanup provided external contracts
105105
for _, provExtContractsGrp := range endpointGroup.ProvExtContractsGrps {
106-
contractsGrpKey := tenant + ":" + provExtContractsGrp
106+
contractsGrpKey := tenant + ":" + provExtContractsGrp
107107
contractsGrp := contivModel.FindExtContractsGroup(contractsGrpKey)
108108
err := extContractsGrpDeregister(endpointGroup, contractsGrp, "provided")
109109
if err != nil {
@@ -121,9 +121,9 @@ func cleanupExternalContracts(endpointGroup *contivModel.EndpointGroup) error {
121121
func setupExternalContracts(endpointGroup *contivModel.EndpointGroup,
122122
consContractsGrps, provContractsGrps []string) error {
123123
// Validate presence and register consumed external contracts
124-
tenant := endpointGroup.TenantName
124+
tenant := endpointGroup.TenantName
125125
for _, consExtContractsGrp := range consContractsGrps {
126-
contractsGrpKey := tenant + ":" + consExtContractsGrp
126+
contractsGrpKey := tenant + ":" + consExtContractsGrp
127127
contractsGrp := contivModel.FindExtContractsGroup(contractsGrpKey)
128128
err := extContractsGrpValidateAndRegister(endpointGroup, contractsGrp, "consumed")
129129
if err != nil {
@@ -133,7 +133,7 @@ func setupExternalContracts(endpointGroup *contivModel.EndpointGroup,
133133

134134
// Validate presence and register provided external contracts
135135
for _, provExtContractsGrp := range provContractsGrps {
136-
contractsGrpKey := tenant + ":" + provExtContractsGrp
136+
contractsGrpKey := tenant + ":" + provExtContractsGrp
137137
contractsGrp := contivModel.FindExtContractsGroup(contractsGrpKey)
138138
err := extContractsGrpValidateAndRegister(endpointGroup, contractsGrp, "provided")
139139
if err != nil {
@@ -155,32 +155,32 @@ func isExtContractsGroupUsed(contractsGroup *contivModel.ExtContractsGroup) bool
155155

156156
// ExtContractsGroupCreate creates a new group of external contracts
157157
func (ac *APIController) ExtContractsGroupCreate(contractsGroup *contivModel.ExtContractsGroup) error {
158-
log.Infof("Received ExtContractsGroupCreate: %+v", contractsGroup)
158+
log.Infof("Received ExtContractsGroupCreate: %+v", contractsGroup)
159159

160-
// NOTE: Nothing more needs to be done here. This object
161-
// need not be created in the masterCfg.
160+
// NOTE: Nothing more needs to be done here. This object
161+
// need not be created in the masterCfg.
162162

163-
return nil
163+
return nil
164164
}
165165

166166
// ExtContractsGroupUpdate updates an existing group of contract sets
167167
func (ac *APIController) ExtContractsGroupUpdate(contractsGroup, params *contivModel.ExtContractsGroup) error {
168-
log.Infof("Received ExtContractsGroupUpdate: %+v, params: %+v", contractsGroup, params)
169-
log.Errorf("Error: external contracts update not supported: %s", contractsGroup.ContractsGroupName)
168+
log.Infof("Received ExtContractsGroupUpdate: %+v, params: %+v", contractsGroup, params)
169+
log.Errorf("Error: external contracts update not supported: %s", contractsGroup.ContractsGroupName)
170170

171-
return core.Errorf("external contracts update not supported")
171+
return core.Errorf("external contracts update not supported")
172172
}
173173

174174
// ExtContractsGroupDelete deletes an existing external contracts group
175175
func (ac *APIController) ExtContractsGroupDelete(contractsGroup *contivModel.ExtContractsGroup) error {
176-
log.Infof("Received ExtContractsGroupDelete: %+v", contractsGroup)
176+
log.Infof("Received ExtContractsGroupDelete: %+v", contractsGroup)
177177

178-
// At this moment, we let the external contracts to be deleted only
179-
// if there are no consumers of this external contracts group
180-
if isExtContractsGroupUsed(contractsGroup) == true {
181-
log.Errorf("Error: External contracts groups is being used: %s", contractsGroup.ContractsGroupName)
182-
return core.Errorf("External contracts group is in-use")
183-
}
178+
// At this moment, we let the external contracts to be deleted only
179+
// if there are no consumers of this external contracts group
180+
if isExtContractsGroupUsed(contractsGroup) == true {
181+
log.Errorf("Error: External contracts groups is being used: %s", contractsGroup.ContractsGroupName)
182+
return core.Errorf("External contracts group is in-use")
183+
}
184184

185-
return nil
185+
return nil
186186
}

0 commit comments

Comments
 (0)