@@ -62,6 +62,7 @@ func main() {
6262 v := & visitor {
6363 g : g ,
6464
65+ actions : make (map [string ]ResourceDatum , 0 ),
6566 ephemeralResources : make (map [string ]ResourceDatum , 0 ),
6667 frameworkDataSources : make (map [string ]ResourceDatum , 0 ),
6768 frameworkResources : make (map [string ]ResourceDatum , 0 ),
@@ -94,6 +95,7 @@ func main() {
9495 GoV2Package : l .GoV2Package (),
9596 ProviderPackage : p ,
9697 ProviderNameUpper : l .ProviderNameUpper (),
98+ Actions : v .actions ,
9799 EphemeralResources : v .ephemeralResources ,
98100 FrameworkDataSources : v .frameworkDataSources ,
99101 FrameworkResources : v .frameworkResources ,
@@ -102,6 +104,9 @@ func main() {
102104 }
103105
104106 var imports []goImport
107+ for resource := range maps .Values (v .actions ) {
108+ imports = append (imports , resource .goImports ... )
109+ }
105110 for resource := range maps .Values (v .ephemeralResources ) {
106111 imports = append (imports , resource .goImports ... )
107112 }
@@ -232,6 +237,7 @@ type ServiceDatum struct {
232237 GoV2Package string // AWS SDK for Go v2 package name
233238 ProviderPackage string
234239 ProviderNameUpper string
240+ Actions map [string ]ResourceDatum
235241 EphemeralResources map [string ]ResourceDatum
236242 FrameworkDataSources map [string ]ResourceDatum
237243 FrameworkResources map [string ]ResourceDatum
@@ -260,6 +266,7 @@ type visitor struct {
260266 functionName string
261267 packageName string
262268
269+ actions map [string ]ResourceDatum
263270 ephemeralResources map [string ]ResourceDatum
264271 frameworkDataSources map [string ]ResourceDatum
265272 frameworkResources map [string ]ResourceDatum
@@ -512,6 +519,34 @@ func (v *visitor) processFuncDecl(funcDecl *ast.FuncDecl) {
512519 }
513520
514521 switch annotationName := m [1 ]; annotationName {
522+ case "Action" :
523+ if len (args .Positional ) == 0 {
524+ v .errs = append (v .errs , fmt .Errorf ("no type name: %s" , fmt .Sprintf ("%s.%s" , v .packageName , v .functionName )))
525+ continue
526+ }
527+
528+ typeName := args .Positional [0 ]
529+
530+ if ! validTypeName .MatchString (typeName ) {
531+ v .errs = append (v .errs , fmt .Errorf ("invalid type name (%s): %s" , typeName , fmt .Sprintf ("%s.%s" , v .packageName , v .functionName )))
532+ continue
533+ }
534+
535+ if d .Name == "" {
536+ v .errs = append (v .errs , fmt .Errorf ("no friendly name: %s" , fmt .Sprintf ("%s.%s" , v .packageName , v .functionName )))
537+ continue
538+ }
539+
540+ if _ , ok := v .actions [typeName ]; ok {
541+ v .errs = append (v .errs , fmt .Errorf ("duplicate Action (%s): %s" , typeName , fmt .Sprintf ("%s.%s" , v .packageName , v .functionName )))
542+ } else {
543+ v .actions [typeName ] = d
544+ }
545+
546+ if d .HasV6_0SDKv2Fix {
547+ v .errs = append (v .errs , fmt .Errorf ("V60SDKv2Fix not supported for Actions: %s" , fmt .Sprintf ("%s.%s" , v .packageName , v .functionName )))
548+ }
549+
515550 case "EphemeralResource" :
516551 if len (args .Positional ) == 0 {
517552 v .errs = append (v .errs , fmt .Errorf ("no type name: %s" , fmt .Sprintf ("%s.%s" , v .packageName , v .functionName )))
0 commit comments