mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-28 18:01:01 -06:00
Merge pull request #19732 from hashicorp/jbardin/terraform-remote-state
there is always an implied workspace of "default"
This commit is contained in:
commit
725ccea6d4
@ -104,18 +104,15 @@ func dataSourceRemoteStateRead(d *cty.Value) (cty.Value, tfdiags.Diagnostics) {
|
||||
return cty.NilVal, diags
|
||||
}
|
||||
|
||||
var name string
|
||||
name := backend.DefaultStateName
|
||||
|
||||
if workspaceVal := d.GetAttr("workspace"); !workspaceVal.IsNull() {
|
||||
newState["workspace"] = workspaceVal
|
||||
ws := workspaceVal.AsString()
|
||||
if ws != backend.DefaultStateName {
|
||||
name = ws
|
||||
}
|
||||
} else {
|
||||
newState["workspace"] = cty.NullVal(cty.String)
|
||||
name = workspaceVal.AsString()
|
||||
}
|
||||
|
||||
newState["workspace"] = cty.StringVal(name)
|
||||
|
||||
state, err := b.StateMgr(name)
|
||||
if err != nil {
|
||||
diags = diags.Append(tfdiags.AttributeValue(
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/apparentlymart/go-dump/dump"
|
||||
"github.com/hashicorp/terraform/backend"
|
||||
"github.com/zclconf/go-cty/cty"
|
||||
)
|
||||
|
||||
@ -34,7 +35,7 @@ func TestState_basic(t *testing.T) {
|
||||
"outputs": cty.ObjectVal(map[string]cty.Value{
|
||||
"foo": cty.StringVal("bar"),
|
||||
}),
|
||||
"workspace": cty.NullVal(cty.String),
|
||||
"workspace": cty.StringVal(backend.DefaultStateName),
|
||||
"defaults": cty.NullVal(cty.DynamicPseudoType),
|
||||
}),
|
||||
false,
|
||||
@ -68,7 +69,7 @@ func TestState_basic(t *testing.T) {
|
||||
cty.StringVal("test2"),
|
||||
}),
|
||||
}),
|
||||
"workspace": cty.NullVal(cty.String),
|
||||
"workspace": cty.StringVal(backend.DefaultStateName),
|
||||
"defaults": cty.NullVal(cty.DynamicPseudoType),
|
||||
}),
|
||||
false,
|
||||
@ -89,7 +90,7 @@ func TestState_basic(t *testing.T) {
|
||||
"map": cty.NullVal(cty.DynamicPseudoType),
|
||||
"list": cty.NullVal(cty.DynamicPseudoType),
|
||||
}),
|
||||
"workspace": cty.NullVal(cty.String),
|
||||
"workspace": cty.StringVal(backend.DefaultStateName),
|
||||
"defaults": cty.NullVal(cty.DynamicPseudoType),
|
||||
}),
|
||||
false,
|
||||
@ -115,7 +116,7 @@ func TestState_basic(t *testing.T) {
|
||||
"outputs": cty.ObjectVal(map[string]cty.Value{
|
||||
"foo": cty.StringVal("bar"),
|
||||
}),
|
||||
"workspace": cty.NullVal(cty.String),
|
||||
"workspace": cty.StringVal(backend.DefaultStateName),
|
||||
}),
|
||||
false,
|
||||
},
|
||||
@ -133,7 +134,7 @@ func TestState_basic(t *testing.T) {
|
||||
}),
|
||||
"defaults": cty.NullVal(cty.DynamicPseudoType),
|
||||
"outputs": cty.EmptyObjectVal,
|
||||
"workspace": cty.NullVal(cty.String),
|
||||
"workspace": cty.StringVal(backend.DefaultStateName),
|
||||
}),
|
||||
true,
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user