Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit 710e3cf

Browse files
committed
comments
1 parent bfe525a commit 710e3cf

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

internal/cmd/providers.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package cmd
33
import (
44
"fmt"
55

6+
"cdr.dev/coder-cli/internal/x/xcobra"
7+
68
"github.com/spf13/cobra"
79
"golang.org/x/xerrors"
810

@@ -29,17 +31,17 @@ func providersCmd() *cobra.Command {
2931

3032
func createProviderCmd() *cobra.Command {
3133
var (
32-
name string
3334
hostname string
3435
clusterAddress string
3536
)
3637
cmd := &cobra.Command{
37-
Use: "create --name=[name] --hostname=[hostname] --clusterAddress=[clusterAddress]",
38+
Use: "create [name] --hostname=[hostname] --clusterAddress=[clusterAddress]",
39+
Args: xcobra.ExactArgs(1),
3840
Short: "create a new workspace provider.",
3941
Long: "Create a new Coder workspace provider.",
4042
Example: `# create a new workspace provider in a pending state
4143
42-
coder providers create --name=my-provider --hostname=provider.example.com --clusterAddress=255.255.255.255`,
44+
coder providers create my-provider --hostname=https://provider.example.com --cluster-address=https://255.255.255.255`,
4345
RunE: func(cmd *cobra.Command, args []string) error {
4446
ctx := cmd.Context()
4547

@@ -48,8 +50,9 @@ coder providers create --name=my-provider --hostname=provider.example.com --clus
4850
return err
4951
}
5052

53+
// ExactArgs(1) ensures our name value can't panic on an out of bounds.
5154
createReq := &coder.CreateWorkspaceProviderReq{
52-
Name: name,
55+
Name: args[0],
5356
Type: coder.WorkspaceProviderKubernetes,
5457
Hostname: hostname,
5558
ClusterAddress: clusterAddress,
@@ -70,12 +73,10 @@ coder providers create --name=my-provider --hostname=provider.example.com --clus
7073
},
7174
}
7275

73-
cmd.Flags().StringVar(&name, "name", "", "workspace provider name")
7476
cmd.Flags().StringVar(&hostname, "hostname", "", "workspace provider hostname")
75-
cmd.Flags().StringVar(&clusterAddress, "clusterAddress", "", "kubernetes cluster apiserver endpoint")
76-
_ = cmd.MarkFlagRequired("name")
77+
cmd.Flags().StringVar(&clusterAddress, "cluster-address", "", "kubernetes cluster apiserver endpoint")
7778
_ = cmd.MarkFlagRequired("hostname")
78-
_ = cmd.MarkFlagRequired("clusterAdress")
79+
_ = cmd.MarkFlagRequired("cluster-address")
7980
return cmd
8081
}
8182

0 commit comments

Comments
 (0)