Skip to content

Commit

Permalink
hack: pin the release image in build flags
Browse files Browse the repository at this point in the history
But still leave an override env var so that it can be overridden. Use the following env var to pin the image while building the binary:
```
$ # export the release-image variable
$ export OPENSHIFT_INSTALL_RELEASE_IMAGE=registry.redhat.io/openshift/origin-release:v4.0"
$ # build the openshift-install binary
$ ./hack/build.sh
$ # distribute the binary to customers and run with pinned image being picked up
$ ./bin/openshift-install create cluster...
```
The only way to override it would be to use an env var OPENSHIFT_INSTALL_RELEASE_IMAGE_OVERRIDE while running the openshift-install binary.
  • Loading branch information
Rajat Chopra committed Nov 27, 2018
1 parent e15d801 commit 18b1d9b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions hack/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ fi
MODE="${MODE:-release}"
LDFLAGS="${LDFLAGS} -X main.version=$(git describe --always --abbrev=40 --dirty)"
TAGS="${TAGS:-}"
OPENSHIFT_INSTALL_RELEASE_IMAGE="${OPENSHIFT_INSTALL_RELEASE_IMAGE:-}"
OUTPUT="${OUTPUT:-bin/openshift-install}"
export CGO_ENABLED=0

case "${MODE}" in
release)
TAGS="${TAGS} release"
LDFLAGS="${LDFLAGS} -X github.com/openshift/installer/pkg/asset/ignition/bootstrap.PinnedReleaseImage=${OPENSHIFT_INSTALL_RELEASE_IMAGE}"
if test "${SKIP_GENERATION}" != y
then
go generate ./data
Expand Down
9 changes: 8 additions & 1 deletion pkg/asset/ignition/bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@ import (

const (
rootDir = "/opt/tectonic"
defaultReleaseImage = "registry.svc.ci.openshift.org/openshift/origin-release:v4.0"
defaultReleaseImage = "registry.svc.ci.openshift.org/openshift/origin-release:latest"
bootstrapIgnFilename = "bootstrap.ign"
)

var (
PinnedReleaseImage = ""
)

// bootstrapTemplateData is the data to use to replace values in bootstrap
// template files.
type bootstrapTemplateData struct {
Expand Down Expand Up @@ -141,6 +145,9 @@ func (a *Bootstrap) getTemplateData(installConfig *types.InstallConfig, adminKub
}

releaseImage := defaultReleaseImage
if len(PinnedReleaseImage) > 0 {
releaseImage = PinnedReleaseImage
}
if ri, ok := os.LookupEnv("OPENSHIFT_INSTALL_RELEASE_IMAGE_OVERRIDE"); ok && ri != "" {
logrus.Warn("Found override for ReleaseImage. Please be warned, this is not advised")
releaseImage = ri
Expand Down

0 comments on commit 18b1d9b

Please sign in to comment.