Skip to content

Commit

Permalink
remove view
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyuhang0 committed Dec 13, 2023
1 parent 616eddb commit 5490b28
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 33 deletions.
16 changes: 1 addition & 15 deletions internal/cli/serverless/branch/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,8 @@ func DescribeCmd(h *internal.Helper) *cobra.Command {
Example: fmt.Sprintf(` Get the branch info in interactive mode:
$ %[1]s serverless branch describe
Get the branch info in non-interactive mode:
$ %[1]s serverless branch describe -c <cluster-id> -b <branch-id>
Get the branch info with Basic view in non-interactive mode:
$ %[1]s serverless branch describe -c <cluster-id> -b <branch-id> -v BASIC`, config.CliName),
$ %[1]s serverless branch describe -c <cluster-id> -b <branch-id>`, config.CliName),
PreRunE: func(cmd *cobra.Command, args []string) error {
err := opts.MarkInteractive(cmd)
if err != nil {
Expand Down Expand Up @@ -129,21 +126,11 @@ func DescribeCmd(h *internal.Helper) *cobra.Command {
clusterID = cID
}

view, err := cmd.Flags().GetString(flag.View)
if err != nil {
return errors.Trace(err)
}

params := branchApi.NewBranchServiceGetBranchParams().
WithClusterID(clusterID).WithBranchID(branchID)
if err != nil {
return errors.Trace(err)
}
if view == flag.BasicView {
params.WithView(&view)
} else if view != flag.FullView {
return errors.Errorf("invalid view: %s", view)
}
branch, err := d.GetBranch(params)
if err != nil {
return errors.Trace(err)
Expand All @@ -161,7 +148,6 @@ func DescribeCmd(h *internal.Helper) *cobra.Command {

describeCmd.Flags().StringP(flag.BranchID, flag.BranchIDShort, "", "The ID of the branch to be described")
describeCmd.Flags().StringP(flag.ClusterID, flag.ClusterIDShort, "", "The cluster ID of the branch to be described")
describeCmd.Flags().StringP(flag.View, flag.ViewShort, flag.FullView, "The view of cluster, One of [\"BASIC\" \"FULL\"]")
describeCmd.MarkFlagsRequiredTogether(flag.BranchID, flag.ClusterID)
return describeCmd
}
19 changes: 1 addition & 18 deletions internal/cli/serverless/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,8 @@ func DescribeCmd(h *internal.Helper) *cobra.Command {
Example: fmt.Sprintf(` Get the serverless cluster info in interactive mode:
$ %[1]s serverless describe
Get the Basic serverless cluster info in interactive mode:
$ %[1]s serverless describe -v BASIC
Get the serverless cluster info in non-interactive mode:
$ %[1]s serverless describe -c <cluster-id>
Get the Basic serverless cluster info in non-interactive mode:
$ %[1]s serverless describe -c <cluster-id> -v BASIC`, config.CliName),
$ %[1]s serverless describe -c <cluster-id>`, config.CliName),
PreRunE: func(cmd *cobra.Command, args []string) error {
flags := opts.NonInteractiveFlags()
for _, fn := range flags {
Expand Down Expand Up @@ -115,17 +109,7 @@ func DescribeCmd(h *internal.Helper) *cobra.Command {
clusterID = cID
}

view, err := cmd.Flags().GetString(flag.View)
if err != nil {
return errors.Trace(err)
}

params := serverlessApi.NewServerlessServiceGetClusterParams().WithClusterID(clusterID)
if view == flag.BasicView {
params.WithView(&view)
} else if view != flag.FullView {
return errors.Errorf("invalid view: %s", view)
}

cluster, err := d.GetCluster(params)
if err != nil {
Expand All @@ -143,6 +127,5 @@ func DescribeCmd(h *internal.Helper) *cobra.Command {
}

describeCmd.Flags().StringP(flag.ClusterID, flag.ClusterIDShort, "", "The ID of the cluster")
describeCmd.Flags().StringP(flag.View, flag.ViewShort, flag.FullView, "The view of cluster, One of [\"BASIC\" \"FULL\"]")
return describeCmd
}

0 comments on commit 5490b28

Please sign in to comment.