Skip to content

Commit

Permalink
Use camel case for generated method names (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
rabbitfang authored Jul 22, 2022
1 parent 12d344a commit c99041c
Show file tree
Hide file tree
Showing 11 changed files with 136 additions and 113 deletions.
33 changes: 28 additions & 5 deletions hack/awsgen/generator/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ func linenumbers(in string) string {

// fetchFuncName returns the name of the fetch (aka list) functions for a specific type
func fetchFuncName(svc config.Service, typ config.Type) string {
return fmt.Sprintf(
"fetch_%s_%s",
return lowerCamelCaseJoin(
"fetch",
svc.Name,
typ.Name,
)
}

// tagFuncName returns the name of the tags function for a specific type
func tagFuncName(svc config.Service, typ config.Type) string {
return fmt.Sprintf(
"getTags_%s_%s",
return lowerCamelCaseJoin(
"getTags",
svc.Name,
typ.Name,
)
Expand All @@ -71,5 +71,28 @@ func resourceName(service config.Service, typ config.Type) string {

// registerFuncName returns the name of the Go func that returns type mapping data for a specific service.
func registerFuncName(svc config.Service) string {
return "register_" + svc.Name
return lowerCamelCaseJoin(
"register",
svc.Name,
)
}

// only ASCII supported
func lowerCamelCaseJoin(parts ...string) string {
var out []string
for idx, part := range parts {
if len(part) == 0 {
continue
}

if idx > 0 {
firstChar := part[0:1]
firstChar = strings.ToUpper(firstChar)
part = firstChar + part[1:]
}

out = append(out, part)
}

return strings.Join(out, "")
}
6 changes: 3 additions & 3 deletions pkg/provider/aws/zz_autoscaling.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c99041c

Please sign in to comment.