Skip to content

Commit 85c76c9

Browse files
committed
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 :).
1 parent e1a71ff commit 85c76c9

File tree

4 files changed

+33
-12
lines changed

4 files changed

+33
-12
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ hack/build.sh
1919
This will create `bin/openshift-install`. This binary can then be invoked to create an OpenShift cluster, like so:
2020

2121
```sh
22-
bin/openshift-install cluster
22+
bin/openshift-install create cluster
2323
```
2424

2525
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.
4141

4242
#### Kubeconfig
4343

44-
You can also use the admin kubeconfig which `openshift-install cluster` placed under `--dir` (which defaults to `.`) in `auth/kubeconfig`.
45-
If you launched the cluster with `openshift-install --dir "${DIR}" cluster`, you can use:
44+
You can also use the admin kubeconfig which `openshift-install create cluster` placed under `--dir` (which defaults to `.`) in `auth/kubeconfig`.
45+
If you launched the cluster with `openshift-install --dir "${DIR}" create cluster`, you can use:
4646

4747
```sh
4848
export KUBECONFIG="${DIR}/auth/kubeconfig"

cmd/openshift-install/targets.go renamed to cmd/openshift-install/create.go

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"fmt"
45
"os/exec"
56
"strings"
67

@@ -57,15 +58,35 @@ var targets = []target{{
5758
assets: []asset.WritableAsset{&cluster.TerraformVariables{}, &kubeconfig.Admin{}, &cluster.Cluster{}},
5859
}}
5960

61+
// Deprecated: Use 'create' subcommands instead.
6062
func newTargetsCmd() []*cobra.Command {
6163
var cmds []*cobra.Command
6264
for _, t := range targets {
63-
t.command.RunE = runTargetCmd(t.assets...)
64-
cmds = append(cmds, t.command)
65+
cmd := *t.command
66+
cmd.Short = fmt.Sprintf("DEPRECATED: USE 'create %s' instead.", cmd.Use)
67+
cmd.RunE = runTargetCmd(t.assets...)
68+
cmds = append(cmds, &cmd)
6569
}
6670
return cmds
6771
}
6872

73+
func newCreateCmd() *cobra.Command {
74+
cmd := &cobra.Command{
75+
Use: "create",
76+
Short: "Create part of an OpenShift cluster",
77+
RunE: func(cmd *cobra.Command, args []string) error {
78+
return cmd.Help()
79+
},
80+
}
81+
82+
for _, t := range targets {
83+
t.command.RunE = runTargetCmd(t.assets...)
84+
cmd.AddCommand(t.command)
85+
}
86+
87+
return cmd
88+
}
89+
6990
func runTargetCmd(targets ...asset.WritableAsset) func(cmd *cobra.Command, args []string) error {
7091
return func(cmd *cobra.Command, args []string) error {
7192
assetStore, err := asset.NewStore(rootOpts.dir)

cmd/openshift-install/main.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ var (
1616
func main() {
1717
rootCmd := newRootCmd()
1818

19-
var subCmds []*cobra.Command
2019
for _, cmd := range newTargetsCmd() {
21-
subCmds = append(subCmds, cmd)
20+
rootCmd.AddCommand(cmd)
2221
}
23-
subCmds = append(subCmds,
22+
23+
for _, subCmd := range []*cobra.Command{
24+
newCreateCmd(),
2425
newDestroyCmd(),
2526
newLegacyDestroyClusterCmd(),
2627
newVersionCmd(),
2728
newGraphCmd(),
28-
)
29-
for _, subCmd := range subCmds {
29+
} {
3030
rootCmd.AddCommand(subCmd)
3131
}
3232

docs/design/assetgeneration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ After being loaded and consumed by a children asset, the existing on-disk asset
7272
E.g.
7373

7474
```shell
75-
$ openshift-install install-config
75+
$ openshift-install create install-config
7676
# Generate install-config.yml
7777

78-
$ openshift-install manifests
78+
$ openshift-install create manifests
7979
# Generate manifests/ and tectonic/ dir, also remove install-config.yml
8080
```
8181

0 commit comments

Comments
 (0)