From 66268690b364ac0d7e64d641e84f2afd8d95c402 Mon Sep 17 00:00:00 2001 From: Sam Stoelinga Date: Mon, 16 Mar 2020 19:00:23 -0700 Subject: [PATCH] Add comments --- pkg/executor/push.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/executor/push.go b/pkg/executor/push.go index 6128ac7df5..0ff7930fd0 100644 --- a/pkg/executor/push.go +++ b/pkg/executor/push.go @@ -115,14 +115,19 @@ func CheckPushPermissions(opts *config.KanikoOptions) error { if checked[destRef.Context().RepositoryStr()] { continue } + + // Historically kaniko was pre-configured by default with gcr credential helper, + // in here we keep the backwards compatibility by enabling the GCR helper only + // when gcr.io is in one of the destinations. if strings.Contains(destRef.RegistryStr(), "gcr.io") { + // Checking for existence of docker.config as it's normally required for + // authenticated registries and prevent overwriting user provided docker conf if _, err := os.Stat("/kaniko/.docker/config.json"); os.IsNotExist(err) { cmd := exec.Command("docker-credential-gcr", "configure-docker") if err := cmd.Run(); err != nil { return errors.Wrap(err, "error while configuring docker-credential-gcr helper") } } - } registryName := destRef.Repository.Registry.Name() if opts.Insecure || opts.InsecureRegistries.Contains(registryName) {