Skip to content

Commit

Permalink
MGMT-19708: Ignore mirrored registries when validating pull secrets
Browse files Browse the repository at this point in the history
When a mirror registry configuration is provided to assisted, we
will assume that the registry does not require authentication.
This is a better user experience so that the user will not have
to provide credentials for a registry if a mirror registry will
be used in its place.
  • Loading branch information
CrystalChun committed Jan 17, 2025
1 parent d966ae9 commit 4b05fd7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,15 @@ func main() {

publicRegistries := map[string]bool{}
validations.ParsePublicRegistries(publicRegistries, Options.ValidationsConfig.PublicRegistries)
if mirrorRegistriesBuilder.IsMirrorRegistriesConfigured() {
mirrorRegistries, err := mirrorRegistriesBuilder.ExtractLocationMirrorDataFromRegistries()
if err != nil {
log.WithError(err).Warnf("failed to parse mirror registries provided to assisted-service, check your mirror registry config map")
} else {
validations.ParseMirrorRegistries(publicRegistries, mirrorRegistries)
}
}

pullSecretValidator, err := validations.NewPullSecretValidator(
publicRegistries,
authHandler,
Expand Down
11 changes: 11 additions & 0 deletions internal/cluster/validations/pull_secret_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strings"

"github.com/openshift/assisted-service/pkg/auth"
"github.com/openshift/assisted-service/pkg/mirrorregistries"
"github.com/openshift/assisted-service/pkg/ocm"
"github.com/pkg/errors"
)
Expand Down Expand Up @@ -35,6 +36,16 @@ func ParsePublicRegistries(publicRegistries map[string]bool, publicRegistriesLit
}
}

func ParseMirrorRegistries(publicRegistries map[string]bool, mirrorRegistries []mirrorregistries.RegistriesConf) {
for _, mirrorRegistry := range mirrorRegistries {
registry, err := ParseRegistry(mirrorRegistry.Location)
if err != nil {
continue
}
publicRegistries[registry] = true
}
}

type registryPullSecretValidator struct {
publicRegistries map[string]bool
registriesWithAuth map[string]bool
Expand Down

0 comments on commit 4b05fd7

Please sign in to comment.