diff --git a/hack/build.sh b/hack/build.sh index 587932971e2..7cfa7b46806 100755 --- a/hack/build.sh +++ b/hack/build.sh @@ -39,6 +39,14 @@ export CGO_ENABLED=0 case "${MODE}" in release) TAGS="${TAGS} release" + if test -n "${RELEASE_IMAGE}" + then + LDFLAGS="${LDFLAGS} -X github.com/openshift/installer/pkg/asset/ignition/bootstrap.defaultReleaseImage=${RELEASE_IMAGE}" + fi + if test -n "${RHCOS_BUILD_NAME}" + then + LDFLAGS="${LDFLAGS} -X github.com/openshift/installer/pkg/rhcos.buildName=${RHCOS_BUILD_NAME}" + fi if test "${SKIP_GENERATION}" != y then go generate ./data diff --git a/pkg/asset/ignition/bootstrap/bootstrap.go b/pkg/asset/ignition/bootstrap/bootstrap.go index 977eff061af..36312862ac1 100644 --- a/pkg/asset/ignition/bootstrap/bootstrap.go +++ b/pkg/asset/ignition/bootstrap/bootstrap.go @@ -29,13 +29,16 @@ import ( const ( rootDir = "/opt/openshift" - defaultReleaseImage = "registry.svc.ci.openshift.org/openshift/origin-release:v4.0" bootstrapIgnFilename = "bootstrap.ign" etcdCertSignerImage = "quay.io/coreos/kube-etcd-signer-server:678cc8e6841e2121ebfdb6e2db568fce290b67d6" etcdctlImage = "quay.io/coreos/etcd:v3.2.14" ignitionUser = "core" ) +var ( + defaultReleaseImage = "registry.svc.ci.openshift.org/openshift/origin-release:v4.0" +) + // bootstrapTemplateData is the data to use to replace values in bootstrap // template files. type bootstrapTemplateData struct { diff --git a/pkg/rhcos/builds.go b/pkg/rhcos/builds.go index a1a76158d9c..015b50ef615 100644 --- a/pkg/rhcos/builds.go +++ b/pkg/rhcos/builds.go @@ -11,10 +11,14 @@ import ( "github.com/sirupsen/logrus" ) -const ( +var ( // DefaultChannel is the default RHCOS channel for the cluster. DefaultChannel = "maipo" + // buildName is the name of the build in the channel that will be picked up + // empty string means the first one in the build list (latest) will be used + buildName = "" + baseURL = "https://releases-rhcos.svc.ci.openshift.org/storage/releases" ) @@ -33,9 +37,13 @@ type metadata struct { } func fetchLatestMetadata(ctx context.Context, channel string) (metadata, error) { - build, err := fetchLatestBuild(ctx, channel) - if err != nil { - return metadata{}, errors.Wrap(err, "failed to fetch latest build") + build := buildName + var err error + if build == "" { + build, err = fetchLatestBuild(ctx, channel) + if err != nil { + return metadata{}, errors.Wrap(err, "failed to fetch latest build") + } } url := fmt.Sprintf("%s/%s/%s/meta.json", baseURL, channel, build) @@ -48,7 +56,7 @@ func fetchLatestMetadata(ctx context.Context, channel string) (metadata, error) client := &http.Client{} resp, err := client.Do(req.WithContext(ctx)) if err != nil { - return metadata{}, errors.Wrap(err, "failed to fetch metadata") + return metadata{}, errors.Wrapf(err, "failed to fetch metadata for build %s", build) } defer resp.Body.Close()