Skip to content

Commit a1803e3

Browse files
authored
PWX-29068: Improving storkctl create clusterpair help output. (#1314)
* PWX-29068: Improving storkctl create clusterpair help output. Signed-off-by: Priyanshu Pandey <ppandey@purestorage.com> * Moving (currently supported only for Rancher) to the top Signed-off-by: Priyanshu Pandey <ppandey@purestorage.com> --------- Signed-off-by: Priyanshu Pandey <ppandey@purestorage.com>
1 parent 6332387 commit a1803e3

3 files changed

Lines changed: 28 additions & 23 deletions

File tree

cmd/stork/stork.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,12 @@ func main() {
187187
cli.IntFlag{
188188
Name: "k8s-api-qps",
189189
Value: 100,
190-
Usage: "Restrict number of k8s api requests from stork (default: 100 QPS)",
190+
Usage: "Restrict number of k8s API requests from stork (default: 100 QPS)",
191191
},
192192
cli.IntFlag{
193193
Name: "k8s-api-burst",
194194
Value: 100,
195-
Usage: "Restrict number of k8s api requests from stork (default: 100 Burst)",
195+
Usage: "Restrict number of k8s API requests from stork (default: 100 Burst)",
196196
},
197197
cli.BoolTFlag{
198198
Name: "kdmp-controller",

pkg/storkctl/clusterpair.go

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,15 @@ const (
3333
gcloudBinaryName = "gcloud"
3434
)
3535

36-
var clusterPairColumns = []string{"NAME", "STORAGE-STATUS", "SCHEDULER-STATUS", "CREATED"}
36+
var (
37+
clusterPairColumns = []string{"NAME", "STORAGE-STATUS", "SCHEDULER-STATUS", "CREATED"}
38+
39+
projectMappingHelpString = "Project mappings between source and destination clusters (currently supported only for Rancher).\n" +
40+
"Use comma-separated <source-project-id>=<dest-project-id> pairs.\n" +
41+
"For the project-id, you can also have a cluster-id field added as a prefix to the project-id.\n" +
42+
"It is recommended to include both one-to-one mappings of the project-id and Rancher cluster-id prefixed project-id as follows:\n" +
43+
"<source-project-id>=<dest-project-id>,<source-cluster-id>:<source-project-id>=<dest-cluster-id>:<dest-project-id>"
44+
)
3745

3846
func newGetClusterPairCommand(cmdFactory Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
3947
getClusterPairCommand := &cobra.Command{
@@ -208,8 +216,7 @@ func newGenerateClusterPairCommand(cmdFactory Factory, ioStreams genericclioptio
208216
if len(projectMappingsStr) > 0 {
209217
projectIDMap, err := utils.ParseKeyValueList(strings.Split(projectMappingsStr, ","))
210218
if err != nil {
211-
util.CheckErr(fmt.Errorf("invalid project-mappings provided, use comma-separated" +
212-
"<source-project-id>=<dest-project-id> pairs (Currently supported only for Rancher)"))
219+
util.CheckErr(fmt.Errorf("invalid %v", projectMappingHelpString))
213220
}
214221
clusterPair.Spec.PlatformOptions = storkv1.PlatformSpec{
215222
Rancher: &storkv1.RancherSpec{ProjectMappings: projectIDMap},
@@ -224,8 +231,7 @@ func newGenerateClusterPairCommand(cmdFactory Factory, ioStreams genericclioptio
224231
}
225232

226233
generateClusterPairCommand.Flags().StringVarP(&storageOptions, "storageoptions", "s", "", "comma seperated key-value pair storage options")
227-
generateClusterPairCommand.Flags().StringVarP(&projectMappingsStr, "project-mappings", "", "",
228-
"project mappings between source and destination clusters, use comma-separated <source-project-id>=<dest-project-id> pairs (Currently supported only for Rancher)")
234+
generateClusterPairCommand.Flags().StringVarP(&projectMappingsStr, "project-mappings", "", "", projectMappingHelpString)
229235
return generateClusterPairCommand
230236
}
231237

@@ -325,16 +331,15 @@ func newCreateClusterPairCommand(cmdFactory Factory, ioStreams genericclioptions
325331
},
326332
}
327333

328-
createClusterPairCommand.Flags().StringVarP(&sIP, "src-ip", "", "", "ip of storage node from source cluster")
329-
createClusterPairCommand.Flags().StringVarP(&sPort, "src-port", "", "9001", "port of storage node from source cluster")
330-
createClusterPairCommand.Flags().StringVarP(&sFile, "src-kube-file", "", "", "kube-config of source cluster")
331-
createClusterPairCommand.Flags().StringVarP(&dIP, "dest-ip", "", "", "kube-config of destination cluster")
332-
createClusterPairCommand.Flags().StringVarP(&dPort, "dest-port", "", "9001", "port of storage node from destination cluster")
333-
createClusterPairCommand.Flags().StringVarP(&dFile, "dest-kube-file", "", "", "kube-config of destination cluster")
334-
createClusterPairCommand.Flags().StringVarP(&srcToken, "src-token", "", "", "(optional)source cluster token for cluster pairing")
335-
createClusterPairCommand.Flags().StringVarP(&destToken, "dest-token", "", "", "(optional)destination cluster token for cluster pairing")
336-
createClusterPairCommand.Flags().StringVarP(&projectMappingsStr, "project-mappings", "", "",
337-
"project mappings between source and destination clusters, use comma-separated <source-project-id>=<dest-project-id> pairs (Currently supported only for Rancher)")
334+
createClusterPairCommand.Flags().StringVarP(&sIP, "src-ip", "", "", "IP of storage node from source cluster")
335+
createClusterPairCommand.Flags().StringVarP(&sPort, "src-port", "", "9001", "Port of storage node from source cluster")
336+
createClusterPairCommand.Flags().StringVarP(&sFile, "src-kube-file", "", "", "Path to the kubeconfig of source cluster")
337+
createClusterPairCommand.Flags().StringVarP(&dIP, "dest-ip", "", "", "IP of storage node from destination cluster")
338+
createClusterPairCommand.Flags().StringVarP(&dPort, "dest-port", "", "9001", "Port of storage node from destination cluster")
339+
createClusterPairCommand.Flags().StringVarP(&dFile, "dest-kube-file", "", "", "Path to the kubeconfig of destination cluster")
340+
createClusterPairCommand.Flags().StringVarP(&srcToken, "src-token", "", "", "(Optional)Source cluster token for cluster pairing")
341+
createClusterPairCommand.Flags().StringVarP(&destToken, "dest-token", "", "", "(Optional)Destination cluster token for cluster pairing")
342+
createClusterPairCommand.Flags().StringVarP(&projectMappingsStr, "project-mappings", "", "", projectMappingHelpString)
338343

339344
return createClusterPairCommand
340345
}

pkg/storkctl/factory.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ func NewFactory() Factory {
7373

7474
func (f *factory) BindFlags(flags *pflag.FlagSet) {
7575
flags.StringVarP(&f.namespace, "namespace", "n", "default", "If present, the namespace scope for this CLI request")
76-
flags.StringVar(&f.kubeconfig, "kubeconfig", "", "Path to the kubeconfig file to use for CLI requests")
77-
flags.StringVar(&f.context, "context", "", "The name of the kubeconfig context to use")
78-
flags.StringVarP(&f.outputFormat, "output", "o", outputFormatTable, "Output format. One of: table|json|yaml")
79-
flags.BoolVarP(&f.watch, "watch", "w", false, "watch stork resourrces")
80-
flags.IntVarP(&f.qps, "qps", "", 100, "Restrict number of k8s api requests from stork")
81-
flags.IntVarP(&f.burst, "burst", "", 100, "Restrict number of k8s api requests from stork")
76+
flags.StringVar(&f.kubeconfig, "kubeconfig", "", "path to the kubeconfig file to use for CLI requests")
77+
flags.StringVar(&f.context, "context", "", "name of the kubeconfig context to use")
78+
flags.StringVarP(&f.outputFormat, "output", "o", outputFormatTable, "output format. One of: table|json|yaml")
79+
flags.BoolVarP(&f.watch, "watch", "w", false, "watch stork resources")
80+
flags.IntVarP(&f.qps, "qps", "", 100, "restrict number of k8s API requests from stork")
81+
flags.IntVarP(&f.burst, "burst", "", 100, "restrict number of k8s API requests from stork")
8282
}
8383

8484
func (f *factory) BindGetFlags(flags *pflag.FlagSet) {

0 commit comments

Comments
 (0)