coder licenses add CLI command (#3632)

* coder licenses add CLI command

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix up lint

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix t.parallel call

Signed-off-by: Spike Curtis <spike@coder.com>

* Code review improvements

Signed-off-by: Spike Curtis <spike@coder.com>

* Lint

Signed-off-by: Spike Curtis <spike@coder.com>

Signed-off-by: Spike Curtis <spike@coder.com>
This commit is contained in:
Spike Curtis
2022-08-23 13:55:39 -07:00
committed by GitHub
parent 6dacf70898
commit 184f0625e1
32 changed files with 357 additions and 38 deletions
+4 -4
View File
@@ -114,7 +114,7 @@ func Root(subcommands []*cobra.Command) *cobra.Command {
return nil
}
client, err := createClient(cmd)
client, err := CreateClient(cmd)
// If the client is unauthenticated we can ignore the check.
// The child commands should handle an unauthenticated client.
if xerrors.Is(err, errUnauthenticated) {
@@ -190,9 +190,9 @@ func isTest() bool {
return flag.Lookup("test.v") != nil
}
// createClient returns a new client from the command context.
// CreateClient returns a new client from the command context.
// It reads from global configuration files if flags are not set.
func createClient(cmd *cobra.Command) (*codersdk.Client, error) {
func CreateClient(cmd *cobra.Command) (*codersdk.Client, error) {
root := createConfig(cmd)
rawURL, err := cmd.Flags().GetString(varURL)
if err != nil || rawURL == "" {
@@ -226,7 +226,7 @@ func createClient(cmd *cobra.Command) (*codersdk.Client, error) {
}
// createAgentClient returns a new client from the command context.
// It works just like createClient, but uses the agent token and URL instead.
// It works just like CreateClient, but uses the agent token and URL instead.
func createAgentClient(cmd *cobra.Command) (*codersdk.Client, error) {
rawURL, err := cmd.Flags().GetString(varAgentURL)
if err != nil {