console: allow to use console when there are untyped vars (#9864)
* the var will simply be "unknown" * add a test
This commit is contained in:
parent
a70164f489
commit
efd69aea2a
|
@ -60,11 +60,7 @@ func (c *ConsoleCommand) RunContext(ctx context.Context, cla *ConsoleArgs) int {
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
diags := packerStarter.Initialize()
|
_ = packerStarter.Initialize()
|
||||||
ret = writeDiags(c.Ui, nil, diags)
|
|
||||||
if ret != 0 {
|
|
||||||
return ret
|
|
||||||
}
|
|
||||||
|
|
||||||
// Determine if stdin is a pipe. If so, we evaluate directly.
|
// Determine if stdin is a pipe. If so, we evaluate directly.
|
||||||
if c.StdinPiped() {
|
if c.StdinPiped() {
|
||||||
|
|
|
@ -35,6 +35,7 @@ func Test_console(t *testing.T) {
|
||||||
{"var.list_of_string[0]", []string{"console", `-var=list_of_string=["first"]`, filepath.Join(testFixture("hcl", "variables", "list_of_string"))}, nil, "first\n"},
|
{"var.list_of_string[0]", []string{"console", `-var=list_of_string=["first"]`, filepath.Join(testFixture("hcl", "variables", "list_of_string"))}, nil, "first\n"},
|
||||||
{"var.untyped[2]", []string{"console", filepath.Join(testFixture("hcl", "variables", "untyped_var"))}, nil, "strings\n"},
|
{"var.untyped[2]", []string{"console", filepath.Join(testFixture("hcl", "variables", "untyped_var"))}, nil, "strings\n"},
|
||||||
{"var.untyped", []string{"console", `-var=untyped=just_a_string`, filepath.Join(testFixture("hcl", "variables", "untyped_var"))}, nil, "just_a_string\n"},
|
{"var.untyped", []string{"console", `-var=untyped=just_a_string`, filepath.Join(testFixture("hcl", "variables", "untyped_var"))}, nil, "just_a_string\n"},
|
||||||
|
{"var.untyped", []string{"console", filepath.Join(testFixture("hcl", "variables", "untyped_var", "var.pkr.hcl"))}, nil, "<unknown>\n"},
|
||||||
{"var.untyped", []string{"console", filepath.Join(testFixture("hcl", "variables", "untyped_var", "var.pkr.hcl"))}, []string{"PKR_VAR_untyped=just_a_string"}, "just_a_string\n"},
|
{"var.untyped", []string{"console", filepath.Join(testFixture("hcl", "variables", "untyped_var", "var.pkr.hcl"))}, []string{"PKR_VAR_untyped=just_a_string"}, "just_a_string\n"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue