From 85c76c9851703e4e23acd09e46448591e131b055 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Mon, 22 Oct 2018 13:58:17 -0700 Subject: [PATCH] cmd/openshift-install: Push creation under 'openshift create' To mirror 'openshift-install destroy' and make it easier for folks using multiple invocations to see what their options are. I've deprecated all the old commands, and am looking forward to dropping them as soon as possible :). --- README.md | 6 ++--- .../{targets.go => create.go} | 25 +++++++++++++++++-- cmd/openshift-install/main.go | 10 ++++---- docs/design/assetgeneration.md | 4 +-- 4 files changed, 33 insertions(+), 12 deletions(-) rename cmd/openshift-install/{targets.go => create.go} (84%) diff --git a/README.md b/README.md index 4028d882a5..e61877e6bd 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ hack/build.sh This will create `bin/openshift-install`. This binary can then be invoked to create an OpenShift cluster, like so: ```sh -bin/openshift-install cluster +bin/openshift-install create cluster ``` The installer requires the terraform binary either alongside openshift-install or in `$PATH`. @@ -41,8 +41,8 @@ Log in using the admin credentials you configured when creating the cluster. #### Kubeconfig -You can also use the admin kubeconfig which `openshift-install cluster` placed under `--dir` (which defaults to `.`) in `auth/kubeconfig`. -If you launched the cluster with `openshift-install --dir "${DIR}" cluster`, you can use: +You can also use the admin kubeconfig which `openshift-install create cluster` placed under `--dir` (which defaults to `.`) in `auth/kubeconfig`. +If you launched the cluster with `openshift-install --dir "${DIR}" create cluster`, you can use: ```sh export KUBECONFIG="${DIR}/auth/kubeconfig" diff --git a/cmd/openshift-install/targets.go b/cmd/openshift-install/create.go similarity index 84% rename from cmd/openshift-install/targets.go rename to cmd/openshift-install/create.go index c2fe691660..fff6f27b73 100644 --- a/cmd/openshift-install/targets.go +++ b/cmd/openshift-install/create.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "os/exec" "strings" @@ -57,15 +58,35 @@ var targets = []target{{ assets: []asset.WritableAsset{&cluster.TerraformVariables{}, &kubeconfig.Admin{}, &cluster.Cluster{}}, }} +// Deprecated: Use 'create' subcommands instead. func newTargetsCmd() []*cobra.Command { var cmds []*cobra.Command for _, t := range targets { - t.command.RunE = runTargetCmd(t.assets...) - cmds = append(cmds, t.command) + cmd := *t.command + cmd.Short = fmt.Sprintf("DEPRECATED: USE 'create %s' instead.", cmd.Use) + cmd.RunE = runTargetCmd(t.assets...) + cmds = append(cmds, &cmd) } return cmds } +func newCreateCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "create", + Short: "Create part of an OpenShift cluster", + RunE: func(cmd *cobra.Command, args []string) error { + return cmd.Help() + }, + } + + for _, t := range targets { + t.command.RunE = runTargetCmd(t.assets...) + cmd.AddCommand(t.command) + } + + return cmd +} + func runTargetCmd(targets ...asset.WritableAsset) func(cmd *cobra.Command, args []string) error { return func(cmd *cobra.Command, args []string) error { assetStore, err := asset.NewStore(rootOpts.dir) diff --git a/cmd/openshift-install/main.go b/cmd/openshift-install/main.go index da43051da2..f3076202df 100644 --- a/cmd/openshift-install/main.go +++ b/cmd/openshift-install/main.go @@ -16,17 +16,17 @@ var ( func main() { rootCmd := newRootCmd() - var subCmds []*cobra.Command for _, cmd := range newTargetsCmd() { - subCmds = append(subCmds, cmd) + rootCmd.AddCommand(cmd) } - subCmds = append(subCmds, + + for _, subCmd := range []*cobra.Command{ + newCreateCmd(), newDestroyCmd(), newLegacyDestroyClusterCmd(), newVersionCmd(), newGraphCmd(), - ) - for _, subCmd := range subCmds { + } { rootCmd.AddCommand(subCmd) } diff --git a/docs/design/assetgeneration.md b/docs/design/assetgeneration.md index 098ad08569..aad6ce5934 100644 --- a/docs/design/assetgeneration.md +++ b/docs/design/assetgeneration.md @@ -72,10 +72,10 @@ After being loaded and consumed by a children asset, the existing on-disk asset E.g. ```shell -$ openshift-install install-config +$ openshift-install create install-config # Generate install-config.yml -$ openshift-install manifests +$ openshift-install create manifests # Generate manifests/ and tectonic/ dir, also remove install-config.yml ```