diff --git a/api/groups/member.gen.go b/api/groups/member.gen.go index 01fd29904..351a66d54 100644 --- a/api/groups/member.gen.go +++ b/api/groups/member.gen.go @@ -3,6 +3,5 @@ package groups type Member struct { Id string `json:"id,omitempty"` - Type string `json:"type,omitempty"` ScopeId string `json:"scope_id,omitempty"` } diff --git a/internal/cmd/commands.go b/internal/cmd/commands.go index 0a491f4c0..6480380de 100644 --- a/internal/cmd/commands.go +++ b/internal/cmd/commands.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/boundary/internal/cmd/commands/config" "github.com/hashicorp/boundary/internal/cmd/commands/controller" "github.com/hashicorp/boundary/internal/cmd/commands/dev" + "github.com/hashicorp/boundary/internal/cmd/commands/groups" "github.com/hashicorp/boundary/internal/cmd/commands/hosts" "github.com/hashicorp/boundary/internal/cmd/commands/roles" "github.com/hashicorp/boundary/internal/cmd/commands/scopes" @@ -53,11 +54,69 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) { SigUSR2Ch: MakeSigUSR2Ch(), }, nil }, + "groups": func() (cli.Command, error) { + return &groups.Command{ + Command: base.NewCommand(ui), + }, nil + }, + "groups create": func() (cli.Command, error) { + return &groups.Command{ + Command: base.NewCommand(ui), + Func: "create", + }, nil + }, + "groups update": func() (cli.Command, error) { + return &groups.Command{ + Command: base.NewCommand(ui), + Func: "update", + }, nil + }, + "groups read": func() (cli.Command, error) { + return &groups.Command{ + Command: base.NewCommand(ui), + Func: "read", + }, nil + }, + "groups delete": func() (cli.Command, error) { + return &groups.Command{ + Command: base.NewCommand(ui), + Func: "delete", + }, nil + }, + "groups list": func() (cli.Command, error) { + return &groups.Command{ + Command: base.NewCommand(ui), + Func: "list", + }, nil + }, + "groups add-members": func() (cli.Command, error) { + return &groups.Command{ + Command: base.NewCommand(ui), + Func: "add-members", + }, nil + }, + "groups set-members": func() (cli.Command, error) { + return &groups.Command{ + Command: base.NewCommand(ui), + Func: "set-members", + }, nil + }, + "groups remove-members": func() (cli.Command, error) { + return &groups.Command{ + Command: base.NewCommand(ui), + Func: "remove-members", + }, nil + }, "hosts create": func() (cli.Command, error) { return &hosts.CreateCommand{ Command: base.NewCommand(ui), }, nil }, + "scopes": func() (cli.Command, error) { + return &scopes.Command{ + Command: base.NewCommand(ui), + }, nil + }, "scopes create": func() (cli.Command, error) { return &scopes.Command{ Command: base.NewCommand(ui), diff --git a/internal/cmd/commands/authenticate/authenticate.go b/internal/cmd/commands/authenticate/authenticate.go index dec005b4a..fde8fcc85 100644 --- a/internal/cmd/commands/authenticate/authenticate.go +++ b/internal/cmd/commands/authenticate/authenticate.go @@ -13,7 +13,7 @@ type Command struct { } func (c *Command) Synopsis() string { - return wordwrap.WrapString("Authenticate the Boundary commandline client", base.TermWidth) + return wordwrap.WrapString("Authenticate the Boundary command-line client", base.TermWidth) } func (c *Command) Help() string { diff --git a/internal/cmd/commands/groups/funcs.go b/internal/cmd/commands/groups/funcs.go new file mode 100644 index 000000000..7ecb72ab8 --- /dev/null +++ b/internal/cmd/commands/groups/funcs.go @@ -0,0 +1,107 @@ +package groups + +import ( + "fmt" + "strings" + "time" + + "github.com/hashicorp/boundary/api/groups" + "github.com/hashicorp/boundary/internal/cmd/base" + "github.com/hashicorp/boundary/internal/cmd/common" + "github.com/hashicorp/boundary/internal/types/resource" + "github.com/mitchellh/go-wordwrap" +) + +func memberSynopsisFunc(inFunc string) string { + var in string + switch { + case strings.HasPrefix(inFunc, "add"): + in = "Add users to" + case strings.HasPrefix(inFunc, "set"): + in = "Set the full contents of the users on" + case strings.HasPrefix(inFunc, "remove"): + in = "Remove users from" + } + return wordwrap.WrapString(fmt.Sprintf("%s a group within Boundary", in), base.TermWidth) +} + +func addMembersHelp() string { + return base.WrapForHelpText([]string{ + "Usage: boundary groups add-members [options] [args]", + "", + ` Adds members (users) to a group given its ID. The "user" flag can be specified multiple times. Example:`, + "", + ` $ boundary groups add-members -id g_1234567890 -user u_1234567890`, + }) +} + +func setMembersHelp() string { + return base.WrapForHelpText([]string{ + "Usage: boundary groups set-members [options] [args]", + "", + ` Sets the complete set of members (users) on a group given its ID. The "user" flag can be specified multiple times. Example:`, + "", + ` $ boundary groups set-principals -id g_1234567890 -user u_anon -user u_1234567890`, + }) +} + +func removeMembersHelp() string { + return base.WrapForHelpText([]string{ + "Usage: boundary groups remove-members [options] [args]", + "", + ` Removes members (users) from a group given its ID. The "user" flag can be specified multiple times. Example:`, + "", + ` $ boundary groups remove-members -id r_1234567890 -user u_1234567890`, + }) +} + +func populateFlags(c *Command, f *base.FlagSet, flagNames []string) { + common.PopulateCommonFlags(c.Command, f, resource.Group, flagNames) + + for _, name := range flagNames { + switch name { + case "member": + f.StringSliceVar(&base.StringSliceVar{ + Name: "member", + Target: &c.flagMembers, + Usage: "The members (users) to add, remove, or set. May be specified multiple times.", + }) + } + } +} + +func generateGroupTableOutput(group *groups.Group) string { + var output []string + if true { + output = []string{ + "", + "Group information:", + fmt.Sprintf(" ID: %s", group.Id), + fmt.Sprintf(" Created At: %s", group.CreatedTime.Local().Format(time.RFC3339)), + fmt.Sprintf(" Updated At: %s", group.UpdatedTime.Local().Format(time.RFC3339)), + fmt.Sprintf(" Version: %d", group.Version), + } + } + if group.Name != "" { + output = append(output, + fmt.Sprintf(" Name: %s", group.Name), + ) + } + if group.Description != "" { + output = append(output, + fmt.Sprintf(" Description: %s", group.Description), + ) + } + if len(group.Members) > 0 { + output = append(output, + fmt.Sprintf(" Members: %s", ""), + ) + } + for _, member := range group.Members { + output = append(output, + fmt.Sprintf(" ID: %s", member.Id), + fmt.Sprintf(" Scope ID: %s", member.ScopeId), + ) + } + return base.WrapForHelpText(output) +} diff --git a/internal/cmd/commands/groups/group.go b/internal/cmd/commands/groups/group.go new file mode 100644 index 000000000..4e2931918 --- /dev/null +++ b/internal/cmd/commands/groups/group.go @@ -0,0 +1,275 @@ +package groups + +import ( + "fmt" + + "github.com/hashicorp/boundary/api" + "github.com/hashicorp/boundary/api/groups" + "github.com/hashicorp/boundary/internal/cmd/base" + "github.com/hashicorp/boundary/internal/cmd/common" + "github.com/hashicorp/boundary/internal/types/resource" + "github.com/hashicorp/vault/sdk/helper/strutil" + "github.com/kr/pretty" + "github.com/mitchellh/cli" + "github.com/posener/complete" +) + +var _ cli.Command = (*Command)(nil) +var _ cli.CommandAutocomplete = (*Command)(nil) + +type Command struct { + *base.Command + + Func string + + flagMembers []string +} + +func (c *Command) Synopsis() string { + switch c.Func { + case "", "create", "update", "read", "delete", "list": + return common.SynopsisFunc(c.Func, "group") + case "add-members", "set-members", "remove-members": + return memberSynopsisFunc(c.Func) + } + return "" +} + +var helpMap = func() map[string]func() string { + ret := common.HelpMap(resource.Group) + ret["add-members"] = addMembersHelp + ret["set-members"] = setMembersHelp + ret["remove-members"] = removeMembersHelp + return ret +} + +var flagsMap = map[string][]string{ + "create": {"name", "description"}, + "update": {"id", "name", "description", "version"}, + "read": {"id"}, + "delete": {"id"}, + "add-members": {"id", "member", "version"}, + "set-members": {"id", "member", "version"}, + "remove-members": {"id", "member", "version"}, +} + +func (c *Command) Help() string { + hm := helpMap() + if c.Func == "" { + return hm["base"]() + } + return hm[c.Func]() + "\n\n" + c.Flags().Help() +} + +func (c *Command) Flags() *base.FlagSets { + set := c.FlagSet(base.FlagSetHTTP | base.FlagSetClient | base.FlagSetOutputFormat) + + f := set.NewFlagSet("Command Options") + + populateFlags(c, f, flagsMap[c.Func]) + return set +} + +func (c *Command) AutocompleteArgs() complete.Predictor { + return complete.PredictAnything +} + +func (c *Command) AutocompleteFlags() complete.Flags { + return c.Flags().Completions() +} + +func (c *Command) Run(args []string) int { + if c.Func == "" { + return cli.RunResultHelp + } + + f := c.Flags() + + if err := f.Parse(args); err != nil { + c.UI.Error(err.Error()) + return 1 + } + + if strutil.StrListContains(flagsMap[c.Func], "id") && c.FlagId == "" { + c.UI.Error("ID is required but not passed in via -id") + return 1 + } + + client, err := c.Client() + if err != nil { + c.UI.Error(fmt.Sprintf("Error creating API client: %s", err.Error())) + return 2 + } + + var opts []groups.Option + + switch c.FlagName { + case "": + case "null": + opts = append(opts, groups.DefaultName()) + default: + opts = append(opts, groups.WithName(c.FlagName)) + } + switch c.FlagDescription { + case "": + case "null": + opts = append(opts, groups.DefaultDescription()) + default: + opts = append(opts, groups.WithDescription(c.FlagDescription)) + } + + members := c.flagMembers + switch c.Func { + case "add-members", "remove-members": + if len(c.flagMembers) == 0 { + c.UI.Error("No members supplied via -member") + return 1 + } + + case "set-members": + switch len(c.flagMembers) { + case 0: + case 1: + if c.flagMembers[0] == "null" { + members = []string{} + } + } + if members == nil { + c.UI.Error("No members supplied via -member") + return 1 + } + } + + groupClient := groups.NewGroupsClient(client) + + // Perform check-and-set when needed + var version uint32 + switch c.Func { + case "create", "read", "delete", "list": + // These don't udpate so don't need the existing version + default: + switch c.FlagVersion { + case 0: + opts = append(opts, groups.WithAutomaticVersioning()) + default: + version = uint32(c.FlagVersion) + } + } + + var existed bool + var group *groups.Group + var listedGroups []*groups.Group + var apiErr *api.Error + + switch c.Func { + case "create": + group, apiErr, err = groupClient.Create(c.Context, opts...) + case "update": + group, apiErr, err = groupClient.Update(c.Context, c.FlagId, version, opts...) + case "read": + group, apiErr, err = groupClient.Read(c.Context, c.FlagId, opts...) + case "delete": + existed, apiErr, err = groupClient.Delete(c.Context, c.FlagId, opts...) + case "list": + listedGroups, apiErr, err = groupClient.List(c.Context, opts...) + case "add-members": + group, apiErr, err = groupClient.AddMembers(c.Context, c.FlagId, version, members, opts...) + case "set-members": + group, apiErr, err = groupClient.SetMembers(c.Context, c.FlagId, version, members, opts...) + case "remove-members": + group, apiErr, err = groupClient.RemoveMembers(c.Context, c.FlagId, version, members, opts...) + } + + plural := "group" + if c.Func == "list" { + plural = "groups" + } + if err != nil { + c.UI.Error(fmt.Sprintf("Error trying to %s %s: %s", c.Func, plural, err.Error())) + return 2 + } + if apiErr != nil { + c.UI.Error(fmt.Sprintf("Error from controller when performing %s on %s: %s", c.Func, plural, pretty.Sprint(apiErr))) + return 1 + } + + switch c.Func { + case "delete": + switch base.Format(c.UI) { + case "json": + c.UI.Output("null") + case "table": + output := "The delete operation completed successfully" + switch existed { + case true: + output += "." + default: + output += ", however the resource did not exist at the time." + } + c.UI.Output(output) + } + return 0 + + case "list": + switch base.Format(c.UI) { + case "json": + if len(listedGroups) == 0 { + c.UI.Output("null") + return 0 + } + b, err := base.JsonFormatter{}.Format(listedGroups) + if err != nil { + c.UI.Error(fmt.Errorf("Error formatting to JSON: %w", err).Error()) + return 1 + } + c.UI.Output(string(b)) + + case "table": + if len(listedGroups) == 0 { + c.UI.Output("No groups found") + return 0 + } + var output []string + output = []string{ + "", + "Group information:", + } + for i, g := range listedGroups { + if i > 0 { + output = append(output, "") + } + if true { + output = append(output, + fmt.Sprintf(" ID: %s", g.Id), + ) + } + if g.Name != "" { + output = append(output, + fmt.Sprintf(" Name: %s", g.Name), + ) + } + if g.Description != "" { + output = append(output, + fmt.Sprintf(" Description: %s", g.Description), + ) + } + } + c.UI.Output(base.WrapForHelpText(output)) + } + return 0 + } + + switch base.Format(c.UI) { + case "table": + c.UI.Output(generateGroupTableOutput(group)) + case "json": + b, err := base.JsonFormatter{}.Format(group) + if err != nil { + c.UI.Error(fmt.Errorf("Error formatting to JSON: %w", err).Error()) + return 1 + } + c.UI.Output(string(b)) + } + + return 0 +} diff --git a/internal/cmd/commands/roles/funcs.go b/internal/cmd/commands/roles/funcs.go index 3cb0e5b1c..d1273919a 100644 --- a/internal/cmd/commands/roles/funcs.go +++ b/internal/cmd/commands/roles/funcs.go @@ -33,9 +33,9 @@ func addPrincipalsHelp() string { return base.WrapForHelpText([]string{ "Usage: boundary roles add-principals [options] [args]", "", - ` Adds principals (users, groups) to a role given its ID. The "user" and "group" flags can be specified multiple times. Example:`, + ` Adds principals (users, groups) to a role given its ID. The "principal" flag can be specified multiple times. Example:`, "", - ` $ boundary roles add-principals -id r_1234567890 -user u_1234567890`, + ` $ boundary roles add-principals -id r_1234567890 -principal u_1234567890`, }) } @@ -43,9 +43,9 @@ func setPrincipalsHelp() string { return base.WrapForHelpText([]string{ "Usage: boundary roles set-principals [options] [args]", "", - ` Sets the complete set of principals (users, groups) on a role given its ID. The "user" and "group" flags can be specified multiple times. Example:`, + ` Sets the complete set of principals (users, groups) on a role given its ID. The "principal" flag can be specified multiple times. Example:`, "", - ` $ boundary roles set-principals -id r_1234567890 -user u_anon -group sg_1234567890`, + ` $ boundary roles set-principals -id r_1234567890 -principal u_anon -principal sg_1234567890`, }) } @@ -53,9 +53,9 @@ func removePrincipalsHelp() string { return base.WrapForHelpText([]string{ "Usage: boundary roles remove-principals [options] [args]", "", - ` Removes principals (users, groups) from a role given its ID. The "user" and "group" flags can be specified multiple times. Example:`, + ` Removes principals (users, groups) from a role given its ID. The "principal" flags can be specified multiple times. Example:`, "", - ` $ boundary roles remove-principals -id r_1234567890 -group sg_1234567890`, + ` $ boundary roles remove-principals -id r_1234567890 -principal sg_1234567890`, }) } diff --git a/internal/cmd/commands/roles/role.go b/internal/cmd/commands/roles/role.go index 2d80dbc63..9ea4825b5 100644 --- a/internal/cmd/commands/roles/role.go +++ b/internal/cmd/commands/roles/role.go @@ -160,7 +160,7 @@ func (c *Command) Run(args []string) int { } } if principals == nil { - c.UI.Error("No principals supplied via -principals") + c.UI.Error("No principals supplied via -principal") return 1 } diff --git a/internal/cmd/main.go b/internal/cmd/main.go index e504a5a11..9abf0e545 100644 --- a/internal/cmd/main.go +++ b/internal/cmd/main.go @@ -199,37 +199,21 @@ func RunCustom(args []string, runOpts *RunOptions) int { return exitCode } -var commonCommands = []string{} - func groupedHelpFunc(f cli.HelpFunc) cli.HelpFunc { return func(commands map[string]cli.CommandFactory) string { var b bytes.Buffer tw := tabwriter.NewWriter(&b, 0, 2, 6, ' ', 0) - fmt.Fprintf(tw, "Usage: boundary [args]\n\n") - fmt.Fprintf(tw, "Common commands:\n") - for _, v := range commonCommands { - printCommand(tw, v, commands[v]) - } + fmt.Fprintf(tw, "Usage: boundary [args]\n") otherCommands := make([]string, 0, len(commands)) for k := range commands { - found := false - for _, v := range commonCommands { - if k == v { - found = true - break - } - } - - if !found { - otherCommands = append(otherCommands, k) - } + otherCommands = append(otherCommands, k) } sort.Strings(otherCommands) fmt.Fprintf(tw, "\n") - fmt.Fprintf(tw, "Other commands:\n") + fmt.Fprintf(tw, "Commands:\n") for _, v := range otherCommands { printCommand(tw, v, commands[v]) } diff --git a/internal/gen/controller.swagger.json b/internal/gen/controller.swagger.json index 74bb4992c..6ac3ae07d 100644 --- a/internal/gen/controller.swagger.json +++ b/internal/gen/controller.swagger.json @@ -2064,11 +2064,6 @@ "description": "The ID of the member.\nOutput only.", "readOnly": true }, - "type": { - "type": "string", - "description": "The type of the member.\nOutput only.", - "readOnly": true - }, "scope_id": { "type": "string", "description": "The scope ID of the member.\nOutput only.", diff --git a/internal/gen/controller/api/resources/groups/group.pb.go b/internal/gen/controller/api/resources/groups/group.pb.go index d196e29f6..174f3979f 100644 --- a/internal/gen/controller/api/resources/groups/group.pb.go +++ b/internal/gen/controller/api/resources/groups/group.pb.go @@ -37,12 +37,9 @@ type Member struct { // The ID of the member. // Output only. Id string `protobuf:"bytes,10,opt,name=id,proto3" json:"id,omitempty"` - // The type of the member. - // Output only. - Type string `protobuf:"bytes,20,opt,name=type,proto3" json:"type,omitempty"` // The scope ID of the member. // Output only. - ScopeId string `protobuf:"bytes,30,opt,name=scope_id,proto3" json:"scope_id,omitempty"` + ScopeId string `protobuf:"bytes,20,opt,name=scope_id,proto3" json:"scope_id,omitempty"` } func (x *Member) Reset() { @@ -84,13 +81,6 @@ func (x *Member) GetId() string { return "" } -func (x *Member) GetType() string { - if x != nil { - return x.Type - } - return "" -} - func (x *Member) GetScopeId() string { if x != nil { return x.ScopeId @@ -245,50 +235,48 @@ var file_controller_api_resources_groups_v1_group_proto_rawDesc = []byte{ 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2a, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x22, 0x48, 0x0a, 0x06, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, - 0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, - 0x79, 0x70, 0x65, 0x18, 0x14, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, - 0x1a, 0x0a, 0x08, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x1e, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x08, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x5f, 0x69, 0x64, 0x22, 0x87, 0x04, 0x0a, 0x05, - 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x43, 0x0a, 0x05, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x18, 0x14, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, - 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, - 0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x63, 0x6f, 0x70, 0x65, 0x49, - 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x12, 0x46, 0x0a, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x1e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, - 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x14, 0xa0, 0xda, 0x29, 0x01, 0xc2, 0xdd, 0x29, 0x0c, - 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x52, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x12, 0x62, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, - 0x6e, 0x18, 0x28, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, - 0x56, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x22, 0xa0, 0xda, 0x29, 0x01, 0xc2, 0xdd, 0x29, 0x1a, 0x0a, - 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0b, 0x64, 0x65, - 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, - 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3e, 0x0a, 0x0c, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x32, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, - 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0c, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x3e, 0x0a, 0x0c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x3c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, - 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, - 0x6e, 0x18, 0x46, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x12, 0x1d, 0x0a, 0x0a, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x50, - 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x49, 0x64, 0x73, 0x12, - 0x44, 0x0a, 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x18, 0x5a, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x2a, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, - 0x69, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, - 0x70, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x07, 0x6d, 0x65, - 0x6d, 0x62, 0x65, 0x72, 0x73, 0x42, 0x53, 0x5a, 0x51, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x62, 0x6f, - 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, - 0x67, 0x65, 0x6e, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x61, - 0x70, 0x69, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x67, 0x72, 0x6f, - 0x75, 0x70, 0x73, 0x3b, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x6f, 0x22, 0x34, 0x0a, 0x06, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, + 0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x73, + 0x63, 0x6f, 0x70, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x14, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, + 0x63, 0x6f, 0x70, 0x65, 0x5f, 0x69, 0x64, 0x22, 0x87, 0x04, 0x0a, 0x05, 0x47, 0x72, 0x6f, 0x75, + 0x70, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, + 0x64, 0x12, 0x43, 0x0a, 0x05, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x18, 0x14, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x2d, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, + 0x69, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x63, 0x6f, 0x70, + 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x63, 0x6f, 0x70, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, + 0x05, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x12, 0x46, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x1e, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, + 0x75, 0x65, 0x42, 0x14, 0xa0, 0xda, 0x29, 0x01, 0xc2, 0xdd, 0x29, 0x0c, 0x0a, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x12, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x62, + 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x28, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, + 0x65, 0x42, 0x22, 0xa0, 0xda, 0x29, 0x01, 0xc2, 0xdd, 0x29, 0x1a, 0x0a, 0x0b, 0x64, 0x65, 0x73, + 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x12, 0x3e, 0x0a, 0x0c, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x74, 0x69, + 0x6d, 0x65, 0x18, 0x32, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0c, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x74, 0x69, + 0x6d, 0x65, 0x12, 0x3e, 0x0a, 0x0c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x74, 0x69, + 0x6d, 0x65, 0x18, 0x3c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x74, 0x69, + 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x46, 0x20, + 0x01, 0x28, 0x0d, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, + 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x50, 0x20, 0x03, 0x28, 0x09, + 0x52, 0x09, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x49, 0x64, 0x73, 0x12, 0x44, 0x0a, 0x07, 0x6d, + 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x18, 0x5a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x63, + 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x72, 0x65, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x2e, 0x76, + 0x31, 0x2e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, + 0x73, 0x42, 0x53, 0x5a, 0x51, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x68, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, + 0x72, 0x79, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x67, 0x65, 0x6e, 0x2f, + 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x72, + 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x3b, + 0x67, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/internal/iam/group_member.go b/internal/iam/group_member.go index 1242f5384..4d31d5aad 100644 --- a/internal/iam/group_member.go +++ b/internal/iam/group_member.go @@ -9,7 +9,9 @@ import ( "google.golang.org/protobuf/proto" ) -// MemberType defines the possible membership types for groups. +// MemberType defines the possible membership types for groups. We don't surface +// this in the API as of yet as it's always user and we don't have plans for +// others currently. type MemberType uint32 const ( diff --git a/internal/proto/local/controller/api/resources/groups/v1/group.proto b/internal/proto/local/controller/api/resources/groups/v1/group.proto index 4e8f93c7d..c74f61990 100644 --- a/internal/proto/local/controller/api/resources/groups/v1/group.proto +++ b/internal/proto/local/controller/api/resources/groups/v1/group.proto @@ -14,13 +14,9 @@ message Member { // Output only. string id = 10; - // The type of the member. - // Output only. - string type = 20; - // The scope ID of the member. // Output only. - string scope_id = 30 [json_name="scope_id"]; + string scope_id = 20 [json_name="scope_id"]; } // Group contains all fields related to a Group resource diff --git a/internal/servers/controller/handlers/groups/group_service.go b/internal/servers/controller/handlers/groups/group_service.go index 1cddca155..845e32179 100644 --- a/internal/servers/controller/handlers/groups/group_service.go +++ b/internal/servers/controller/handlers/groups/group_service.go @@ -360,7 +360,6 @@ func toProto(in *iam.Group, members []*iam.GroupMember) *pb.Group { out.MemberIds = append(out.MemberIds, m.GetMemberId()) out.Members = append(out.Members, &pb.Member{ Id: m.GetMemberId(), - Type: m.GetType(), ScopeId: m.GetMemberScopeId(), }) } diff --git a/internal/servers/controller/handlers/groups/group_service_test.go b/internal/servers/controller/handlers/groups/group_service_test.go index 8094e02a5..a3d84d3e4 100644 --- a/internal/servers/controller/handlers/groups/group_service_test.go +++ b/internal/servers/controller/handlers/groups/group_service_test.go @@ -100,7 +100,6 @@ func TestGet(t *testing.T) { Members: []*pb.Member{ { Id: u.GetPublicId(), - Type: iam.UserMemberType.String(), ScopeId: u.GetScopeId(), }, }, @@ -118,7 +117,6 @@ func TestGet(t *testing.T) { Members: []*pb.Member{ { Id: u.GetPublicId(), - Type: iam.UserMemberType.String(), ScopeId: u.GetScopeId(), }, }, @@ -590,7 +588,6 @@ func TestUpdate(t *testing.T) { Members: []*pb.Member{ { Id: u.GetPublicId(), - Type: iam.UserMemberType.String(), ScopeId: u.GetScopeId(), }, }, @@ -621,7 +618,6 @@ func TestUpdate(t *testing.T) { Members: []*pb.Member{ { Id: u.GetPublicId(), - Type: iam.UserMemberType.String(), ScopeId: u.GetScopeId(), }, }, @@ -653,7 +649,6 @@ func TestUpdate(t *testing.T) { Members: []*pb.Member{ { Id: u.GetPublicId(), - Type: iam.UserMemberType.String(), ScopeId: u.GetScopeId(), }, }, @@ -685,7 +680,6 @@ func TestUpdate(t *testing.T) { Members: []*pb.Member{ { Id: u.GetPublicId(), - Type: iam.UserMemberType.String(), ScopeId: u.GetScopeId(), }, }, @@ -748,7 +742,6 @@ func TestUpdate(t *testing.T) { Members: []*pb.Member{ { Id: u.GetPublicId(), - Type: iam.UserMemberType.String(), ScopeId: u.GetScopeId(), }, }, @@ -779,7 +772,6 @@ func TestUpdate(t *testing.T) { Members: []*pb.Member{ { Id: u.GetPublicId(), - Type: iam.UserMemberType.String(), ScopeId: u.GetScopeId(), }, }, @@ -810,7 +802,6 @@ func TestUpdate(t *testing.T) { Members: []*pb.Member{ { Id: u.GetPublicId(), - Type: iam.UserMemberType.String(), ScopeId: u.GetScopeId(), }, },