Skip to content

Commit 589a4fc

Browse files
committed
add support for nullable metadata fields
1 parent 53e5081 commit 589a4fc

File tree

7 files changed

+234
-107
lines changed

7 files changed

+234
-107
lines changed

provisioner/terraform/resources.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ type metadataItem struct {
4343
Key string `mapstructure:"key"`
4444
Value string `mapstructure:"value"`
4545
Sensitive bool `mapstructure:"sensitive"`
46+
IsNull bool `mapstructure:"is_null"`
4647
}
4748

4849
// ConvertResources consumes Terraform state and a GraphViz representation produced by
@@ -260,6 +261,7 @@ func ConvertResources(module *tfjson.StateModule, rawGraph string) ([]*proto.Res
260261
Key: item.Key,
261262
Value: item.Value,
262263
Sensitive: item.Sensitive,
264+
IsNull: item.IsNull,
263265
})
264266
}
265267
}

provisioner/terraform/resources_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,15 @@ func TestConvertResources(t *testing.T) {
123123
Metadata: []*proto.Resource_Metadata{{
124124
Key: "hello",
125125
Value: "world",
126+
}, {
127+
Key: "null",
128+
IsNull: true,
129+
}, {
130+
Key: "empty",
131+
}, {
132+
Key: "secret",
133+
Value: "squirrel",
134+
Sensitive: true,
126135
}},
127136
}},
128137
} {

provisioner/terraform/testdata/resource-metadata/resource-metadata.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,16 @@ resource "coder_metadata" "about_info" {
2020
key = "hello"
2121
value = "world"
2222
}
23+
pair {
24+
key = "null"
25+
}
26+
pair {
27+
key = "empty"
28+
value = ""
29+
}
30+
pair {
31+
key = "secret"
32+
value = "squirrel"
33+
sensitive = true
34+
}
2335
}

provisioner/terraform/testdata/resource-metadata/resource-metadata.tfplan.json

Lines changed: 74 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

provisioner/terraform/testdata/resource-metadata/resource-metadata.tfstate.json

Lines changed: 27 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)