Structured Renderer: use the new renderer when rendering the state in addition to the plan (#32629)

* Use the new renderer when rendering the state

* remove confusing and unneeded comment
This commit is contained in:
Liam Cervante
2023-02-07 09:14:14 +01:00
committed by GitHub
parent c70244426a
commit d818d7850d
31 changed files with 1311 additions and 613 deletions

View File

@@ -18,7 +18,7 @@ import (
func TestMarshalOutputs(t *testing.T) {
tests := []struct {
Outputs map[string]*states.OutputValue
Want map[string]output
Want map[string]Output
Err bool
}{
{
@@ -33,7 +33,7 @@ func TestMarshalOutputs(t *testing.T) {
Value: cty.StringVal("sekret"),
},
},
map[string]output{
map[string]Output{
"test": {
Sensitive: true,
Value: json.RawMessage(`"sekret"`),
@@ -49,7 +49,7 @@ func TestMarshalOutputs(t *testing.T) {
Value: cty.StringVal("not_so_sekret"),
},
},
map[string]output{
map[string]Output{
"test": {
Sensitive: false,
Value: json.RawMessage(`"not_so_sekret"`),
@@ -76,7 +76,7 @@ func TestMarshalOutputs(t *testing.T) {
}),
},
},
map[string]output{
map[string]Output{
"mapstring": {
Sensitive: false,
Value: json.RawMessage(`{"beep":"boop"}`),
@@ -111,7 +111,7 @@ func TestMarshalOutputs(t *testing.T) {
func TestMarshalAttributeValues(t *testing.T) {
tests := []struct {
Attr cty.Value
Want attributeValues
Want AttributeValues
}{
{
cty.NilVal,
@@ -125,13 +125,13 @@ func TestMarshalAttributeValues(t *testing.T) {
cty.ObjectVal(map[string]cty.Value{
"foo": cty.StringVal("bar"),
}),
attributeValues{"foo": json.RawMessage(`"bar"`)},
AttributeValues{"foo": json.RawMessage(`"bar"`)},
},
{
cty.ObjectVal(map[string]cty.Value{
"foo": cty.NullVal(cty.String),
}),
attributeValues{"foo": json.RawMessage(`null`)},
AttributeValues{"foo": json.RawMessage(`null`)},
},
{
cty.ObjectVal(map[string]cty.Value{
@@ -143,7 +143,7 @@ func TestMarshalAttributeValues(t *testing.T) {
cty.StringVal("moon"),
}),
}),
attributeValues{
AttributeValues{
"bar": json.RawMessage(`{"hello":"world"}`),
"baz": json.RawMessage(`["goodnight","moon"]`),
},
@@ -159,7 +159,7 @@ func TestMarshalAttributeValues(t *testing.T) {
cty.StringVal("moon").Mark(marks.Sensitive),
}),
}),
attributeValues{
AttributeValues{
"bar": json.RawMessage(`{"hello":"world"}`),
"baz": json.RawMessage(`["goodnight","moon"]`),
},
@@ -180,7 +180,7 @@ func TestMarshalResources(t *testing.T) {
tests := map[string]struct {
Resources map[string]*states.Resource
Schemas *terraform.Schemas
Want []resource
Want []Resource
Err bool
}{
"nil": {
@@ -214,15 +214,15 @@ func TestMarshalResources(t *testing.T) {
},
},
testSchemas(),
[]resource{
[]Resource{
{
Address: "test_thing.bar",
Mode: "managed",
Type: "test_thing",
Name: "bar",
Index: addrs.InstanceKey(nil),
Index: nil,
ProviderName: "registry.terraform.io/hashicorp/test",
AttributeValues: attributeValues{
AttributeValues: AttributeValues{
"foozles": json.RawMessage(`null`),
"woozles": json.RawMessage(`"confuzles"`),
},
@@ -260,15 +260,15 @@ func TestMarshalResources(t *testing.T) {
},
},
testSchemas(),
[]resource{
[]Resource{
{
Address: "test_thing.bar",
Mode: "managed",
Type: "test_thing",
Name: "bar",
Index: addrs.InstanceKey(nil),
Index: nil,
ProviderName: "registry.terraform.io/hashicorp/test",
AttributeValues: attributeValues{
AttributeValues: AttributeValues{
"foozles": json.RawMessage(`"confuzles"`),
"woozles": json.RawMessage(`null`),
},
@@ -331,15 +331,15 @@ func TestMarshalResources(t *testing.T) {
},
},
testSchemas(),
[]resource{
[]Resource{
{
Address: "test_thing.bar[0]",
Mode: "managed",
Type: "test_thing",
Name: "bar",
Index: addrs.IntKey(0),
Index: json.RawMessage(`0`),
ProviderName: "registry.terraform.io/hashicorp/test",
AttributeValues: attributeValues{
AttributeValues: AttributeValues{
"foozles": json.RawMessage(`null`),
"woozles": json.RawMessage(`"confuzles"`),
},
@@ -373,15 +373,15 @@ func TestMarshalResources(t *testing.T) {
},
},
testSchemas(),
[]resource{
[]Resource{
{
Address: "test_thing.bar[\"rockhopper\"]",
Mode: "managed",
Type: "test_thing",
Name: "bar",
Index: addrs.StringKey("rockhopper"),
Index: json.RawMessage(`"rockhopper"`),
ProviderName: "registry.terraform.io/hashicorp/test",
AttributeValues: attributeValues{
AttributeValues: AttributeValues{
"foozles": json.RawMessage(`null`),
"woozles": json.RawMessage(`"confuzles"`),
},
@@ -417,16 +417,16 @@ func TestMarshalResources(t *testing.T) {
},
},
testSchemas(),
[]resource{
[]Resource{
{
Address: "test_thing.bar",
Mode: "managed",
Type: "test_thing",
Name: "bar",
Index: addrs.InstanceKey(nil),
Index: nil,
ProviderName: "registry.terraform.io/hashicorp/test",
DeposedKey: deposedKey.String(),
AttributeValues: attributeValues{
AttributeValues: AttributeValues{
"foozles": json.RawMessage(`null`),
"woozles": json.RawMessage(`"confuzles"`),
},
@@ -466,15 +466,15 @@ func TestMarshalResources(t *testing.T) {
},
},
testSchemas(),
[]resource{
[]Resource{
{
Address: "test_thing.bar",
Mode: "managed",
Type: "test_thing",
Name: "bar",
Index: addrs.InstanceKey(nil),
Index: nil,
ProviderName: "registry.terraform.io/hashicorp/test",
AttributeValues: attributeValues{
AttributeValues: AttributeValues{
"foozles": json.RawMessage(`null`),
"woozles": json.RawMessage(`"confuzles"`),
},
@@ -485,10 +485,10 @@ func TestMarshalResources(t *testing.T) {
Mode: "managed",
Type: "test_thing",
Name: "bar",
Index: addrs.InstanceKey(nil),
Index: nil,
ProviderName: "registry.terraform.io/hashicorp/test",
DeposedKey: deposedKey.String(),
AttributeValues: attributeValues{
AttributeValues: AttributeValues{
"foozles": json.RawMessage(`null`),
"woozles": json.RawMessage(`"confuzles"`),
},
@@ -526,15 +526,15 @@ func TestMarshalResources(t *testing.T) {
},
},
testSchemas(),
[]resource{
[]Resource{
{
Address: "test_map_attr.bar",
Mode: "managed",
Type: "test_map_attr",
Name: "bar",
Index: addrs.InstanceKey(nil),
Index: nil,
ProviderName: "registry.terraform.io/hashicorp/test",
AttributeValues: attributeValues{
AttributeValues: AttributeValues{
"data": json.RawMessage(`{"woozles":"confuzles"}`),
},
SensitiveValues: json.RawMessage(`{"data":true}`),