Skip to content

Commit c9a4a8a

Browse files
committed
Remove rawNames from *conversionContext.makeTerraformInput
This is a pure refactor and doesn't have behavioral effects.
1 parent f92a71e commit c9a4a8a

File tree

3 files changed

+9
-18
lines changed

3 files changed

+9
-18
lines changed

pkg/tfbridge/diff.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func visitPropertyValue(
103103
// fill in default values for empty fields (note that this is a property of the field reader, not of
104104
// the schema) as it does when computing the hash code for a set element.
105105
ctx := &conversionContext{Ctx: ctx}
106-
ev, err := ctx.makeTerraformInput(ep, resource.PropertyValue{}, e, etfs, eps, rawNames)
106+
ev, err := ctx.makeTerraformInput(ep, resource.PropertyValue{}, e, etfs, eps)
107107
if err != nil {
108108
return
109109
}

pkg/tfbridge/schema.go

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,6 @@ func (ctx *conversionContext) makeTerraformInput(
351351
old, v resource.PropertyValue,
352352
tfs shim.Schema,
353353
ps *SchemaInfo,
354-
rawNames bool,
355354
) (interface{}, error) {
356355
// For TypeList or TypeSet with MaxItems==1, we will have projected as a scalar
357356
// nested value, and need to wrap it into a single-element array before passing to
@@ -435,7 +434,7 @@ func (ctx *conversionContext) makeTerraformInput(
435434
oldElem = oldArr[i]
436435
}
437436
elemName := fmt.Sprintf("%v[%v]", name, i)
438-
e, err := ctx.makeTerraformInput(elemName, oldElem, elem, etfs, eps, rawNames)
437+
e, err := ctx.makeTerraformInput(elemName, oldElem, elem, etfs, eps)
439438
if err != nil {
440439
return nil, err
441440
}
@@ -554,15 +553,7 @@ func (ctx *conversionContext) makeMapTerraformInputs(
554553
old = olds[key]
555554
}
556555

557-
// If type information is lost (the map's element type is unknown), subsequent
558-
// nested PropertyMap values will be treated by makeObjectTerraformInputs. In this
559-
// case rawNames=true needs to make sure makeObjectTerraformInputs does not mangle
560-
// pulumiStyleLabels into terraform_style_labels. This is the legacy behavior
561-
// enforced by tests. It also makes intuitive sense: absent schema information the
562-
// code should not be doing name mangling.
563-
rawNames := tfsElement == nil
564-
565-
v, err := ctx.makeTerraformInput(name, old, value, tfsElement, psElement, rawNames)
556+
v, err := ctx.makeTerraformInput(name, old, value, tfsElement, psElement)
566557
if err != nil {
567558
return nil, err
568559
}
@@ -626,7 +617,7 @@ func (ctx *conversionContext) makeObjectTerraformInputs(
626617
}
627618

628619
// And then translate the property value.
629-
v, err := ctx.makeTerraformInput(name, old, value, tfi, psi, false)
620+
v, err := ctx.makeTerraformInput(name, old, value, tfi, psi)
630621
if err != nil {
631622
return nil, err
632623
}
@@ -769,7 +760,7 @@ func (ctx *conversionContext) applyDefaults(
769760

770761
if old, hasold := olds[key]; hasold && useOldDefault(key) {
771762
v, err := ctx.makeTerraformInput(name, resource.PropertyValue{},
772-
old, tfi, psi, rawNames)
763+
old, tfi, psi)
773764
if err != nil {
774765
return err
775766
}
@@ -811,15 +802,15 @@ func (ctx *conversionContext) applyDefaults(
811802
defaultValue, source = v, "env vars"
812803
} else if configKey := info.Default.Config; configKey != "" {
813804
if v := ctx.ProviderConfig[resource.PropertyKey(configKey)]; !v.IsNull() {
814-
tv, err := ctx.makeTerraformInput(name, resource.PropertyValue{}, v, tfi, psi, rawNames)
805+
tv, err := ctx.makeTerraformInput(name, resource.PropertyValue{}, v, tfi, psi)
815806
if err != nil {
816807
return err
817808
}
818809
defaultValue, source = tv, "config"
819810
}
820811
} else if info.Default.Value != nil {
821812
v := resource.NewPropertyValue(info.Default.Value)
822-
tv, err := ctx.makeTerraformInput(name, resource.PropertyValue{}, v, tfi, psi, rawNames)
813+
tv, err := ctx.makeTerraformInput(name, resource.PropertyValue{}, v, tfi, psi)
823814
if err != nil {
824815
return err
825816
}
@@ -921,7 +912,7 @@ func (ctx *conversionContext) applyDefaults(
921912
key, tfi, psi := getInfoFromTerraformName(name, tfs, ps, rawNames)
922913

923914
if old, hasold := olds[key]; hasold && useOldDefault(key) {
924-
v, err := ctx.makeTerraformInput(name, resource.PropertyValue{}, old, tfi, psi, rawNames)
915+
v, err := ctx.makeTerraformInput(name, resource.PropertyValue{}, old, tfi, psi)
925916
if err != nil {
926917
valueErr = err
927918
return false

pkg/tfbridge/schema_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func makeTerraformInputsForCreate(olds, news resource.PropertyMap,
6868

6969
func makeTerraformInput(v resource.PropertyValue, tfs shim.Schema, ps *SchemaInfo) (interface{}, error) {
7070
ctx := &conversionContext{}
71-
return ctx.makeTerraformInput("v", resource.PropertyValue{}, v, tfs, ps, false)
71+
return ctx.makeTerraformInput("v", resource.PropertyValue{}, v, tfs, ps)
7272
}
7373

7474
func TestMakeTerraformInputMixedMaxItemsOne(t *testing.T) {

0 commit comments

Comments
 (0)