Skip to content

Commit

Permalink
[WIP] AGENT: Fix releaseImageMirror formatting
Browse files Browse the repository at this point in the history
When the image is of the form:

    quay.io/openshift-release-dev/ocp-release@sha256:300bce8246cf880e792e106607925de0a404484637627edf5f517375517d54a4

Splitting by ':' means that the extracted location will be:

    quay.io/openshift-release-dev/ocp-release@sha256:

Instead of

    quay.io/openshift-release-dev/ocp-release

Whereas in registries.conf we'd have the location be:

    [[registry]]
      location = "quay.io/openshift-release-dev/ocp-release"

Thus. There wouldn't be a match and the release image will be empty in
places like:

    /usr/local/share/assisted-service/assisted-service.env

or

    /etc/systemd/system/create-cluster-and-infraenv.service

Signed-off-by: Antoni Segura Puimedon <antoni@redhat.com>
  • Loading branch information
celebdor committed Aug 27, 2022
1 parent ddf29b4 commit 863cd1e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/asset/agent/image/ignition.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net/url"
"path"
"path/filepath"
"regexp"
"strings"

"github.com/coreos/ignition/v2/config/util"
Expand Down Expand Up @@ -141,11 +142,16 @@ func (a *Ignition) Generate(dependencies asset.Parents) error {

// Get the mirror for release image
releaseImageMirror := ""
source := strings.Split(agentManifests.ClusterImageSet.Spec.ReleaseImage, ":")
source := regexp.MustCompile(`^(.+?)(@sha256)?:(.+)`).FindStringSubmatch(agentManifests.ClusterImageSet.Spec.ReleaseImage)
for _, config := range registriesConfig.MirrorConfig {
if config.Location == source[0] {
if config.Location == source[1] {
// include the tag with the build release image
releaseImageMirror = fmt.Sprintf("%s:%s", config.Mirror, source[1])
if len(source) == 4 {
// Has Sha256
releaseImageMirror = fmt.Sprintf("%s%s:%s\n", config.Mirror, source[2], source[3])
} else if len(source) == 3 {
releaseImageMirror = fmt.Sprintf("%s:%s\n", config.Mirror, source[2])
}
}
}

Expand Down

0 comments on commit 863cd1e

Please sign in to comment.