Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add new deploy type #350

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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