Skip to content

Commit

Permalink
PWX-29068: Improving storkctl create clusterpair help output. (#1314)
Browse files Browse the repository at this point in the history
* PWX-29068: Improving storkctl create clusterpair help output.

Signed-off-by: Priyanshu Pandey <[email protected]>

* Moving (currently supported only for Rancher) to the top

Signed-off-by: Priyanshu Pandey <[email protected]>

---------

Signed-off-by: Priyanshu Pandey <[email protected]>
  • Loading branch information
pp511 authored Feb 28, 2023
1 parent 6332387 commit a1803e3
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 23 deletions.
4 changes: 2 additions & 2 deletions cmd/stork/stork.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,12 @@ func main() {
cli.IntFlag{
Name: "k8s-api-qps",
Value: 100,
Usage: "Restrict number of k8s api requests from stork (default: 100 QPS)",
Usage: "Restrict number of k8s API requests from stork (default: 100 QPS)",
},
cli.IntFlag{
Name: "k8s-api-burst",
Value: 100,
Usage: "Restrict number of k8s api requests from stork (default: 100 Burst)",
Usage: "Restrict number of k8s API requests from stork (default: 100 Burst)",
},
cli.BoolTFlag{
Name: "kdmp-controller",
Expand Down
35 changes: 20 additions & 15 deletions pkg/storkctl/clusterpair.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,15 @@ const (
gcloudBinaryName = "gcloud"
)

var clusterPairColumns = []string{"NAME", "STORAGE-STATUS", "SCHEDULER-STATUS", "CREATED"}
var (
clusterPairColumns = []string{"NAME", "STORAGE-STATUS", "SCHEDULER-STATUS", "CREATED"}

projectMappingHelpString = "Project mappings between source and destination clusters (currently supported only for Rancher).\n" +
"Use comma-separated <source-project-id>=<dest-project-id> pairs.\n" +
"For the project-id, you can also have a cluster-id field added as a prefix to the project-id.\n" +
"It is recommended to include both one-to-one mappings of the project-id and Rancher cluster-id prefixed project-id as follows:\n" +
"<source-project-id>=<dest-project-id>,<source-cluster-id>:<source-project-id>=<dest-cluster-id>:<dest-project-id>"
)

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

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

Expand Down Expand Up @@ -325,16 +331,15 @@ func newCreateClusterPairCommand(cmdFactory Factory, ioStreams genericclioptions
},
}

createClusterPairCommand.Flags().StringVarP(&sIP, "src-ip", "", "", "ip of storage node from source cluster")
createClusterPairCommand.Flags().StringVarP(&sPort, "src-port", "", "9001", "port of storage node from source cluster")
createClusterPairCommand.Flags().StringVarP(&sFile, "src-kube-file", "", "", "kube-config of source cluster")
createClusterPairCommand.Flags().StringVarP(&dIP, "dest-ip", "", "", "kube-config of destination cluster")
createClusterPairCommand.Flags().StringVarP(&dPort, "dest-port", "", "9001", "port of storage node from destination cluster")
createClusterPairCommand.Flags().StringVarP(&dFile, "dest-kube-file", "", "", "kube-config of destination cluster")
createClusterPairCommand.Flags().StringVarP(&srcToken, "src-token", "", "", "(optional)source cluster token for cluster pairing")
createClusterPairCommand.Flags().StringVarP(&destToken, "dest-token", "", "", "(optional)destination cluster token for cluster pairing")
createClusterPairCommand.Flags().StringVarP(&projectMappingsStr, "project-mappings", "", "",
"project mappings between source and destination clusters, use comma-separated <source-project-id>=<dest-project-id> pairs (Currently supported only for Rancher)")
createClusterPairCommand.Flags().StringVarP(&sIP, "src-ip", "", "", "IP of storage node from source cluster")
createClusterPairCommand.Flags().StringVarP(&sPort, "src-port", "", "9001", "Port of storage node from source cluster")
createClusterPairCommand.Flags().StringVarP(&sFile, "src-kube-file", "", "", "Path to the kubeconfig of source cluster")
createClusterPairCommand.Flags().StringVarP(&dIP, "dest-ip", "", "", "IP of storage node from destination cluster")
createClusterPairCommand.Flags().StringVarP(&dPort, "dest-port", "", "9001", "Port of storage node from destination cluster")
createClusterPairCommand.Flags().StringVarP(&dFile, "dest-kube-file", "", "", "Path to the kubeconfig of destination cluster")
createClusterPairCommand.Flags().StringVarP(&srcToken, "src-token", "", "", "(Optional)Source cluster token for cluster pairing")
createClusterPairCommand.Flags().StringVarP(&destToken, "dest-token", "", "", "(Optional)Destination cluster token for cluster pairing")
createClusterPairCommand.Flags().StringVarP(&projectMappingsStr, "project-mappings", "", "", projectMappingHelpString)

return createClusterPairCommand
}
Expand Down
12 changes: 6 additions & 6 deletions pkg/storkctl/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ func NewFactory() Factory {

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

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

0 comments on commit a1803e3

Please sign in to comment.