Skip to content

Commit

Permalink
fix: generate config with only globalImageRegistryMirror set"
Browse files Browse the repository at this point in the history
  • Loading branch information
dkoshkin committed Feb 14, 2024
1 parent 17fa13f commit 3e43d0d
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions pkg/handlers/generic/mutation/imageregistries/credentials/inject.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,26 @@ func (h *imageRegistriesPatchHandler) Mutate(
"holderRef", holderRef,
)

imageRegistries, found, err := variables.Get[v1alpha1.ImageRegistries](
imageRegistries, imageRegistriesFound, err := variables.Get[v1alpha1.ImageRegistries](
vars,
h.variableName,
h.variableFieldPath...,
)
if err != nil {
return err
}
if !found {

// add credentials for global image registry mirror
globalMirror, globalMirrorFound, err := variables.Get[v1alpha1.GlobalImageRegistryMirror](
vars,
h.variableName,
mirrors.GlobalMirrorVariableName,
)
if err != nil {
return err
}

if !imageRegistriesFound && !globalMirrorFound {
log.V(5).Info("Image Registry Credentials variable not defined")
return nil
}
Expand All @@ -100,16 +111,8 @@ func (h *imageRegistriesPatchHandler) Mutate(
registryWithOptionalCredentials,
)
}
// add credentials for global image registry mirror
globalMirror, found, err := variables.Get[v1alpha1.GlobalImageRegistryMirror](
vars,
h.variableName,
mirrors.GlobalMirrorVariableName,
)
if err != nil {
return err
}
if found {

if globalMirrorFound {
mirrorCredentials, generateErr := mirrorConfigFromGlobalImageRegistryMirror(
ctx,
h.client,
Expand Down

0 comments on commit 3e43d0d

Please sign in to comment.