Merge pull request #1468 from crazy-max/fix-git-vcs-check

build: fix env vars check for vcs details
pull/1470/head
Justin Chadwell 2 years ago committed by GitHub
commit b741d26eb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -24,13 +24,13 @@ func getGitAttributes(ctx context.Context, contextPath string, dockerfilePath st
if v, ok := os.LookupEnv("BUILDX_GIT_LABELS"); ok { if v, ok := os.LookupEnv("BUILDX_GIT_LABELS"); ok {
if v == "full" { // backward compatibility with old "full" mode if v == "full" { // backward compatibility with old "full" mode
setGitLabels = true setGitLabels = true
} else if v, _ := strconv.ParseBool(v); v { } else if v, err := strconv.ParseBool(v); err == nil {
setGitLabels = v setGitLabels = v
} }
} }
setGitInfo := true setGitInfo := true
if v, ok := os.LookupEnv("BUILDX_GIT_INFO"); ok { if v, ok := os.LookupEnv("BUILDX_GIT_INFO"); ok {
if v, _ := strconv.ParseBool(v); v { if v, err := strconv.ParseBool(v); err == nil {
setGitInfo = v setGitInfo = v
} }
} }

@ -43,6 +43,12 @@ func TestGetGitAttributes(t *testing.T) {
"vcs:revision", "vcs:revision",
}, },
}, },
{
name: "none",
envGitLabels: "false",
envGitInfo: "false",
expected: []string{},
},
{ {
name: "gitinfo", name: "gitinfo",
envGitLabels: "false", envGitLabels: "false",

Loading…
Cancel
Save