diff --git a/pkg/buildcontext/git.go b/pkg/buildcontext/git.go index 11daea4c8..291f834f6 100644 --- a/pkg/buildcontext/git.go +++ b/pkg/buildcontext/git.go @@ -27,10 +27,12 @@ import ( const ( gitPullMethodEnvKey = "GIT_PULL_METHOD" + gitPullMethodHttps = "https" + gitPullMethodHttp = "http" ) var ( - supportedGitPullMethods = map[string]bool{"https": true, "http": true} + supportedGitPullMethods = map[string]bool{gitPullMethodHttps: true, gitPullMethodHttp: true} ) // Git unifies calls to download and unpack the build context. diff --git a/pkg/buildcontext/git_test.go b/pkg/buildcontext/git_test.go index 8505897f0..6f293a6ef 100644 --- a/pkg/buildcontext/git_test.go +++ b/pkg/buildcontext/git_test.go @@ -15,7 +15,7 @@ func TestGetGitPullMethod(t *testing.T) { { testName: "noEnv", setEnv: func() (expectedValue string) { - expectedValue = "https" + expectedValue = gitPullMethodHttps return }, }, @@ -23,18 +23,18 @@ func TestGetGitPullMethod(t *testing.T) { testName: "emptyEnv", setEnv: func() (expectedValue string) { _ = os.Setenv(gitPullMethodEnvKey, "") - expectedValue = "https" + expectedValue = gitPullMethodHttps return }, }, { testName: "httpEnv", setEnv: func() (expectedValue string) { - err := os.Setenv(gitPullMethodEnvKey, "http") + err := os.Setenv(gitPullMethodEnvKey, gitPullMethodHttp) if nil != err { - expectedValue = "https" + expectedValue = gitPullMethodHttps } else { - expectedValue = "http" + expectedValue = gitPullMethodHttp } return }, @@ -42,8 +42,8 @@ func TestGetGitPullMethod(t *testing.T) { { testName: "httpsEnv", setEnv: func() (expectedValue string) { - _ = os.Setenv(gitPullMethodEnvKey, "https") - expectedValue = "https" + _ = os.Setenv(gitPullMethodEnvKey, gitPullMethodHttps) + expectedValue = gitPullMethodHttps return }, }, @@ -51,7 +51,7 @@ func TestGetGitPullMethod(t *testing.T) { testName: "unknownEnv", setEnv: func() (expectedValue string) { _ = os.Setenv(gitPullMethodEnvKey, "unknown") - expectedValue = "https" + expectedValue = gitPullMethodHttps return }, },