Skip to content

Commit

Permalink
Read installer image digests from an environment variable
Browse files Browse the repository at this point in the history
INSTALLER_IMAGE_DIGESTS should be a JSON-formatted mapping of
"MAJOR.MINOR" OpenShift versions to an aro-installer image digest.
  • Loading branch information
mbarnes committed Jul 6, 2023
1 parent d82d4f5 commit a3dd54f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
27 changes: 24 additions & 3 deletions cmd/aro/update_ocp_versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ package main

import (
"context"
"encoding/base64"
"encoding/json"
"fmt"
"os"

Expand All @@ -30,19 +32,38 @@ func getLatestOCPVersions(ctx context.Context, log *logrus.Entry) ([]api.OpenShi
dstRepo := dstAcr + acrDomainSuffix
ocpVersions := []api.OpenShiftVersion{}

// INSTALLER_IMAGE_DIGESTS is the mapping of a minor version to
// the aro-installer wrapper digest. This allows us to utilize
// Azure Safe Deployment Practices (SDP) instead of pushing the
// version tag and deploying to all regions at once.
var installerImageDigests map[string]string
jsonData := []byte(os.Getenv("INSTALLER_IMAGE_DIGESTS"))

// For Azure DevOps pipelines, the JSON data is Base64-encoded
// since it's embedded in JSON-formatted build artifacts. But
// let's not force that on local development mode.
if !env.IsLocalDevelopmentMode() {
jsonData, err = base64.StdEncoding.DecodeString(string(jsonData))
if err != nil {
return nil, fmt.Errorf("INSTALLER_IMAGE_DIGESTS: Failed to decode base64: %v", err)
}
}
if err = json.Unmarshal(jsonData, &installerImageDigests); err != nil {
return nil, fmt.Errorf("INSTALLER_IMAGE_DIGESTS: Failed to parse JSON: %v", err)
}

for _, vers := range version.HiveInstallStreams {
installerPullSpec := fmt.Sprintf("%s/aro-installer:%s", dstRepo, vers.Version.MinorVersion())
digest, ok := version.InstallerImageDigest[vers.Version.MinorVersion()]
digest, ok := installerImageDigests[vers.Version.MinorVersion()]
if !ok {
return nil, fmt.Errorf("no digest found for version %s", vers.Version.String())
}

installerPullSpec = fmt.Sprintf("%s@sha256:%s", installerPullSpec, digest)
ocpVersions = append(ocpVersions, api.OpenShiftVersion{
Properties: api.OpenShiftVersionProperties{
Version: vers.Version.String(),
OpenShiftPullspec: vers.PullSpec,
InstallerPullspec: installerPullSpec,
InstallerPullspec: installerPullSpec + "@" + digest,
Enabled: true,
},
})
Expand Down
8 changes: 0 additions & 8 deletions pkg/util/version/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@ const (

var GitCommit = "unknown"

// InstallerImageDigest is the mapping of a minor version to the aro-installer wrapper digest
// this allows us to utilize SDP instead of pushing up the tag and it rolling out to all regions
// at once
var InstallerImageDigest = map[string]string{
NewVersion(4, 10).MinorVersion(): "eef5f0d82ab07c866999f99a632edafd845e0dc48a0f06eac9df46b0ab882231",
NewVersion(4, 11).MinorVersion(): "82869dd10841046c4b98fc46c6f87030c82b320b82f990610c1fa87150004730",
}

// DefaultInstallStream describes stream we are defaulting to for all new clusters
var DefaultInstallStream = &Stream{
Version: NewVersion(4, 10, 54),
Expand Down

0 comments on commit a3dd54f

Please sign in to comment.