mirror of
https://github.com/GoogleContainerTools/kaniko
synced 2026-10-09 06:25:44 +02:00
image: fix registry mirror setup
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
This commit is contained in:
@@ -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