Merge pull request #25297 from hashicorp/jbardin/terraform-remote-state

don't set remote workspace in state
This commit is contained in:
James Bardin 2020-06-22 12:04:19 -04:00 committed by GitHub
commit ff91a2257b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 17 deletions

View File

@ -104,8 +104,6 @@ func dataSourceRemoteStateRead(d cty.Value) (cty.Value, tfdiags.Diagnostics) {
workspaceName = workspaceVal.AsString()
}
newState["workspace"] = cty.StringVal(workspaceName)
state, err := b.StateMgr(workspaceName)
if err != nil {
diags = diags.Append(tfdiags.AttributeValue(

View File

@ -40,7 +40,27 @@ func TestState_basic(t *testing.T) {
"outputs": cty.ObjectVal(map[string]cty.Value{
"foo": cty.StringVal("bar"),
}),
"defaults": cty.NullVal(cty.DynamicPseudoType),
}),
false,
},
"workspace": {
cty.ObjectVal(map[string]cty.Value{
"backend": cty.StringVal("local"),
"workspace": cty.StringVal(backend.DefaultStateName),
"config": cty.ObjectVal(map[string]cty.Value{
"path": cty.StringVal("./testdata/basic.tfstate"),
}),
}),
cty.ObjectVal(map[string]cty.Value{
"backend": cty.StringVal("local"),
"workspace": cty.StringVal(backend.DefaultStateName),
"config": cty.ObjectVal(map[string]cty.Value{
"path": cty.StringVal("./testdata/basic.tfstate"),
}),
"outputs": cty.ObjectVal(map[string]cty.Value{
"foo": cty.StringVal("bar"),
}),
"defaults": cty.NullVal(cty.DynamicPseudoType),
}),
false,
@ -60,7 +80,6 @@ func TestState_basic(t *testing.T) {
"outputs": cty.ObjectVal(map[string]cty.Value{
"foo": cty.StringVal("bar"),
}),
"workspace": cty.StringVal(backend.DefaultStateName),
"defaults": cty.NullVal(cty.DynamicPseudoType),
}),
false,
@ -94,7 +113,6 @@ func TestState_basic(t *testing.T) {
cty.StringVal("test2"),
}),
}),
"workspace": cty.StringVal(backend.DefaultStateName),
"defaults": cty.NullVal(cty.DynamicPseudoType),
}),
false,
@ -115,7 +133,6 @@ func TestState_basic(t *testing.T) {
"map": cty.NullVal(cty.DynamicPseudoType),
"list": cty.NullVal(cty.DynamicPseudoType),
}),
"workspace": cty.StringVal(backend.DefaultStateName),
"defaults": cty.NullVal(cty.DynamicPseudoType),
}),
false,
@ -141,7 +158,6 @@ func TestState_basic(t *testing.T) {
"outputs": cty.ObjectVal(map[string]cty.Value{
"foo": cty.StringVal("bar"),
}),
"workspace": cty.StringVal(backend.DefaultStateName),
}),
false,
},
@ -159,7 +175,6 @@ func TestState_basic(t *testing.T) {
}),
"defaults": cty.NullVal(cty.DynamicPseudoType),
"outputs": cty.EmptyObjectVal,
"workspace": cty.StringVal(backend.DefaultStateName),
}),
true,
},
@ -212,7 +227,6 @@ func TestState_basic(t *testing.T) {
}),
"defaults": cty.NullVal(cty.DynamicPseudoType),
"outputs": cty.EmptyObjectVal,
"workspace": cty.StringVal(backend.DefaultStateName),
}),
false,
},
@ -233,7 +247,6 @@ func TestState_basic(t *testing.T) {
"outputs": cty.ObjectVal(map[string]cty.Value{
"foo": cty.StringVal("bar"),
}),
"workspace": cty.StringVal(backend.DefaultStateName),
}),
false,
},