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,8 +40,28 @@ 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),
"defaults": cty.NullVal(cty.DynamicPseudoType),
"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,8 +80,7 @@ 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),
"defaults": cty.NullVal(cty.DynamicPseudoType),
}),
false,
},
@ -94,8 +113,7 @@ func TestState_basic(t *testing.T) {
cty.StringVal("test2"),
}),
}),
"workspace": cty.StringVal(backend.DefaultStateName),
"defaults": cty.NullVal(cty.DynamicPseudoType),
"defaults": cty.NullVal(cty.DynamicPseudoType),
}),
false,
},
@ -115,8 +133,7 @@ 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),
"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,
},
@ -157,9 +173,8 @@ func TestState_basic(t *testing.T) {
"config": cty.ObjectVal(map[string]cty.Value{
"path": cty.StringVal("./testdata/missing.tfstate"),
}),
"defaults": cty.NullVal(cty.DynamicPseudoType),
"outputs": cty.EmptyObjectVal,
"workspace": cty.StringVal(backend.DefaultStateName),
"defaults": cty.NullVal(cty.DynamicPseudoType),
"outputs": cty.EmptyObjectVal,
}),
true,
},
@ -210,9 +225,8 @@ func TestState_basic(t *testing.T) {
"config": cty.MapVal(map[string]cty.Value{
"path": cty.StringVal("./testdata/empty.tfstate"),
}),
"defaults": cty.NullVal(cty.DynamicPseudoType),
"outputs": cty.EmptyObjectVal,
"workspace": cty.StringVal(backend.DefaultStateName),
"defaults": cty.NullVal(cty.DynamicPseudoType),
"outputs": cty.EmptyObjectVal,
}),
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,
},