Thanks to visit codestin.com
Credit goes to github.com

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

Commit 0b54f02

Browse files
committed
comments
1 parent bfe525a commit 0b54f02

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

internal/cmd/providers.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cmd
22

33
import (
4+
"cdr.dev/coder-cli/internal/x/xcobra"
45
"fmt"
56

67
"github.com/spf13/cobra"
@@ -29,17 +30,17 @@ func providersCmd() *cobra.Command {
2930

3031
func createProviderCmd() *cobra.Command {
3132
var (
32-
name string
3333
hostname string
3434
clusterAddress string
3535
)
3636
cmd := &cobra.Command{
37-
Use: "create --name=[name] --hostname=[hostname] --clusterAddress=[clusterAddress]",
37+
Use: "create [name] --hostname=[hostname] --clusterAddress=[clusterAddress]",
38+
Args: xcobra.ExactArgs(1),
3839
Short: "create a new workspace provider.",
3940
Long: "Create a new Coder workspace provider.",
4041
Example: `# create a new workspace provider in a pending state
4142
42-
coder providers create --name=my-provider --hostname=provider.example.com --clusterAddress=255.255.255.255`,
43+
coder providers create my-provider --hostname=https://provider.example.com --cluster-address=https://255.255.255.255`,
4344
RunE: func(cmd *cobra.Command, args []string) error {
4445
ctx := cmd.Context()
4546

@@ -48,8 +49,9 @@ coder providers create --name=my-provider --hostname=provider.example.com --clus
4849
return err
4950
}
5051

52+
// ExactArgs(1) ensures our name value can't panic on an out of bounds.
5153
createReq := &coder.CreateWorkspaceProviderReq{
52-
Name: name,
54+
Name: args[0],
5355
Type: coder.WorkspaceProviderKubernetes,
5456
Hostname: hostname,
5557
ClusterAddress: clusterAddress,
@@ -70,12 +72,10 @@ coder providers create --name=my-provider --hostname=provider.example.com --clus
7072
},
7173
}
7274

73-
cmd.Flags().StringVar(&name, "name", "", "workspace provider name")
7475
cmd.Flags().StringVar(&hostname, "hostname", "", "workspace provider hostname")
75-
cmd.Flags().StringVar(&clusterAddress, "clusterAddress", "", "kubernetes cluster apiserver endpoint")
76-
_ = cmd.MarkFlagRequired("name")
76+
cmd.Flags().StringVar(&clusterAddress, "cluster-address", "", "kubernetes cluster apiserver endpoint")
7777
_ = cmd.MarkFlagRequired("hostname")
78-
_ = cmd.MarkFlagRequired("clusterAdress")
78+
_ = cmd.MarkFlagRequired("cluster-address")
7979
return cmd
8080
}
8181

0 commit comments

Comments
 (0)