mirror of
https://github.com/GoogleContainerTools/kaniko
synced 2026-10-01 01:18:57 +02:00
image: fix registry mirror setup
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
This commit is contained in:
@@ -15,6 +15,6 @@
|
||||
# Test to make sure the executor builds an image correctly
|
||||
# when no files are changed
|
||||
|
||||
FROM google-appengine/debian9@sha256:1d6a9a6d106bd795098f60f4abb7083626354fa6735e81743c7f8cfca11259f0
|
||||
RUN echo "hey"
|
||||
FROM library/debian:latest
|
||||
RUN echo "hey"
|
||||
MAINTAINER kaniko
|
||||
|
||||
@@ -229,7 +229,7 @@ func getGitRepo() string {
|
||||
} else {
|
||||
branch = os.Getenv("TRAVIS_BRANCH")
|
||||
repoSlug = os.Getenv("TRAVIS_REPO_SLUG")
|
||||
log.Printf("Travis CI pepo: %s branch: %s\n", repoSlug, branch)
|
||||
log.Printf("Travis CI repo: %s branch: %s\n", repoSlug, branch)
|
||||
}
|
||||
return "github.com/" + repoSlug + "#refs/heads/" + branch
|
||||
}
|
||||
@@ -303,7 +303,7 @@ func TestBuildViaRegistryMirror(t *testing.T) {
|
||||
dockerRunFlags = append(dockerRunFlags, ExecutorImage,
|
||||
"-f", dockerfile,
|
||||
"-d", kanikoImage,
|
||||
"--registry-mirror", "gcr.io",
|
||||
"--registry-mirror", "us-mirror.gcr.io",
|
||||
"-c", fmt.Sprintf("git://%s", repo))
|
||||
|
||||
kanikoCmd := exec.Command("docker", dockerRunFlags...)
|
||||
|
||||
@@ -40,10 +40,10 @@ type KanikoOptions struct {
|
||||
ImageNameDigestFile string
|
||||
OCILayoutPath string
|
||||
RegistryMirror string
|
||||
InsecureRegistries multiArg
|
||||
SkipTLSVerifyRegistries multiArg
|
||||
Destinations multiArg
|
||||
BuildArgs multiArg
|
||||
InsecureRegistries multiArg
|
||||
SkipTLSVerifyRegistries multiArg
|
||||
Insecure bool
|
||||
SkipTLSVerify bool
|
||||
InsecurePull bool
|
||||
|
||||
@@ -108,6 +108,7 @@ func remoteImage(image string, opts *config.KanikoOptions) (v1.Image, error) {
|
||||
|
||||
registryName := ref.Context().RegistryStr()
|
||||
var newReg name.Registry
|
||||
toSet := false
|
||||
|
||||
if opts.RegistryMirror != "" && registryName == name.DefaultRegistry {
|
||||
registryName = opts.RegistryMirror
|
||||
@@ -116,6 +117,8 @@ func remoteImage(image string, opts *config.KanikoOptions) (v1.Image, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
toSet = true
|
||||
}
|
||||
|
||||
if opts.InsecurePull || opts.InsecureRegistries.Contains(registryName) {
|
||||
@@ -123,9 +126,11 @@ func remoteImage(image string, opts *config.KanikoOptions) (v1.Image, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
toSet = true
|
||||
}
|
||||
|
||||
if newReg != ref.Context().Registry {
|
||||
if toSet {
|
||||
if tag, ok := ref.(name.Tag); ok {
|
||||
tag.Repository.Registry = newReg
|
||||
ref = tag
|
||||
|
||||
Reference in New Issue
Block a user