diff --git a/cmd/command/setup_opts.go b/cmd/command/setup_opts.go index bc0205060188816d29633284593717d7f9fe08f0..e6bdc1371f663b8a28c88f313b23177c77449d66 100644 --- a/cmd/command/setup_opts.go +++ b/cmd/command/setup_opts.go @@ -18,6 +18,7 @@ package command import ( "nestos-kubernetes-deployer/cmd/command/opts" + "nestos-kubernetes-deployer/constVal" "github.com/spf13/cobra" ) @@ -25,7 +26,7 @@ import ( func SetupDeployCmdOpts(deployCmd *cobra.Command) { flags := deployCmd.Flags() flags.StringVarP(&opts.Opts.ClusterConfigFile, "file", "f", "", "Location of the cluster deploy config file") - flags.StringVarP(&opts.Opts.ClusterID, "clusterID", "", "", "Unique identifier for the cluster") + flags.StringVarP(&opts.Opts.ClusterID, "clusterID", "", "", constVal.ClusterIdHelp) flags.StringVar(&opts.Opts.Arch, "arch", "", "Architecture for Kubernetes cluster deployment (e.g., amd64 or arm64)") flags.StringVarP(&opts.Opts.Platform, "platform", "", "", "Infrastructure platform for deploying the cluster (supports 'libvirt' 'openstack' 'pxe' 'ipxe')") @@ -96,12 +97,12 @@ func SetupDeployCmdOpts(deployCmd *cobra.Command) { func SetupDestroyCmdOpts(destroyCmd *cobra.Command) { flags := destroyCmd.Flags() - flags.StringVarP(&opts.Opts.ClusterID, "cluster-id", "", "", "Unique identifier for the cluster") + flags.StringVarP(&opts.Opts.ClusterID, constVal.ClusterId, "", "", constVal.ClusterIdHelp) } func SetupUpgradeCmdOpts(upgradeCmd *cobra.Command) { flags := upgradeCmd.Flags() - flags.StringVarP(&opts.Opts.ClusterID, "cluster-id", "", "", "Unique identifier for the cluster") + flags.StringVarP(&opts.Opts.ClusterID, constVal.ClusterId, "", "", constVal.ClusterIdHelp) flags.StringVarP(&opts.Opts.Housekeeper.KubeVersion, "kube-version", "", "", "Choose a specific kubernetes version for upgrading") flags.BoolVarP(&opts.Opts.Housekeeper.EvictPodForce, "force", "", false, "Force eviction of pods even if unsafe. This may result in data loss or service disruption, use with caution (default: false)") flags.UintVarP(&opts.Opts.Housekeeper.MaxUnavailable, "maxunavailable", "", 0, "Number of nodes that are upgraded at the same time (default: 2)") @@ -111,7 +112,7 @@ func SetupUpgradeCmdOpts(upgradeCmd *cobra.Command) { func SetupExtendCmdOpts(extendCmd *cobra.Command) { flags := extendCmd.Flags() - flags.StringVarP(&opts.Opts.ClusterID, "cluster-id", "", "", "Unique identifier for the cluster") + flags.StringVarP(&opts.Opts.ClusterID, constVal.ClusterId, "", "", constVal.ClusterIdHelp) flags.UintVarP(&opts.Opts.ExtendCount, "num", "n", 0, "The number of extend worker nodes") } diff --git a/constVal/commandLine.go b/constVal/commandLine.go new file mode 100644 index 0000000000000000000000000000000000000000..b15ab8943e0bc9c66776d06ddae89ca79d8ac239 --- /dev/null +++ b/constVal/commandLine.go @@ -0,0 +1,22 @@ +/* +Copyright 2024 KylinSoft Co., Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package constVal + +const ( + ClusterId = "cluster-id" + ClusterIdHelp = "Unique identifier for the cluster" +)