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

command/show (plan -json): fix panic #21541

Merged
merged 2 commits into from Jun 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 1 addition & 15 deletions command/jsonplan/plan.go
Expand Up @@ -210,21 +210,7 @@ func (p *plan) marshalResourceChanges(changes *plans.Changes, schemas *terraform
if err != nil {
return err
}
afterUnknown, _ = cty.Transform(changeV.After, func(path cty.Path, val cty.Value) (cty.Value, error) {
if val.IsNull() {
return cty.False, nil
}

if !val.Type().IsPrimitiveType() {
return val, nil // just pass through non-primitives; they already contain our transform results
}

if val.IsKnown() {
return cty.False, nil
}

return cty.True, nil
})
afterUnknown = cty.EmptyObjectVal
} else {
filteredAfter := omitUnknowns(changeV.After)
if filteredAfter.IsNull() {
Expand Down
2 changes: 1 addition & 1 deletion command/jsonplan/values_test.go
Expand Up @@ -173,7 +173,7 @@ func TestMarshalPlanResources(t *testing.T) {
Want []resource
Err bool
}{
"create with unkonwns": {
"create with unknowns": {
Action: plans.Create,
Before: cty.NullVal(cty.EmptyObject),
After: cty.ObjectVal(map[string]cty.Value{
Expand Down
2 changes: 0 additions & 2 deletions command/show_test.go
Expand Up @@ -2,7 +2,6 @@ package command

import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
Expand Down Expand Up @@ -221,7 +220,6 @@ func TestShow_json_output(t *testing.T) {
json.Unmarshal([]byte(byteValue), &want)

if !cmp.Equal(got, want) {
fmt.Println(ui.OutputWriter.String())
t.Fatalf("wrong result:\n %v\n", cmp.Diff(got, want))
}

Expand Down
7 changes: 2 additions & 5 deletions command/test-fixtures/show-json/basic-delete/output.json
Expand Up @@ -48,10 +48,7 @@
"ami": "bar",
"id": "placeholder"
},
"after_unknown": {
"ami": false,
"id": false
}
"after_unknown": {}
}
},
{
Expand All @@ -69,7 +66,7 @@
"id": "placeholder"
},
"after": null,
"after_unknown": false
"after_unknown": {}
}
}
],
Expand Down
5 changes: 1 addition & 4 deletions command/test-fixtures/show-json/basic-update/output.json
Expand Up @@ -48,10 +48,7 @@
"ami": "bar",
"id": "placeholder"
},
"after_unknown": {
"ami": false,
"id": false
}
"after_unknown": {}
}
}
],
Expand Down