@@ -78,12 +78,14 @@ func (a *SDKAPI) GetOperationMap(cfg *ackgenconfig.Config) *OperationMap {
78
78
// create an index of Operations by operation types and resource name
79
79
opMap := OperationMap {}
80
80
for opID , op := range a .API .Operations {
81
- opTypeArray , resName := getOpTypeAndResourceName (opID , cfg )
82
- for _ , opType := range opTypeArray {
81
+ opTypes , opResourceNames := getOpTypesAndResourcesMapping (opID , cfg )
82
+ for _ , opType := range opTypes {
83
83
if _ , found := opMap [opType ]; ! found {
84
84
opMap [opType ] = map [string ]* awssdkmodel.Operation {}
85
85
}
86
- opMap [opType ][resName ] = op
86
+ for _ , resName := range opResourceNames {
87
+ opMap [opType ][resName ] = op
88
+ }
87
89
}
88
90
}
89
91
@@ -98,7 +100,7 @@ func (a *SDKAPI) GetOperationMap(cfg *ackgenconfig.Config) *OperationMap {
98
100
//
99
101
// see: https://github.com/aws-controllers-k8s/community/issues/1555
100
102
for opID , opCfg := range cfg .Operations {
101
- if opCfg .ResourceName == "" {
103
+ if len ( opCfg .ResourceName ) == 0 {
102
104
continue
103
105
}
104
106
op , found := a .API .Operations [opID ]
@@ -107,7 +109,9 @@ func (a *SDKAPI) GetOperationMap(cfg *ackgenconfig.Config) *OperationMap {
107
109
}
108
110
for _ , operationType := range opCfg .OperationType {
109
111
opType := OpTypeFromString (operationType )
110
- opMap [opType ][opCfg.ResourceName ] = op
112
+ for _ , resName := range opCfg .ResourceName {
113
+ opMap [opType ][resName ] = op
114
+ }
111
115
}
112
116
}
113
117
a .opMap = & opMap
@@ -360,20 +364,23 @@ func NewSDKAPI(api *awssdkmodel.API, apiGroupSuffix string) *SDKAPI {
360
364
}
361
365
362
366
// Override the operation type and/or resource name, if specified in config
363
- func getOpTypeAndResourceName (opID string , cfg * ackgenconfig.Config ) ([]OpType , string ) {
367
+ func getOpTypesAndResourcesMapping (opID string , cfg * ackgenconfig.Config ) ([]OpType , [] string ) {
364
368
opType , resName := GetOpTypeAndResourceNameFromOpID (opID , cfg )
365
- opTypes := [] OpType { opType }
369
+ opConfig , exists := cfg . GetOperationConfig ( opID )
366
370
367
- if operationConfig , exists := cfg .GetOperationConfig (opID ); exists {
368
- if operationConfig .ResourceName != "" {
369
- resName = operationConfig .ResourceName
370
- }
371
- for _ , operationType := range operationConfig .OperationType {
372
- opType = OpTypeFromString (operationType )
373
- opTypes = append (opTypes , opType )
374
- }
371
+ // The existance of the operation in the config file is not enough to
372
+ // override the operation type and/or resource name. The operation type
373
+ // and/or resource name must be specified in the config file.
374
+ if ! exists || len (opConfig .ResourceName ) == 0 || len (opConfig .OperationType ) == 0 {
375
+ return []OpType {opType }, []string {resName }
376
+ }
377
+
378
+ opTypes := []OpType {}
379
+ for _ , operationType := range opConfig .OperationType {
380
+ opType = OpTypeFromString (operationType )
381
+ opTypes = append (opTypes , opType )
375
382
}
376
- return opTypes , resName
383
+ return [] OpType { opType }, opConfig . ResourceName
377
384
}
378
385
379
386
// getMemberByPath returns a ShapeRef given a root Shape and a dot-notation
0 commit comments