@@ -43,6 +43,21 @@ const (
4343
4444type OperationMap map [OpType ]map [string ]* awssdkmodel.Operation
4545
46+ // resourceExistsInConfig returns true if the supplied resource name exists in
47+ // the supplied Config object's Resources collection, case-insensitive
48+ // matching.
49+ func resourceExistsInConfig (
50+ subject string ,
51+ cfg * ackgenconfig.Config ,
52+ ) bool {
53+ for resName := range cfg .Resources {
54+ if strings .EqualFold (resName , subject ) {
55+ return true
56+ }
57+ }
58+ return false
59+ }
60+
4661// GetOpTypeAndResourceNameFromOpID guesses the resource name and type of
4762// operation from the OperationID
4863func GetOpTypeAndResourceNameFromOpID (
@@ -58,17 +73,19 @@ func GetOpTypeAndResourceNameFromOpID(
5873 // Do not singularize "pluralized singular" resources
5974 // like EC2's DhcpOptions, if defined in generator config's list of
6075 // resources.
61- if _ , exists := cfg . Resources [ resName ]; ! exists {
62- return OpTypeCreateBatch , pluralize . Singular ( resName )
76+ if resourceExistsInConfig ( resName , cfg ) {
77+ return OpTypeCreateBatch , resName
6378 }
79+ return OpTypeCreateBatch , pluralize .Singular (resName )
6480 }
6581 return OpTypeCreateBatch , resName
6682 } else if strings .HasPrefix (opID , "CreateBatch" ) {
6783 resName := strings .TrimPrefix (opID , "CreateBatch" )
6884 if pluralize .IsPlural (resName ) {
69- if _ , exists := cfg . Resources [ resName ]; ! exists {
70- return OpTypeCreateBatch , pluralize . Singular ( resName )
85+ if resourceExistsInConfig ( resName , cfg ) {
86+ return OpTypeCreateBatch , resName
7187 }
88+ return OpTypeCreateBatch , pluralize .Singular (resName )
7289 }
7390 return OpTypeCreateBatch , resName
7491 } else if strings .HasPrefix (opID , "Create" ) {
@@ -78,9 +95,10 @@ func GetOpTypeAndResourceNameFromOpID(
7895 // resources, then just return OpTypeCreate and the resource name.
7996 // This handles "pluralized singular" resource names like EC2's
8097 // DhcpOptions.
81- if _ , exists := cfg . Resources [ resName ]; ! exists {
82- return OpTypeCreateBatch , pluralize . Singular ( resName )
98+ if resourceExistsInConfig ( resName , cfg ) {
99+ return OpTypeCreate , resName
83100 }
101+ return OpTypeCreateBatch , pluralize .Singular (resName )
84102 }
85103 return OpTypeCreate , resName
86104 } else if strings .HasPrefix (opID , "Modify" ) {
@@ -92,10 +110,10 @@ func GetOpTypeAndResourceNameFromOpID(
92110 } else if strings .HasPrefix (opID , "Describe" ) {
93111 resName := strings .TrimPrefix (opID , "Describe" )
94112 if pluralize .IsPlural (resName ) {
95- if _ , exists := cfg . Resources [ resName ]; ! exists {
96- return OpTypeList , pluralize . Singular ( resName )
113+ if resourceExistsInConfig ( resName , cfg ) {
114+ return OpTypeGet , resName
97115 }
98- return OpTypeList , resName
116+ return OpTypeList , pluralize . Singular ( resName )
99117 }
100118 return OpTypeGet , resName
101119 } else if strings .HasPrefix (opID , "Get" ) {
@@ -106,18 +124,19 @@ func GetOpTypeAndResourceNameFromOpID(
106124 }
107125 resName := strings .TrimPrefix (opID , "Get" )
108126 if pluralize .IsPlural (resName ) {
109- if _ , exists := cfg . Resources [ resName ]; ! exists {
110- return OpTypeList , pluralize . Singular ( resName )
127+ if resourceExistsInConfig ( resName , cfg ) {
128+ return OpTypeGet , resName
111129 }
112- return OpTypeList , resName
130+ return OpTypeList , pluralize . Singular ( resName )
113131 }
114132 return OpTypeGet , resName
115133 } else if strings .HasPrefix (opID , "List" ) {
116134 resName := strings .TrimPrefix (opID , "List" )
117135 if pluralize .IsPlural (resName ) {
118- if _ , exists := cfg . Resources [ resName ]; ! exists {
119- return OpTypeList , pluralize . Singular ( resName )
136+ if resourceExistsInConfig ( resName , cfg ) {
137+ return OpTypeList , resName
120138 }
139+ return OpTypeList , pluralize .Singular (resName )
121140 }
122141 return OpTypeList , resName
123142 } else if strings .HasPrefix (opID , "Set" ) {
0 commit comments