Merge pull request #1442 from crazy-max/hcl-fix-panic

bake: fix panic for unsupported hcl variable type
This commit is contained in:
CrazyMax 2022-12-05 14:30:04 +01:00 committed by GitHub
commit b06eaffeeb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -782,3 +782,15 @@ func TestFunctionNoResult(t *testing.T) {
_, err := ParseFile(dt, "docker-bake.hcl") _, err := ParseFile(dt, "docker-bake.hcl")
require.Error(t, err) require.Error(t, err)
} }
func TestVarUnsupportedType(t *testing.T) {
dt := []byte(`
variable "FOO" {
default = []
}
target "default" {}`)
t.Setenv("FOO", "bar")
_, err := ParseFile(dt, "docker-bake.hcl")
require.Error(t, err)
}

View File

@ -241,7 +241,7 @@ func (p *parser) resolveValue(name string) (err error) {
return nil return nil
} else { } else {
// TODO: support lists with csv values // TODO: support lists with csv values
return errors.Errorf("unsupported type %s for variable %s", v.Type(), name) return errors.Errorf("unsupported type %s for variable %s", vv.Type().FriendlyName(), name)
} }
} }
v = &vv v = &vv