@@ -78,12 +78,14 @@ func (a *SDKAPI) GetOperationMap(cfg *ackgenconfig.Config) *OperationMap {
7878 // create an index of Operations by operation types and resource name
7979 opMap := OperationMap {}
8080 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 {
8383 if _ , found := opMap [opType ]; ! found {
8484 opMap [opType ] = map [string ]* awssdkmodel.Operation {}
8585 }
86- opMap [opType ][resName ] = op
86+ for _ , resName := range opResourceNames {
87+ opMap [opType ][resName ] = op
88+ }
8789 }
8890 }
8991
@@ -98,7 +100,7 @@ func (a *SDKAPI) GetOperationMap(cfg *ackgenconfig.Config) *OperationMap {
98100 //
99101 // see: https://github.com/aws-controllers-k8s/community/issues/1555
100102 for opID , opCfg := range cfg .Operations {
101- if opCfg .ResourceName == "" {
103+ if len ( opCfg .ResourceName ) == 0 {
102104 continue
103105 }
104106 op , found := a .API .Operations [opID ]
@@ -107,7 +109,9 @@ func (a *SDKAPI) GetOperationMap(cfg *ackgenconfig.Config) *OperationMap {
107109 }
108110 for _ , operationType := range opCfg .OperationType {
109111 opType := OpTypeFromString (operationType )
110- opMap [opType ][opCfg.ResourceName ] = op
112+ for _ , resName := range opCfg .ResourceName {
113+ opMap [opType ][resName ] = op
114+ }
111115 }
112116 }
113117 a .opMap = & opMap
@@ -360,20 +364,23 @@ func NewSDKAPI(api *awssdkmodel.API, apiGroupSuffix string) *SDKAPI {
360364}
361365
362366// 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 ) {
364368 opType , resName := GetOpTypeAndResourceNameFromOpID (opID , cfg )
365- opTypes := [] OpType { opType }
369+ opConfig , exists := cfg . GetOperationConfig ( opID )
366370
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 )
375382 }
376- return opTypes , resName
383+ return [] OpType { opType }, opConfig . ResourceName
377384}
378385
379386// getMemberByPath returns a ShapeRef given a root Shape and a dot-notation
0 commit comments