mirror of
https://github.com/GoogleContainerTools/kaniko
synced 2026-10-19 13:41:08 +02:00
Add ability to use public GCR image
Kaniko by default used to configure the GCR credential helper however this caused Kaniko to fail when trying to use a base image from a public GCR image. This patch makes it possible to use public GCR images as base image when using docker even when you're not authenticated to GCR. Co-authored-by: Nate Williams <nate.williams@files.com>
This commit is contained in:
co-authored by
Nate Williams
parent
0cfc5c635a
commit
8a020010b7
@@ -24,6 +24,7 @@ import (
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -114,7 +115,15 @@ func CheckPushPermissions(opts *config.KanikoOptions) error {
|
||||
if checked[destRef.Context().RepositoryStr()] {
|
||||
continue
|
||||
}
|
||||
if strings.Contains(destRef.RegistryStr(), "gcr.io") {
|
||||
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) {
|
||||
newReg, err := name.NewRegistry(registryName, name.WeakValidation, name.Insecure)
|
||||
|
||||
Reference in New Issue
Block a user