Skip to content

Commit

Permalink
hack: pin the os release base url, channel and build name
Browse files Browse the repository at this point in the history
Three environment variables to be used when building the pinned release binary:
    RHCOS_BASE_URL: points to the base url from where to pick the image from. Defaults to "https://releases-rhcos.svc.ci.openshift.org/storage/releases".
    RHCOS_DEFAULT_CHANNEL: points to the channel where the image is available. Defaults to "maipo"
    RHCOS_BUILD_NAME: a string representing the build name. If empty, then the latest one will be picked up.
  • Loading branch information
Rajat Chopra committed Nov 29, 2018
1 parent e87f0d5 commit 6521f80
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
12 changes: 12 additions & 0 deletions hack/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ release)
then
LDFLAGS="${LDFLAGS} -X github.com/openshift/installer/pkg/asset/ignition/bootstrap.defaultReleaseImage=${RELEASE_IMAGE}"
fi
if test -n "${RHCOS_DEFAULT_CHANNEL}"
then
LDFLAGS="${LDFLAGS} -X github.com/openshift/installer/pkg/rhcos.DefaultChannel=${RHCOS_DEFAULT_CHANNEL}"
fi
if test -n "${RHCOS_BASE_URL}"
then
LDFLAGS="${LDFLAGS} -X github.com/openshift/installer/pkg/rhcos.baseURL=${RHCOS_BASE_URL}"
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
Expand Down
15 changes: 14 additions & 1 deletion pkg/rhcos/builds.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -104,5 +108,14 @@ func fetchLatestBuild(ctx context.Context, channel string) (string, error) {
return "", errors.Errorf("no builds found")
}

if buildName != "" {
for _, build := range builds.Builds {
if build == buildName {
return buildName, nil
}
}
return "", errors.Errorf("no build with name '%s' found at '%s'. Available builds are: %v", buildName, url, builds.Builds)
}

return builds.Builds[0], nil
}

0 comments on commit 6521f80

Please sign in to comment.