Skip to content

Commit

Permalink
add deploy type
Browse files Browse the repository at this point in the history
Signed-off-by: WhereAreBugs <[email protected]>
  • Loading branch information
WhereAreBugs committed Nov 22, 2023
1 parent 8409077 commit ec0505f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
21 changes: 19 additions & 2 deletions cli/command/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ var (
CAN_SKIP_ROLES = []string{
ROLE_SNAPSHOTCLONE,
}
SUPPORTED_DEPLOY_TYPES = []string{
"default",
"prod",
"staging",
"test",
"beta",
"dev",
}
)

type deployOptions struct {
Expand All @@ -117,6 +125,7 @@ type deployOptions struct {
poolset string
poolsetDiskType string
debug bool
deployType string
}

func checkDeployOptions(options deployOptions) error {
Expand All @@ -127,6 +136,12 @@ func checkDeployOptions(options deployOptions) error {
F("skip role: %s", role)
}
}
// check deploy type
supportDeployType := utils.Slice2Map(SUPPORTED_DEPLOY_TYPES)
if !supportDeployType[options.deployType] {
return errno.ERR_UNSUPPORT_DEPLOY_TYPE.
F("deploy type: %s", options.deployType)
}
return nil
}

Expand All @@ -152,6 +167,7 @@ func NewDeployCommand(curveadm *cli.CurveAdm) *cobra.Command {
flags.StringVar(&options.poolset, "poolset", "default", "poolset name")
flags.StringVar(&options.poolsetDiskType, "poolset-disktype", "ssd", "Specify the disk type of physical pool")
flags.BoolVar(&options.debug, "debug", false, "Debug deploy progress")
flags.StringVar(&options.deployType, "deploy-type", "default", "Specify the type of deploy")
return cmd
}

Expand Down Expand Up @@ -285,10 +301,11 @@ func serviceStats(dcs []*topology.DeployConfig) string {
return serviceStats
}

func displayDeployTitle(curveadm *cli.CurveAdm, dcs []*topology.DeployConfig) {
func displayDeployTitle(curveadm *cli.CurveAdm, dcs []*topology.DeployConfig, options deployOptions) {
curveadm.WriteOutln("Cluster Name : %s", curveadm.ClusterName())
curveadm.WriteOutln("Cluster Kind : %s", dcs[0].GetKind())
curveadm.WriteOutln("Cluster Services: %s", serviceStats(dcs))
curveadm.WriteOutln("Cluster Type : %s", options.deployType)
curveadm.WriteOutln("")
}

Expand Down Expand Up @@ -336,7 +353,7 @@ func runDeploy(curveadm *cli.CurveAdm, options deployOptions) error {
}

// 6) display title
displayDeployTitle(curveadm, dcs)
displayDeployTitle(curveadm, dcs, options)

// 7) run playground
if err = pb.Run(); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/errno/errno.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ var (
ERR_UNSUPPORT_CLEAN_ITEM = EC(210005, "unsupport clean item")
ERR_NO_SERVICES_MATCHED = EC(210006, "no services matched")
ERR_INVALID_DISK_TYPE = EC(210007, "diskType must be lowercase and only can only be one of ssd, hdd and nvme")

ERR_UNSUPPORT_DEPLOY_TYPE = EC(210008, "unknown deploy type")
// 220: commad options (client common)
ERR_UNSUPPORT_CLIENT_KIND = EC(220000, "unsupport client kind")
// 221: command options (client/bs)
Expand Down

0 comments on commit ec0505f

Please sign in to comment.