Skip to content

feat: add display_name field to groups #8740

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add display name to cli
  • Loading branch information
Emyrk committed Aug 1, 2023
commit d0c254cd35293b5b0ef5c2f77d37f0972141a250
17 changes: 14 additions & 3 deletions enterprise/cli/groupcreate.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ import (
)

func (r *RootCmd) groupCreate() *clibase.Cmd {
var avatarURL string
var (
avatarURL string
displayName string
)

client := new(codersdk.Client)
cmd := &clibase.Cmd{
Use: "create <name>",
Expand All @@ -30,8 +34,9 @@ func (r *RootCmd) groupCreate() *clibase.Cmd {
}

group, err := client.CreateGroup(ctx, org.ID, codersdk.CreateGroupRequest{
Name: inv.Args[0],
AvatarURL: avatarURL,
Name: inv.Args[0],
DisplayName: displayName,
AvatarURL: avatarURL,
})
if err != nil {
return xerrors.Errorf("create group: %w", err)
Expand All @@ -50,6 +55,12 @@ func (r *RootCmd) groupCreate() *clibase.Cmd {
Env: "CODER_AVATAR_URL",
Value: clibase.StringOf(&avatarURL),
},
{
Flag: "display-name",
Description: `Optional human friendly name for the group.`,
Env: "CODER_DISPLAY_NAME",
Value: clibase.StringOf(&displayName),
},
}

return cmd
Expand Down
19 changes: 15 additions & 4 deletions enterprise/cli/groupedit.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ import (

func (r *RootCmd) groupEdit() *clibase.Cmd {
var (
avatarURL string
name string
addUsers []string
rmUsers []string
avatarURL string
name string
displayName string
addUsers []string
rmUsers []string
)
client := new(codersdk.Client)
cmd := &clibase.Cmd{
Expand Down Expand Up @@ -52,6 +53,10 @@ func (r *RootCmd) groupEdit() *clibase.Cmd {
req.AvatarURL = &avatarURL
}

if inv.ParsedFlags().Lookup("display-name").Changed {
req.DisplayName = &displayName
}

userRes, err := client.Users(ctx, codersdk.UsersRequest{})
if err != nil {
return xerrors.Errorf("get users: %w", err)
Expand Down Expand Up @@ -90,6 +95,12 @@ func (r *RootCmd) groupEdit() *clibase.Cmd {
Description: "Update the group avatar.",
Value: clibase.StringOf(&avatarURL),
},
{
Flag: "display-name",
Description: `Optional human friendly name for the group.`,
Env: "CODER_DISPLAY_NAME",
Value: clibase.StringOf(&displayName),
},
{
Flag: "add-users",
FlagShorthand: "a",
Expand Down