Skip to content

Commit 0aad8a0

Browse files
authored
Add cluster name/region flags to the CLI (#1492)
1 parent 794734f commit 0aad8a0

File tree

4 files changed

+46
-10
lines changed

4 files changed

+46
-10
lines changed

cli/cmd/cluster.go

+16
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ import (
5252
var (
5353
_flagClusterEnv string
5454
_flagClusterConfig string
55+
_flagClusterName string
56+
_flagClusterRegion string
5557
_flagClusterInfoDebug bool
5658
_flagClusterDisallowPrompt bool
5759
_flagAWSAccessKeyID string
@@ -73,6 +75,8 @@ func clusterInit() {
7375

7476
_infoCmd.Flags().SortFlags = false
7577
addClusterConfigFlag(_infoCmd)
78+
addClusterNameFlag(_infoCmd)
79+
addClusterRegionFlag(_infoCmd)
7680
addAWSCredentialsFlags(_infoCmd)
7781
_infoCmd.Flags().StringVarP(&_flagClusterEnv, "env", "e", defaultEnv, "environment to update")
7882
_infoCmd.Flags().BoolVarP(&_flagClusterInfoDebug, "debug", "d", false, "save the current cluster state to a file")
@@ -89,12 +93,16 @@ func clusterInit() {
8993

9094
_downCmd.Flags().SortFlags = false
9195
addClusterConfigFlag(_downCmd)
96+
addClusterNameFlag(_downCmd)
97+
addClusterRegionFlag(_downCmd)
9298
addAWSCredentialsFlags(_downCmd)
9399
_downCmd.Flags().BoolVarP(&_flagClusterDisallowPrompt, "yes", "y", false, "skip prompts")
94100
_clusterCmd.AddCommand(_downCmd)
95101

96102
_exportCmd.Flags().SortFlags = false
97103
addClusterConfigFlag(_exportCmd)
104+
addClusterNameFlag(_exportCmd)
105+
addClusterRegionFlag(_exportCmd)
98106
addAWSCredentialsFlags(_exportCmd)
99107
_clusterCmd.AddCommand(_exportCmd)
100108
}
@@ -104,6 +112,14 @@ func addClusterConfigFlag(cmd *cobra.Command) {
104112
cmd.Flags().SetAnnotation("config", cobra.BashCompFilenameExt, _configFileExts)
105113
}
106114

115+
func addClusterNameFlag(cmd *cobra.Command) {
116+
cmd.Flags().StringVarP(&_flagClusterName, "name", "n", "", "aws name of the cluster")
117+
}
118+
119+
func addClusterRegionFlag(cmd *cobra.Command) {
120+
cmd.Flags().StringVarP(&_flagClusterRegion, "region", "r", "", "aws region of the cluster")
121+
}
122+
107123
func addAWSCredentialsFlags(cmd *cobra.Command) {
108124
cmd.Flags().StringVar(&_flagAWSAccessKeyID, "aws-key", "", "aws access key id")
109125
cmd.Flags().StringVar(&_flagAWSSecretAccessKey, "aws-secret", "", "aws secret access key")

cli/cmd/lib_cluster_config.go

+14
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@ func getNewClusterAccessConfig(disallowPrompt bool) (*clusterconfig.AccessConfig
8989
}
9090
}
9191

92+
if _flagClusterName != "" {
93+
accessConfig.ClusterName = pointer.String(_flagClusterName)
94+
}
95+
if _flagClusterRegion != "" {
96+
accessConfig.Region = pointer.String(_flagClusterRegion)
97+
}
98+
9299
if accessConfig.ClusterName != nil && accessConfig.Region != nil {
93100
return accessConfig, nil
94101
}
@@ -118,6 +125,13 @@ func getClusterAccessConfigWithCache(disallowPrompt bool) (*clusterconfig.Access
118125
}
119126
}
120127

128+
if _flagClusterName != "" {
129+
accessConfig.ClusterName = pointer.String(_flagClusterName)
130+
}
131+
if _flagClusterRegion != "" {
132+
accessConfig.Region = pointer.String(_flagClusterRegion)
133+
}
134+
121135
if accessConfig.ClusterName != nil && accessConfig.Region != nil {
122136
return accessConfig, nil
123137
}

dev/generate_cli_md.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ commands=(
3737
"cluster up"
3838
"cluster info"
3939
"cluster configure"
40-
"cluster export"
4140
"cluster down"
41+
"cluster export"
4242
"env configure"
4343
"env list"
4444
"env default"

docs/miscellaneous/cli.md

+15-9
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ Usage:
143143
144144
Flags:
145145
-c, --config string path to a cluster configuration file
146+
-n, --name string aws name of the cluster
147+
-r, --region string aws region of the cluster
146148
--aws-key string aws access key id
147149
--aws-secret string aws secret access key
148150
-e, --env string environment to update (default "aws")
@@ -170,35 +172,39 @@ Flags:
170172
-h, --help help for configure
171173
```
172174

173-
### cluster export
175+
### cluster down
174176

175177
```text
176-
download the code and configuration for all APIs deployed in a cluster
178+
spin down a cluster
177179
178180
Usage:
179-
cortex cluster export [flags]
181+
cortex cluster down [flags]
180182
181183
Flags:
182184
-c, --config string path to a cluster configuration file
185+
-n, --name string aws name of the cluster
186+
-r, --region string aws region of the cluster
183187
--aws-key string aws access key id
184188
--aws-secret string aws secret access key
185-
-h, --help help for export
189+
-y, --yes skip prompts
190+
-h, --help help for down
186191
```
187192

188-
### cluster down
193+
### cluster export
189194

190195
```text
191-
spin down a cluster
196+
download the code and configuration for all APIs deployed in a cluster
192197
193198
Usage:
194-
cortex cluster down [flags]
199+
cortex cluster export [flags]
195200
196201
Flags:
197202
-c, --config string path to a cluster configuration file
203+
-n, --name string aws name of the cluster
204+
-r, --region string aws region of the cluster
198205
--aws-key string aws access key id
199206
--aws-secret string aws secret access key
200-
-y, --yes skip prompts
201-
-h, --help help for down
207+
-h, --help help for export
202208
```
203209

204210
### env configure

0 commit comments

Comments
 (0)