Skip to content

Commit

Permalink
modified: cli/command/deploy.go
Browse files Browse the repository at this point in the history
	modified:   internal/errno/errno.go
  • Loading branch information
WhereAreBugs committed Nov 20, 2023
1 parent 8409077 commit 7644457
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 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
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 7644457

Please sign in to comment.