feat: add groups support to the CLI (#4755)

This commit is contained in:
Jon Ayers
2022-10-27 16:49:35 -05:00
committed by GitHub
parent ce2a7d49b1
commit 90f77a3415
28 changed files with 766 additions and 18 deletions
+1 -1
View File
@@ -33,7 +33,7 @@ func create() *cobra.Command {
return err
}
organization, err := currentOrganization(cmd, client)
organization, err := CurrentOrganization(cmd, client)
if err != nil {
return err
}
+2 -2
View File
@@ -86,7 +86,7 @@ func login() *cobra.Command {
return xerrors.Errorf("Failed to check server %q for first user, is the URL correct and is coder accessible from your browser? Error - has initial user: %w", serverURL.String(), err)
}
if !hasInitialUser {
_, _ = fmt.Fprintf(cmd.OutOrStdout(), caret+"Your Coder deployment hasn't been set up!\n")
_, _ = fmt.Fprintf(cmd.OutOrStdout(), Caret+"Your Coder deployment hasn't been set up!\n")
if username == "" {
if !isTTY(cmd) {
@@ -244,7 +244,7 @@ func login() *cobra.Command {
return xerrors.Errorf("write server url: %w", err)
}
_, _ = fmt.Fprintf(cmd.OutOrStdout(), caret+"Welcome to Coder, %s! You're authenticated.\n", cliui.Styles.Keyword.Render(resp.Username))
_, _ = fmt.Fprintf(cmd.OutOrStdout(), Caret+"Welcome to Coder, %s! You're authenticated.\n", cliui.Styles.Keyword.Render(resp.Username))
return nil
},
}
+1 -1
View File
@@ -67,7 +67,7 @@ func logout() *cobra.Command {
errorString := strings.TrimRight(errorStringBuilder.String(), "\n")
return xerrors.New("Failed to log out.\n" + errorString)
}
_, _ = fmt.Fprintf(cmd.OutOrStdout(), caret+"You are no longer logged in. You can log in using 'coder login <url>'.\n")
_, _ = fmt.Fprintf(cmd.OutOrStdout(), Caret+"You are no longer logged in. You can log in using 'coder login <url>'.\n")
return nil
},
}
+1 -1
View File
@@ -27,7 +27,7 @@ func parameterList() *cobra.Command {
return err
}
organization, err := currentOrganization(cmd, client)
organization, err := CurrentOrganization(cmd, client)
if err != nil {
return xerrors.Errorf("get current organization: %w", err)
}
+3 -3
View File
@@ -30,7 +30,7 @@ import (
)
var (
caret = cliui.Styles.Prompt.String()
Caret = cliui.Styles.Prompt.String()
// Applied as annotations to workspace commands
// so they display in a separated "help" section.
@@ -352,8 +352,8 @@ func createAgentClient(cmd *cobra.Command) (*codersdk.Client, error) {
return client, nil
}
// currentOrganization returns the currently active organization for the authenticated user.
func currentOrganization(cmd *cobra.Command, client *codersdk.Client) (codersdk.Organization, error) {
// CurrentOrganization returns the currently active organization for the authenticated user.
func CurrentOrganization(cmd *cobra.Command, client *codersdk.Client) (codersdk.Organization, error) {
orgs, err := client.OrganizationsByUser(cmd.Context(), codersdk.Me)
if err != nil {
return codersdk.Organization{}, nil
+1 -1
View File
@@ -40,7 +40,7 @@ func templateCreate() *cobra.Command {
return err
}
organization, err := currentOrganization(cmd, client)
organization, err := CurrentOrganization(cmd, client)
if err != nil {
return err
}
+1 -1
View File
@@ -27,7 +27,7 @@ func templateDelete() *cobra.Command {
if err != nil {
return err
}
organization, err := currentOrganization(cmd, client)
organization, err := CurrentOrganization(cmd, client)
if err != nil {
return err
}
+1 -1
View File
@@ -29,7 +29,7 @@ func templateEdit() *cobra.Command {
if err != nil {
return xerrors.Errorf("create client: %w", err)
}
organization, err := currentOrganization(cmd, client)
organization, err := CurrentOrganization(cmd, client)
if err != nil {
return xerrors.Errorf("get current organization: %w", err)
}
+2 -2
View File
@@ -20,7 +20,7 @@ func templateList() *cobra.Command {
if err != nil {
return err
}
organization, err := currentOrganization(cmd, client)
organization, err := CurrentOrganization(cmd, client)
if err != nil {
return err
}
@@ -30,7 +30,7 @@ func templateList() *cobra.Command {
}
if len(templates) == 0 {
_, _ = fmt.Fprintf(cmd.ErrOrStderr(), "%s No templates found in %s! Create one:\n\n", caret, color.HiWhiteString(organization.Name))
_, _ = fmt.Fprintf(cmd.ErrOrStderr(), "%s No templates found in %s! Create one:\n\n", Caret, color.HiWhiteString(organization.Name))
_, _ = fmt.Fprintln(cmd.ErrOrStderr(), color.HiMagentaString(" $ coder templates create <directory>\n"))
return nil
}
+1 -1
View File
@@ -35,7 +35,7 @@ func templatePull() *cobra.Command {
}
// TODO(JonA): Do we need to add a flag for organization?
organization, err := currentOrganization(cmd, client)
organization, err := CurrentOrganization(cmd, client)
if err != nil {
return xerrors.Errorf("current organization: %w", err)
}
+1 -1
View File
@@ -34,7 +34,7 @@ func templatePush() *cobra.Command {
if err != nil {
return err
}
organization, err := currentOrganization(cmd, client)
organization, err := CurrentOrganization(cmd, client)
if err != nil {
return err
}
+1 -1
View File
@@ -45,7 +45,7 @@ func templateVersionsList() *cobra.Command {
if err != nil {
return xerrors.Errorf("create client: %w", err)
}
organization, err := currentOrganization(cmd, client)
organization, err := CurrentOrganization(cmd, client)
if err != nil {
return xerrors.Errorf("get current organization: %w", err)
}
+1 -1
View File
@@ -25,7 +25,7 @@ func userCreate() *cobra.Command {
if err != nil {
return err
}
organization, err := currentOrganization(cmd, client)
organization, err := CurrentOrganization(cmd, client)
if err != nil {
return err
}