From ea7f204f0ff434fc23bff9d7da4e42b28e61197e Mon Sep 17 00:00:00 2001 From: Cesar Wong Date: Mon, 25 Jul 2016 15:04:04 -0400 Subject: [PATCH] Set default image version for 'oc cluster up' --- docs/cluster_up_down.md | 3 ++- docs/man/man1/oc-cluster-up.1 | 2 +- docs/man/man1/openshift-cli-cluster-up.1 | 2 +- pkg/bootstrap/docker/up.go | 11 ++++++++++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/docs/cluster_up_down.md b/docs/cluster_up_down.md index 3fde75a90e36..3d4c2ed25be7 100644 --- a/docs/cluster_up_down.md +++ b/docs/cluster_up_down.md @@ -208,7 +208,8 @@ To use a different suffix, specify it with `--routing-suffix`. ## Specifying Images to Use -By default `oc cluster up` uses `openshift/origin:latest` as its OpenShift image and `openshift-origin-${component}:latest` for +By default `oc cluster up` uses `openshift/origin:[released-version]` as its OpenShift image (where [released-version] +corresponds to the release of the `oc` client) and `openshift-origin-${component}:[released-version]` for other images created by the OpenShift cluster (registry, router, builders, etc). It is possible to use a different set of images by specifying the version and/or the image prefix. diff --git a/docs/man/man1/oc-cluster-up.1 b/docs/man/man1/oc-cluster-up.1 index 4f25ba695168..c7703bf3f187 100644 --- a/docs/man/man1/oc-cluster-up.1 +++ b/docs/man/man1/oc-cluster-up.1 @@ -94,7 +94,7 @@ A public hostname can also be specified for the server with the \-\-public\-host Use existing configuration if present .PP -\fB\-\-version\fP="latest" +\fB\-\-version\fP="" Specify the tag for OpenShift images diff --git a/docs/man/man1/openshift-cli-cluster-up.1 b/docs/man/man1/openshift-cli-cluster-up.1 index 0978409d12a5..24d591f1edff 100644 --- a/docs/man/man1/openshift-cli-cluster-up.1 +++ b/docs/man/man1/openshift-cli-cluster-up.1 @@ -94,7 +94,7 @@ A public hostname can also be specified for the server with the \-\-public\-host Use existing configuration if present .PP -\fB\-\-version\fP="latest" +\fB\-\-version\fP="" Specify the tag for OpenShift images diff --git a/pkg/bootstrap/docker/up.go b/pkg/bootstrap/docker/up.go index e29f673417f1..a80185f70fd4 100644 --- a/pkg/bootstrap/docker/up.go +++ b/pkg/bootstrap/docker/up.go @@ -28,6 +28,7 @@ import ( "github.com/openshift/origin/pkg/cmd/util/clientcmd" osclientcmd "github.com/openshift/origin/pkg/cmd/util/clientcmd" dockerutil "github.com/openshift/origin/pkg/cmd/util/docker" + "github.com/openshift/origin/pkg/cmd/util/variable" ) const ( @@ -121,7 +122,7 @@ func NewCmdUp(name, fullName string, f *osclientcmd.Factory, out io.Writer) *cob } cmd.Flags().BoolVar(&config.ShouldCreateDockerMachine, "create-machine", false, "Create a Docker machine if one doesn't exist") cmd.Flags().StringVar(&config.DockerMachine, "docker-machine", "", "Specify the Docker machine to use") - cmd.Flags().StringVar(&config.ImageVersion, "version", "latest", "Specify the tag for OpenShift images") + cmd.Flags().StringVar(&config.ImageVersion, "version", "", "Specify the tag for OpenShift images") cmd.Flags().StringVar(&config.Image, "image", "openshift/origin", "Specify the images to use for OpenShift") cmd.Flags().BoolVar(&config.SkipRegistryCheck, "skip-registry-check", false, "Skip Docker daemon registry check") cmd.Flags().StringVar(&config.PublicHostname, "public-hostname", "", "Public hostname for OpenShift cluster") @@ -199,6 +200,10 @@ func (c *ClientStartConfig) Complete(f *osclientcmd.Factory, cmd *cobra.Command) c.originalFactory = f c.command = cmd + if len(c.ImageVersion) == 0 { + c.ImageVersion = defaultImageVersion() + } + c.addTask("Checking OpenShift client", c.CheckOpenShiftClient) if c.ShouldCreateDockerMachine { @@ -308,6 +313,10 @@ func defaultPortForwarding() bool { const defaultDockerMachineName = "openshift" +func defaultImageVersion() string { + return variable.OverrideVersion.LastSemanticVersion() +} + // CreateDockerMachine will create a new Docker machine to run OpenShift func (c *ClientStartConfig) CreateDockerMachine(out io.Writer) error { if len(c.DockerMachine) == 0 {