Skip to content

Commit

Permalink
move timeout duration to flags
Browse files Browse the repository at this point in the history
  • Loading branch information
lizzy-0323 committed Dec 16, 2024
1 parent 9268a93 commit ce20d72
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion internal/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func NewCliCmd() *cobra.Command {
cmd.AddCommand(backup.NewCmd())
cmd.AddCommand(install.NewCmd())
cmd.AddCommand(update.NewCmd())
cmd.AddCommand(demo.NewCmd(0))
cmd.AddCommand(demo.NewCmd())
cmd.AddCommand(completion.NewCmd(cmd.OutOrStdout(), ""))
cmd.Flags().BoolP("version", "v", false, "Print the version of oceanbase cli")
return cmd
Expand Down
13 changes: 5 additions & 8 deletions internal/cli/cmd/demo/demo.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,19 @@ import (
"github.com/oceanbase/ob-operator/internal/const/status/tenantstatus"
)

var defaultTimeoutDuration = 30 * time.Minute

// NewCmd create demo command for cluster creation
func NewCmd(timeoutDuration time.Duration) *cobra.Command {
func NewCmd() *cobra.Command {
clusterOptions := cluster.NewCreateOptions()
tenantOptions := tenant.NewCreateOptions()
logger := utils.GetDefaultLoggerInstance()
pf := demo.NewPromptFactory()
clusterTickerDuration := 2 * time.Second
tenantTickerDuration := 1 * time.Second
var clusterType string
var timeoutDuration time.Duration
var wait bool
var err error
var prompt any
if timeoutDuration == 0 {
timeoutDuration = defaultTimeoutDuration
}
cmd := &cobra.Command{
Use: "demo <subcommand>",
Short: "deploy demo ob cluster and tenant in easier way",
Expand Down Expand Up @@ -126,8 +122,9 @@ func NewCmd(timeoutDuration time.Duration) *cobra.Command {
logger.Printf("Run `echo $(kubectl get secret %s -n %s -o jsonpath='{.data.password}'|base64 --decode)` to get tenant secrets", obtenant.Spec.Credentials.Root, obtenant.Namespace)
},
}
// TODO: if w is set, wait for cluster and tenant ready
cmd.Flags().BoolVarP(&wait, cluster.FLAG_WAIT, "w", cluster.DEFAULT_WAIT, "wait for the cluster and tenant ready")
// TODO: if w is set, wait for cluster and tenant ready, not implemented yet
cmd.Flags().BoolVarP(&wait, cluster.FLAG_WAIT, cluster.SHORTHAND_WAIT, cluster.DEFAULT_WAIT, "wait for the cluster and tenant ready")

Check failure on line 126 in internal/cli/cmd/demo/demo.go

View workflow job for this annotation

GitHub Actions / build-images

undefined: cluster.SHORTHAND_WAIT
cmd.Flags().DurationVarP(&timeoutDuration, cluster.FLAG_TIMEOUT, cluster.SHORTHAND_TIMEOUT, cluster.DEFAULT_TIMEOUT*time.Minute, "timeout duration for waiting for the cluster and tenant ready")

Check failure on line 127 in internal/cli/cmd/demo/demo.go

View workflow job for this annotation

GitHub Actions / build-images

undefined: cluster.FLAG_TIMEOUT

Check failure on line 127 in internal/cli/cmd/demo/demo.go

View workflow job for this annotation

GitHub Actions / build-images

undefined: cluster.SHORTHAND_TIMEOUT

Check failure on line 127 in internal/cli/cmd/demo/demo.go

View workflow job for this annotation

GitHub Actions / build-images

undefined: cluster.DEFAULT_TIMEOUT
return cmd
}

Expand Down

0 comments on commit ce20d72

Please sign in to comment.