@@ -22,9 +22,6 @@ import (
2222//go:embed resource.gtpl
2323var resourceTmpl string
2424
25- //go:embed resourcefw.gtpl
26- var resourceFrameworkTmpl string
27-
2825//go:embed resourcetest.gtpl
2926var resourceTestTmpl string
3027
@@ -33,6 +30,7 @@ var websiteTmpl string
3330
3431type TemplateData struct {
3532 Resource string
33+ ResourceAWS string
3634 ResourceLower string
3735 ResourceSnake string
3836 HumanFriendlyService string
@@ -43,12 +41,11 @@ type TemplateData struct {
4341 Service string
4442 ServiceLower string
4543 AWSServiceName string
46- PluginFramework bool
4744 HumanResourceName string
4845 ProviderResourceName string
4946}
5047
51- func Create (resName , snakeName string , comments , force , pluginFramework , tags bool ) error {
48+ func Create (resName , snakeName string , comments , force , tags bool ) error {
5249 wd , err := os .Getwd () // os.Getenv("GOPACKAGE") not available since this is not run with go generate
5350 if err != nil {
5451 return fmt .Errorf ("error reading working directory: %s" , err )
@@ -79,6 +76,7 @@ func Create(resName, snakeName string, comments, force, pluginFramework, tags bo
7976
8077 templateData := TemplateData {
8178 Resource : resName ,
79+ ResourceAWS : capitalizeForAWS (resName ),
8280 ResourceLower : strings .ToLower (resName ),
8381 ResourceSnake : snakeName ,
8482 HumanFriendlyService : service .HumanFriendly (),
@@ -89,17 +87,12 @@ func Create(resName, snakeName string, comments, force, pluginFramework, tags bo
8987 Service : service .ProviderNameUpper (),
9088 ServiceLower : strings .ToLower (service .ProviderNameUpper ()),
9189 AWSServiceName : service .FullHumanFriendly (),
92- PluginFramework : pluginFramework ,
9390 HumanResourceName : convert .ToHumanResName (resName ),
9491 ProviderResourceName : convert .ToProviderResourceName (servicePackage , snakeName ),
9592 }
9693
97- tmpl := resourceTmpl
98- if pluginFramework {
99- tmpl = resourceFrameworkTmpl
100- }
10194 f := fmt .Sprintf ("%s.go" , snakeName )
102- if err = writeTemplate ("newres" , f , tmpl , force , templateData ); err != nil {
95+ if err = writeTemplate ("newres" , f , resourceTmpl , force , templateData ); err != nil {
10396 return fmt .Errorf ("writing resource template: %w" , err )
10497 }
10598
@@ -155,3 +148,8 @@ func writeTemplate(templateName, filename, tmpl string, force bool, td TemplateD
155148
156149 return nil
157150}
151+
152+ // AWS API structs use different capitalization than the provider standards
153+ func capitalizeForAWS (s string ) string {
154+ return strings .ReplaceAll (s , "VPC" , "Vpc" )
155+ }
0 commit comments