Skip to content

Commit

Permalink
We should use Pascal case for implied tokens because resources/data are
Browse files Browse the repository at this point in the history
pascal case.

This unblocks pulumi convert terraform bridge changes.
  • Loading branch information
brandonpollack23 committed Dec 10, 2024
1 parent 1148f36 commit d55dfb5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### Improvements

- change resource names to pascal case so they work.
- Add parameterization block to "package" blocks
- Add generation of pcl "package" blocks

Expand Down
2 changes: 1 addition & 1 deletion pkg/convert/testdata/states/unknown/import.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"Type": "unknown:index:resource",
"Type": "unknown:index:Resource",
"Name": "a_resource",
"ID": "abc123",
"LogicalName": "",
Expand Down
12 changes: 11 additions & 1 deletion pkg/convert/tf.go
Original file line number Diff line number Diff line change
Expand Up @@ -1291,6 +1291,15 @@ func camelCaseName(name string) string {
return name
}

func pascalCaseName(name string) string {
if name == "" {
return ""
}

ccName := camelCaseName(name)
return strings.ToUpper(string(rune(ccName[0]))) + ccName[1:]
}

// Returns whether the fully qualified path is being applied for a property.
func (s *scopes) isPropertyPath(fullyQualifiedPath string) bool {
if fullyQualifiedPath == "" {
Expand Down Expand Up @@ -2207,8 +2216,9 @@ func impliedToken(typeName string) string {
if under := strings.Index(typeName, "_"); under != -1 {
provider := typeName[:under]
typeName = typeName[under+1:]
return fmt.Sprintf("%s:index:%s", provider, camelCaseName(typeName))
return fmt.Sprintf("%s:index:%s", provider, pascalCaseName(typeName))
}

return camelCaseName(typeName)
}

Expand Down

0 comments on commit d55dfb5

Please sign in to comment.