always return original workspace, even when null
The returned value type needs to strictly match the proposed value type.
This commit is contained in:
parent
6ef11e9d9e
commit
a0fad2c6b4
|
@ -97,10 +97,13 @@ func dataSourceRemoteStateRead(d cty.Value) (cty.Value, tfdiags.Diagnostics) {
|
|||
newState["backend"] = d.GetAttr("backend")
|
||||
newState["config"] = d.GetAttr("config")
|
||||
|
||||
workspaceName := backend.DefaultStateName
|
||||
|
||||
if workspaceVal := d.GetAttr("workspace"); !workspaceVal.IsNull() {
|
||||
workspaceVal := d.GetAttr("workspace")
|
||||
// This attribute is not computed, so we always have to store the state
|
||||
// value, even if we implicitly use a default.
|
||||
newState["workspace"] = workspaceVal
|
||||
|
||||
workspaceName := backend.DefaultStateName
|
||||
if !workspaceVal.IsNull() {
|
||||
workspaceName = workspaceVal.AsString()
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ func TestState_basic(t *testing.T) {
|
|||
"foo": cty.StringVal("bar"),
|
||||
}),
|
||||
"defaults": cty.NullVal(cty.DynamicPseudoType),
|
||||
"workspace": cty.NullVal(cty.String),
|
||||
}),
|
||||
false,
|
||||
},
|
||||
|
@ -81,6 +82,7 @@ func TestState_basic(t *testing.T) {
|
|||
"foo": cty.StringVal("bar"),
|
||||
}),
|
||||
"defaults": cty.NullVal(cty.DynamicPseudoType),
|
||||
"workspace": cty.NullVal(cty.String),
|
||||
}),
|
||||
false,
|
||||
},
|
||||
|
@ -114,6 +116,7 @@ func TestState_basic(t *testing.T) {
|
|||
}),
|
||||
}),
|
||||
"defaults": cty.NullVal(cty.DynamicPseudoType),
|
||||
"workspace": cty.NullVal(cty.String),
|
||||
}),
|
||||
false,
|
||||
},
|
||||
|
@ -134,6 +137,7 @@ func TestState_basic(t *testing.T) {
|
|||
"list": cty.NullVal(cty.DynamicPseudoType),
|
||||
}),
|
||||
"defaults": cty.NullVal(cty.DynamicPseudoType),
|
||||
"workspace": cty.NullVal(cty.String),
|
||||
}),
|
||||
false,
|
||||
},
|
||||
|
@ -158,6 +162,7 @@ func TestState_basic(t *testing.T) {
|
|||
"outputs": cty.ObjectVal(map[string]cty.Value{
|
||||
"foo": cty.StringVal("bar"),
|
||||
}),
|
||||
"workspace": cty.NullVal(cty.String),
|
||||
}),
|
||||
false,
|
||||
},
|
||||
|
@ -175,6 +180,7 @@ func TestState_basic(t *testing.T) {
|
|||
}),
|
||||
"defaults": cty.NullVal(cty.DynamicPseudoType),
|
||||
"outputs": cty.EmptyObjectVal,
|
||||
"workspace": cty.NullVal(cty.String),
|
||||
}),
|
||||
true,
|
||||
},
|
||||
|
@ -227,6 +233,7 @@ func TestState_basic(t *testing.T) {
|
|||
}),
|
||||
"defaults": cty.NullVal(cty.DynamicPseudoType),
|
||||
"outputs": cty.EmptyObjectVal,
|
||||
"workspace": cty.NullVal(cty.String),
|
||||
}),
|
||||
false,
|
||||
},
|
||||
|
@ -247,6 +254,7 @@ func TestState_basic(t *testing.T) {
|
|||
"outputs": cty.ObjectVal(map[string]cty.Value{
|
||||
"foo": cty.StringVal("bar"),
|
||||
}),
|
||||
"workspace": cty.NullVal(cty.String),
|
||||
}),
|
||||
false,
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue