terraform: string through the context meta

This commit is contained in:
Mitchell Hashimoto 2017-03-13 16:21:09 -07:00
parent 4e1511c77f
commit 9900bd752a
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
4 changed files with 36 additions and 0 deletions

View File

@ -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)
}
}

View File

@ -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,

View File

@ -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,

View File

@ -0,0 +1,3 @@
output "output" {
value = "${terraform.env}"
}