From d55dfb5ae4a48e6256b3a75f34c317a36ee53bbb Mon Sep 17 00:00:00 2001 From: Brandon Pollack Date: Tue, 10 Dec 2024 21:46:53 +0900 Subject: [PATCH] We should use Pascal case for implied tokens because resources/data are pascal case. This unblocks pulumi convert terraform bridge changes. --- CHANGELOG_PENDING.md | 1 + pkg/convert/testdata/states/unknown/import.json | 2 +- pkg/convert/tf.go | 12 +++++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index 2e1f9e9..40947ea 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -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 diff --git a/pkg/convert/testdata/states/unknown/import.json b/pkg/convert/testdata/states/unknown/import.json index 460b4b0..72ffe9e 100644 --- a/pkg/convert/testdata/states/unknown/import.json +++ b/pkg/convert/testdata/states/unknown/import.json @@ -1,6 +1,6 @@ [ { - "Type": "unknown:index:resource", + "Type": "unknown:index:Resource", "Name": "a_resource", "ID": "abc123", "LogicalName": "", diff --git a/pkg/convert/tf.go b/pkg/convert/tf.go index bd6357e..5051250 100644 --- a/pkg/convert/tf.go +++ b/pkg/convert/tf.go @@ -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 == "" { @@ -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) }