diff --git a/README.md b/README.md index 86cd5b9f7..db8408c3b 100644 --- a/README.md +++ b/README.md @@ -897,7 +897,7 @@ Force building outside of a container #### Flag `--git` Branch to clone if build context is a git repository (default -branch=,single-branch=false,recurse-submodules=false) +branch=,single-branch=false,recurse-submodules=false,insecure-skip-tls=false) #### Flag `--image-name-with-digest-file` diff --git a/cmd/executor/cmd/root.go b/cmd/executor/cmd/root.go index 4460c94a9..a3e392e75 100644 --- a/cmd/executor/cmd/root.go +++ b/cmd/executor/cmd/root.go @@ -424,6 +424,7 @@ func resolveSourceContext() error { GitBranch: opts.Git.Branch, GitSingleBranch: opts.Git.SingleBranch, GitRecurseSubmodules: opts.Git.RecurseSubmodules, + InsecureSkipTLS: opts.Git.InsecureSkipTLS, }) if err != nil { return err diff --git a/pkg/buildcontext/buildcontext.go b/pkg/buildcontext/buildcontext.go index 3e637e578..47722479e 100644 --- a/pkg/buildcontext/buildcontext.go +++ b/pkg/buildcontext/buildcontext.go @@ -32,6 +32,7 @@ type BuildOptions struct { GitBranch string GitSingleBranch bool GitRecurseSubmodules bool + InsecureSkipTLS bool } // BuildContext unifies calls to download and unpack the build context. diff --git a/pkg/buildcontext/git.go b/pkg/buildcontext/git.go index 0d44e55e1..f6bb3857e 100644 --- a/pkg/buildcontext/git.go +++ b/pkg/buildcontext/git.go @@ -65,6 +65,7 @@ func (g *Git) UnpackTarFromBuildContext() (string, error) { Progress: os.Stdout, SingleBranch: g.opts.GitSingleBranch, RecurseSubmodules: getRecurseSubmodules(g.opts.GitRecurseSubmodules), + InsecureSkipTLS: g.opts.InsecureSkipTLS, } var fetchRef string var checkoutRef string diff --git a/pkg/config/options.go b/pkg/config/options.go index 2ec4afc43..8f777f05f 100644 --- a/pkg/config/options.go +++ b/pkg/config/options.go @@ -96,6 +96,7 @@ type KanikoGitOptions struct { Branch string SingleBranch bool RecurseSubmodules bool + InsecureSkipTLS bool } var ErrInvalidGitFlag = errors.New("invalid git flag, must be in the key=value format") @@ -128,6 +129,12 @@ func (k *KanikoGitOptions) Set(s string) error { return err } k.RecurseSubmodules = v + case "insecure-skip-tls": + v, err := strconv.ParseBool(parts[1]) + if err != nil { + return err + } + k.InsecureSkipTLS = v } return nil } diff --git a/pkg/config/options_test.go b/pkg/config/options_test.go index f268c9303..f2742b9d6 100644 --- a/pkg/config/options_test.go +++ b/pkg/config/options_test.go @@ -33,10 +33,12 @@ func TestKanikoGitOptions(t *testing.T) { testutil.CheckNoError(t, g.Set("branch=foo")) testutil.CheckNoError(t, g.Set("recurse-submodules=true")) testutil.CheckNoError(t, g.Set("single-branch=true")) + testutil.CheckNoError(t, g.Set("insecure-skip-tls=false")) testutil.CheckDeepEqual(t, KanikoGitOptions{ Branch: "foo", SingleBranch: true, RecurseSubmodules: true, + InsecureSkipTLS: false, }, *g) })