Merge pull request #10978 from hashicorp/azr_invalid_prov_pause_before

Fix Invalid provprovisioner pause_before panic
This commit is contained in:
Megan Marsh 2021-04-26 11:31:42 -07:00 committed by GitHub
commit 69705f3e40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 2 deletions

View File

@ -0,0 +1,12 @@
source "null" "example1" {
communicator = "none"
}
build {
sources = ["source.null.example1"]
provisioner "shell-local" {
pause_before = "5"
inline = ["echo Did I wait a bit?"]
}
}

View File

@ -22,6 +22,8 @@ func TestValidateCommand(t *testing.T) {
{path: filepath.Join(testFixture("validate"), "null_var.json"), exitCode: 1}, {path: filepath.Join(testFixture("validate"), "null_var.json"), exitCode: 1},
{path: filepath.Join(testFixture("validate"), "var_foo_with_no_default.pkr.hcl"), exitCode: 1}, {path: filepath.Join(testFixture("validate"), "var_foo_with_no_default.pkr.hcl"), exitCode: 1},
{path: testFixture("hcl", "validation", "wrong_pause_before.pkr.hcl"), exitCode: 1},
// wrong version fails // wrong version fails
{path: filepath.Join(testFixture("version_req", "base_failure")), exitCode: 1}, {path: filepath.Join(testFixture("version_req", "base_failure")), exitCode: 1},
{path: filepath.Join(testFixture("version_req", "base_success")), exitCode: 0}, {path: filepath.Join(testFixture("version_req", "base_success")), exitCode: 0},

View File

@ -119,8 +119,9 @@ func (p *Parser) decodeProvisioner(block *hcl.Block, cfg *PackerConfig) (*Provis
pauseBefore, err := time.ParseDuration(b.PauseBefore) pauseBefore, err := time.ParseDuration(b.PauseBefore)
if err != nil { if err != nil {
return nil, append(diags, &hcl.Diagnostic{ return nil, append(diags, &hcl.Diagnostic{
Summary: "Failed to parse pause_before duration", Summary: "Failed to parse pause_before duration",
Detail: err.Error(), Severity: hcl.DiagError,
Detail: err.Error(),
}) })
} }
provisioner.PauseBefore = pauseBefore provisioner.PauseBefore = pauseBefore