From cf8fa4a404e86c9f8313e59a1e87d4910d98279b Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Wed, 14 Dec 2022 09:45:13 +0100 Subject: [PATCH] build: fix env vars check for vcs details Signed-off-by: CrazyMax --- build/git.go | 4 ++-- build/git_test.go | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/build/git.go b/build/git.go index 67aea527..8cabbb07 100644 --- a/build/git.go +++ b/build/git.go @@ -24,13 +24,13 @@ func getGitAttributes(ctx context.Context, contextPath string, dockerfilePath st if v, ok := os.LookupEnv("BUILDX_GIT_LABELS"); ok { if v == "full" { // backward compatibility with old "full" mode setGitLabels = true - } else if v, _ := strconv.ParseBool(v); v { + } else if v, err := strconv.ParseBool(v); err == nil { setGitLabels = v } } setGitInfo := true 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 } } diff --git a/build/git_test.go b/build/git_test.go index 5dc630f4..6b531837 100644 --- a/build/git_test.go +++ b/build/git_test.go @@ -43,6 +43,12 @@ func TestGetGitAttributes(t *testing.T) { "vcs:revision", }, }, + { + name: "none", + envGitLabels: "false", + envGitInfo: "false", + expected: []string{}, + }, { name: "gitinfo", envGitLabels: "false",