terraform: string through the context meta
This commit is contained in:
parent
4e1511c77f
commit
9900bd752a
|
@ -8069,3 +8069,33 @@ func TestContext2Apply_dataDependsOn(t *testing.T) {
|
|||
t.Fatalf("bad:\n%s", strings.TrimSpace(state.String()))
|
||||
}
|
||||
}
|
||||
|
||||
func TestContext2Apply_terraformEnv(t *testing.T) {
|
||||
m := testModule(t, "apply-terraform-env")
|
||||
p := testProvider("aws")
|
||||
p.ApplyFn = testApplyFn
|
||||
p.DiffFn = testDiffFn
|
||||
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Meta: &ContextMeta{Env: "foo"},
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
})
|
||||
|
||||
if _, err := ctx.Plan(); err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
state, err := ctx.Apply()
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
actual := state.RootModule().Outputs["output"]
|
||||
expected := "foo"
|
||||
if actual == nil || actual.Value != expected {
|
||||
t.Fatalf("bad: \n%s", actual)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,6 +84,7 @@ func (w *ContextGraphWalker) EnterPath(path []string) EvalContext {
|
|||
StateLock: &w.Context.stateLock,
|
||||
Interpolater: &Interpolater{
|
||||
Operation: w.Operation,
|
||||
Meta: w.Context.meta,
|
||||
Module: w.Context.module,
|
||||
State: w.Context.state,
|
||||
StateLock: &w.Context.stateLock,
|
||||
|
|
|
@ -46,6 +46,7 @@ func newShadowContext(c *Context) (*Context, *Context, Shadow) {
|
|||
destroy: c.destroy,
|
||||
diff: c.diff.DeepCopy(),
|
||||
hooks: nil,
|
||||
meta: c.meta,
|
||||
module: c.module,
|
||||
state: c.state.DeepCopy(),
|
||||
targets: targetRaw.([]string),
|
||||
|
@ -77,6 +78,7 @@ func newShadowContext(c *Context) (*Context, *Context, Shadow) {
|
|||
diff: c.diff,
|
||||
// diffLock - no copy
|
||||
hooks: c.hooks,
|
||||
meta: c.meta,
|
||||
module: c.module,
|
||||
sh: c.sh,
|
||||
state: c.state,
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
output "output" {
|
||||
value = "${terraform.env}"
|
||||
}
|
Loading…
Reference in New Issue