@@ -170,12 +170,9 @@ func createClusterCommand() *cobra.Command {
170170 Use : "create" ,
171171 Short : "create a cluster" ,
172172 Run : func (cmd * cobra.Command , args []string ) {
173- operatorEndpoint , err := cmd . Flags (). GetString ( "operator-endpoint" )
173+ operatorEndpoint , err := getOperatorEndpoint ( )
174174 if err != nil {
175- operatorEndpoint , err = getOperatorEndpoint ()
176- if err != nil {
177- cmdFailedf (cmd , "get operator endpoint failed: %s" , err )
178- }
175+ cmdFailedf (cmd , "get operator endpoint failed: %s" , err )
179176 }
180177
181178 if showInstallableList {
@@ -251,6 +248,7 @@ func createClusterCommand() *cobra.Command {
251248 }
252249
253250 clusterspec := table .NewWriter ()
251+ clusterspec .SetCaption ("The Endpoints Of Vanus Operator: %s\n " , operatorEndpoint )
254252 clusterspec .AppendHeader (table.Row {"Cluster" , "Version" , "Component" , "Replicas" , "StorageSize" , "StorageClass" })
255253 if c .Etcd .StorageClass == nil {
256254 clusterspec .AppendRow (table.Row {"vanus" , * c .Version , "etcd" , * c .Etcd .Replicas , * c .Etcd .StorageSize , "-" })
@@ -351,12 +349,9 @@ func deleteClusterCommand() *cobra.Command {
351349 Use : "delete" ,
352350 Short : "delete a cluster" ,
353351 Run : func (cmd * cobra.Command , args []string ) {
354- operatorEndpoint , err := cmd . Flags (). GetString ( "operator-endpoint" )
352+ operatorEndpoint , err := getOperatorEndpoint ( )
355353 if err != nil {
356- operatorEndpoint , err = getOperatorEndpoint ()
357- if err != nil {
358- cmdFailedf (cmd , "get operator endpoint failed: %s" , err )
359- }
354+ cmdFailedf (cmd , "get operator endpoint failed: %s" , err )
360355 }
361356
362357 fmt .Print ("Deleting a cluster will lose all cluster data and can't be recovered, do you still want to delete the vanus cluster(y/n):" )
@@ -465,12 +460,9 @@ func upgradeClusterCommand() *cobra.Command {
465460 Use : "upgrade" ,
466461 Short : "upgrade cluster" ,
467462 Run : func (cmd * cobra.Command , args []string ) {
468- operatorEndpoint , err := cmd . Flags (). GetString ( "operator-endpoint" )
463+ operatorEndpoint , err := getOperatorEndpoint ( )
469464 if err != nil {
470- operatorEndpoint , err = getOperatorEndpoint ()
471- if err != nil {
472- cmdFailedf (cmd , "get operator endpoint failed: %s" , err )
473- }
465+ cmdFailedf (cmd , "get operator endpoint failed: %s" , err )
474466 }
475467
476468 if showUpgradeableList {
@@ -588,12 +580,13 @@ func scaleStoreReplicas() *cobra.Command {
588580 Use : "store" ,
589581 Short : "scale store replicas" ,
590582 Run : func (cmd * cobra.Command , args []string ) {
591- operatorEndpoint , err := cmd . Flags (). GetString ( "operator-endpoint" )
583+ operatorEndpoint , err := getOperatorEndpoint ( )
592584 if err != nil {
593- operatorEndpoint , err = getOperatorEndpoint ()
594- if err != nil {
595- cmdFailedf (cmd , "get operator endpoint failed: %s" , err )
596- }
585+ cmdFailedf (cmd , "get operator endpoint failed: %s" , err )
586+ }
587+
588+ if storeReplicas == 0 {
589+ cmdFailedf (cmd , "the --replicas flag MUST be set" )
597590 }
598591
599592 client := & http.Client {}
@@ -651,7 +644,7 @@ func scaleStoreReplicas() *cobra.Command {
651644 }
652645 },
653646 }
654- cmd .Flags ().Int32Var (& storeReplicas , "replicas" , 3 , "replicas" )
647+ cmd .Flags ().Int32Var (& storeReplicas , "replicas" , 0 , "the replicas of store " )
655648 return cmd
656649}
657650
@@ -660,12 +653,13 @@ func scaleTriggerReplicas() *cobra.Command {
660653 Use : "trigger" ,
661654 Short : "scale trigger replicas" ,
662655 Run : func (cmd * cobra.Command , args []string ) {
663- operatorEndpoint , err := cmd . Flags (). GetString ( "operator-endpoint" )
656+ operatorEndpoint , err := getOperatorEndpoint ( )
664657 if err != nil {
665- operatorEndpoint , err = getOperatorEndpoint ()
666- if err != nil {
667- cmdFailedf (cmd , "get operator endpoint failed: %s" , err )
668- }
658+ cmdFailedf (cmd , "get operator endpoint failed: %s" , err )
659+ }
660+
661+ if triggerReplicas == 0 {
662+ cmdFailedf (cmd , "the --replicas flag MUST be set" )
669663 }
670664
671665 client := & http.Client {}
@@ -723,7 +717,7 @@ func scaleTriggerReplicas() *cobra.Command {
723717 }
724718 },
725719 }
726- cmd .Flags ().Int32Var (& triggerReplicas , "replicas" , 3 , "replicas" )
720+ cmd .Flags ().Int32Var (& triggerReplicas , "replicas" , 0 , "the replicas of trigger " )
727721 return cmd
728722}
729723
@@ -732,12 +726,9 @@ func getClusterCommand() *cobra.Command {
732726 Use : "status" ,
733727 Short : "get cluster status" ,
734728 Run : func (cmd * cobra.Command , args []string ) {
735- operatorEndpoint , err := cmd . Flags (). GetString ( "operator-endpoint" )
729+ operatorEndpoint , err := getOperatorEndpoint ( )
736730 if err != nil {
737- operatorEndpoint , err = getOperatorEndpoint ()
738- if err != nil {
739- cmdFailedf (cmd , "get operator endpoint failed: %s" , err )
740- }
731+ cmdFailedf (cmd , "get operator endpoint failed: %s" , err )
741732 }
742733
743734 client := & http.Client {}
0 commit comments