image: fix registry mirror setup

Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
This commit is contained in:
Yoan Blanc
2020-02-16 11:41:51 +01:00
parent edc4eb33f4
commit 474fdcf68d
4 changed files with 12 additions and 7 deletions
+2 -2
View File
@@ -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
+6 -1
View File
@@ -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