Skip to content
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

Handle Output values in diffs #682

Merged
merged 5 commits into from
Aug 1, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
### Bug fixes

- Properly reference override values in Python Helm SDK (https://github.com/pulumi/pulumi-kubernetes/pull/676).
- Handle Output values in diffs. (https://github.com/pulumi/pulumi-kubernetes/pull/682).

## 0.25.3 (July 29, 2019)

Expand Down
3 changes: 2 additions & 1 deletion pkg/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,8 @@ func (k *kubeProvider) Diff(
var isInputPatch bool
var patchBase *unstructured.Unstructured

tryDryRun := supportsDryRun && oldInputs.GroupVersionKind().String() == gvk.String()
tryDryRun := supportsDryRun && oldInputs.GroupVersionKind().String() == gvk.String() &&
lblackstone marked this conversation as resolved.
Show resolved Hide resolved
!hasComputedValue(newInputs) && !hasComputedValue(oldInputs)
if tryDryRun {
patch, patchBase, err = k.dryRunPatch(oldInputs, newInputs)

Expand Down
13 changes: 13 additions & 0 deletions pkg/provider/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ func hasComputedValue(obj *unstructured.Unstructured) bool {
if field, isMap := v.(map[string]interface{}); isMap {
objects = append(objects, field)
}
if field, isSlice := v.([]interface{}); isSlice {
lblackstone marked this conversation as resolved.
Show resolved Hide resolved
for _, v := range field {
if _, isComputed := v.(resource.Computed); isComputed {
return true
}
if field, isMap := v.(map[string]interface{}); isMap {
objects = append(objects, field)
}
}
}
if field, isSlice := v.([]map[string]interface{}); isSlice {
objects = append(objects, field...)
}
}
}

Expand Down
20 changes: 20 additions & 0 deletions pkg/provider/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,26 @@ func TestHasComputedValue(t *testing.T) {
}},
hasComputedValue: true,
},
{
name: "Object with nested slice of map[string]interface{} has a computed value",
obj: &unstructured.Unstructured{Object: map[string]interface{}{
"field1": 1,
"field2": []map[string]interface{}{
{"field3": resource.Computed{}},
},
}},
hasComputedValue: true,
},
{
name: "Object with nested slice of interface{} has a computed value",
obj: &unstructured.Unstructured{Object: map[string]interface{}{
"field1": 1,
"field2": []interface{}{
resource.Computed{},
},
}},
hasComputedValue: true,
},
}

for _, test := range tests {
Expand Down