-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove rawNames
from makeObjectTerraformInputs
#1851
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
261df01
Remove `rawNames` from `makeObjectTerraformInputs`
iwahbe 991e816
Remove rawNames from `*conversionContext.makeTerraformInput`
iwahbe e1d6178
Remove rawNames from `*conversionContext.applyDefaults`
iwahbe 701fac6
Breaking: Remove rawNames from `MakeTerraformOutput` & `MakeTerraform…
iwahbe f90c041
Remove rawNames from `visitPropertyValue`
iwahbe f13bd3c
Remove rawNames from `getInfoFromTerraformName`
iwahbe 7df97a6
Add some additional test cases for "Test_makeTerraformInputsNoDefaults"
iwahbe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -396,10 +396,31 @@ func TestTerraformOutputsWithSecretsSupported(t *testing.T) { | |
}, | ||
{ | ||
name: "object_property_value", | ||
|
||
// NOTE: This input does not match the schema's type. The tfValue *should* be wrapped | ||
// in a []any{}. [MakeTerraformOutputs] handles this case, but it shouldn't need to | ||
// and tf should never return it. | ||
tfValue: map[string]interface{}{ | ||
"property_a": "a", | ||
"property_b": true, | ||
}, | ||
tfType: &schema.Schema{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, strange test case it didn't have tfType before so it was trying to parse untyped? |
||
Type: shim.TypeList, | ||
Required: true, | ||
MaxItems: 1, | ||
Elem: (&schema.Resource{ | ||
Schema: schema.SchemaMap{ | ||
"property_a": (&schema.Schema{ | ||
Type: shim.TypeString, | ||
Optional: true, | ||
}).Shim(), | ||
"property_b": (&schema.Schema{ | ||
Type: shim.TypeBool, | ||
Optional: true, | ||
}).Shim(), | ||
}, | ||
}).Shim(), | ||
}, | ||
expect: autogold.Expect(resource.PropertyMap{resource.PropertyKey("objectPropertyValue"): resource.PropertyValue{ | ||
V: resource.PropertyMap{ | ||
resource.PropertyKey("propertyA"): resource.PropertyValue{ | ||
|
@@ -607,9 +628,8 @@ func TestTerraformOutputsWithSecretsSupported(t *testing.T) { | |
}, | ||
schemaMap, | ||
schemaInfo, | ||
nil, /* assets */ | ||
false, /* useRawNames */ | ||
true, /* supportsSecrets */ | ||
nil, /* assets */ | ||
true, /* supportsSecrets */ | ||
) | ||
tt.expect.Equal(t, result) | ||
}) | ||
|
@@ -638,8 +658,7 @@ func TestTerraformOutputsWithSecretsUnsupported(t *testing.T) { | |
}, | ||
}), | ||
map[string]*SchemaInfo{}, | ||
nil, /* assets */ | ||
false, /*useRawNames*/ | ||
nil, /* assets */ | ||
false, | ||
) | ||
assert.Equal(t, resource.NewPropertyMapFromMap(map[string]interface{}{ | ||
|
@@ -1026,7 +1045,7 @@ func TestDefaults(t *testing.T) { | |
} | ||
inputs, assets, err := makeTerraformInputsForConfig(olds, props, tfs, ps) | ||
assert.NoError(t, err) | ||
outputs := MakeTerraformOutputs(ctx, f.NewTestProvider(), inputs, tfs, ps, assets, false, true) | ||
outputs := MakeTerraformOutputs(ctx, f.NewTestProvider(), inputs, tfs, ps, assets, true) | ||
|
||
// sort the defaults list before the equality test below. | ||
sortDefaultsList(outputs) | ||
|
@@ -1072,7 +1091,7 @@ func TestDefaults(t *testing.T) { | |
assert.Equal(t, "true", inputs["x2stringxbool"]) | ||
assert.Equal(t, "1", inputs["x2stringxint"]) | ||
|
||
outputs = MakeTerraformOutputs(ctx, f.NewTestProvider(), inputs, tfs, ps, assets, false, true) | ||
outputs = MakeTerraformOutputs(ctx, f.NewTestProvider(), inputs, tfs, ps, assets, true) | ||
|
||
// sort the defaults list before the equality test below. | ||
sortDefaultsList(outputs) | ||
|
@@ -1141,7 +1160,7 @@ func TestDefaultsConflictsWith(t *testing.T) { | |
|
||
inputs, assets, err := makeTerraformInputsForConfig(olds, props, tfs, ps) | ||
assert.NoError(t, err) | ||
outputs := MakeTerraformOutputs(ctx, f.NewTestProvider(), inputs, tfs, ps, assets, false, true) | ||
outputs := MakeTerraformOutputs(ctx, f.NewTestProvider(), inputs, tfs, ps, assets, true) | ||
sortDefaultsList(outputs) | ||
|
||
assert.Equal(t, resource.NewPropertyMapFromMap(map[string]interface{}{ | ||
|
@@ -1161,7 +1180,7 @@ func TestDefaultsConflictsWith(t *testing.T) { | |
inputs, assets, err = makeTerraformInputsForConfig(olds, props, tfs, ps) | ||
assert.NoError(t, err) | ||
|
||
outputs = MakeTerraformOutputs(ctx, f.NewTestProvider(), inputs, tfs, ps, assets, false, true) | ||
outputs = MakeTerraformOutputs(ctx, f.NewTestProvider(), inputs, tfs, ps, assets, true) | ||
sortDefaultsList(outputs) | ||
|
||
assert.Equal(t, resource.NewPropertyMapFromMap(map[string]interface{}{ | ||
|
@@ -1195,7 +1214,7 @@ func TestComputedAsset(t *testing.T) { | |
} | ||
inputs, assets, err := makeTerraformInputsNoDefaults(olds, props, tfs, ps) | ||
assert.NoError(t, err) | ||
outputs := MakeTerraformOutputs(ctx, shimv1.NewProvider(testTFProvider), inputs, tfs, ps, assets, false, true) | ||
outputs := MakeTerraformOutputs(ctx, shimv1.NewProvider(testTFProvider), inputs, tfs, ps, assets, true) | ||
assert.Equal(t, resource.PropertyMap{ | ||
"zzz": resource.PropertyValue{V: resource.Computed{Element: resource.PropertyValue{V: ""}}}, | ||
}, outputs) | ||
|
@@ -1215,7 +1234,7 @@ func TestInvalidAsset(t *testing.T) { | |
} | ||
inputs, assets, err := makeTerraformInputsNoDefaults(olds, props, tfs, ps) | ||
assert.NoError(t, err) | ||
outputs := MakeTerraformOutputs(ctx, shimv1.NewProvider(testTFProvider), inputs, tfs, ps, assets, false, true) | ||
outputs := MakeTerraformOutputs(ctx, shimv1.NewProvider(testTFProvider), inputs, tfs, ps, assets, true) | ||
assert.Equal(t, resource.PropertyMap{ | ||
"zzz": resource.NewStringProperty("invalid"), | ||
}, outputs) | ||
|
@@ -1280,8 +1299,7 @@ func TestOverridingTFSchema(t *testing.T) { | |
tfInputs, | ||
tfSchema, | ||
typeOverrides, | ||
nil, /* assets */ | ||
false, /*useRawNames*/ | ||
nil, /* assets */ | ||
true, | ||
) | ||
assert.Equal(t, tfOutputs, result) | ||
|
@@ -1332,7 +1350,7 @@ func TestArchiveAsAsset(t *testing.T) { | |
} | ||
inputs, assets, err := makeTerraformInputsNoDefaults(olds, props, tfs, ps) | ||
assert.NoError(t, err) | ||
outputs := MakeTerraformOutputs(ctx, shimv1.NewProvider(testTFProvider), inputs, tfs, ps, assets, false, true) | ||
outputs := MakeTerraformOutputs(ctx, shimv1.NewProvider(testTFProvider), inputs, tfs, ps, assets, true) | ||
assert.True(t, arch.DeepEquals(outputs["zzz"])) | ||
} | ||
|
||
|
@@ -1701,8 +1719,7 @@ func TestStringOutputsWithSchema(t *testing.T) { | |
"not_a_float_value": {Type: schemav1.TypeFloat}, | ||
}), | ||
map[string]*SchemaInfo{}, | ||
nil, /* assets */ | ||
false, /* useRawNames */ | ||
nil, /* assets */ | ||
true, | ||
) | ||
|
||
|
@@ -2760,7 +2777,6 @@ func TestOutputNumberTypes(t *testing.T) { | |
tfs, | ||
map[string]*SchemaInfo{}, | ||
AssetTable{}, | ||
false, | ||
true, | ||
) | ||
assert.Equal(t, resource.PropertyMap{ | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it handles it because it's trying to do MaxItems=1 mismatch toleration or something. Hard to know.