Skip to content

Commit 4ad9aea

Browse files
committed
fix null tags
1 parent 5e8f1c5 commit 4ad9aea

File tree

7 files changed

+14
-1
lines changed

7 files changed

+14
-1
lines changed

cli/clidisplay/resources.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func WorkspaceTags(writer io.Writer, tags types.TagBlocks) hcl.Diagnostics {
2323
tableWriter.AppendHeader(row)
2424
for _, tb := range tags {
2525
for _, tag := range tb.Tags {
26-
if tag.IsKnown() {
26+
if tag.Valid() {
2727
k, v := tag.AsStrings()
2828
tableWriter.AppendRow(table.Row{k, v, ""})
2929
continue

preview_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,16 @@ func Test_Extract(t *testing.T) {
163163
expUnknowns: []string{},
164164
params: map[string]func(t *testing.T, parameter types.Parameter){},
165165
},
166+
{
167+
name: "null default",
168+
dir: "nulldefault",
169+
expTags: map[string]string{},
170+
input: preview.Input{
171+
ParameterValues: map[string]types.ParameterValue{},
172+
},
173+
expUnknowns: []string{},
174+
params: map[string]func(t *testing.T, parameter types.Parameter){},
175+
},
166176
} {
167177
t.Run(tc.name, func(t *testing.T) {
168178
t.Parallel()

testdata/nulldefault/main.tf

Whitespace-only changes.

testdata/nulldefault/vars.tfvars

Whitespace-only changes.

testdata/test/main.tf

Whitespace-only changes.

testdata/test/vars.tfvars

Whitespace-only changes.

types/tags.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ func (t Tag) Valid() bool {
8484
if !t.Key.Type().Equals(cty.String) || !t.Value.Type().Equals(cty.String) {
8585
return false
8686
}
87+
if t.Key.IsNull() || t.Value.IsNull() {
88+
return false
89+
}
8790
return true
8891
}
8992

0 commit comments

Comments
 (0)