diff --git a/pkg/sysregistriesv2/system_registries_v2.go b/pkg/sysregistriesv2/system_registries_v2.go index 4c1629f563..d0ddbf1914 100644 --- a/pkg/sysregistriesv2/system_registries_v2.go +++ b/pkg/sysregistriesv2/system_registries_v2.go @@ -357,21 +357,26 @@ func (config *V2RegistriesConf) postProcessRegistries() error { return err } - if reg.Prefix == "" { - if reg.Location == "" { - return &InvalidRegistries{s: "invalid condition: both location and prefix are unset"} - } - reg.Prefix = reg.Location - } else { + // Allow config authors to always use Prefix. + if reg.Prefix != "" { reg.Prefix, err = parseLocation(reg.Prefix) if err != nil { return err } - // FIXME: allow config authors to always use Prefix. - // https://github.com/containers/image/pull/1191#discussion_r610622495 - if reg.Prefix[:2] != "*." && reg.Location == "" { - return &InvalidRegistries{s: "invalid condition: location is unset and prefix is not in the format: *.example.com"} + if reg.Location != "" { + reg.Location, err = parseLocation(reg.Location) + if err != nil { + return err + } + } + } else if reg.Location != "" { + reg.Prefix, err = parseLocation(reg.Location) + if err != nil { + return err } + reg.Location = reg.Prefix + } else { + return &InvalidRegistries{s: "invalid condition: both location and prefix are unset"} } // make sure mirrors are valid