Documentation
¶
Overview ¶
Package role provides the cli subcommands for managing roles within a mediator control plane
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var RoleCmd = &cobra.Command{ Use: "role", Short: "Manage roles within a mediator control plane", Long: `The medic role subcommands allows the management of roles within a mediator controlplane.`, RunE: func(cmd *cobra.Command, args []string) error { return cmd.Usage() }, }
RoleCmd is the root command for the role subcommands
View Source
var Role_createCmd = &cobra.Command{ Use: "create", Short: "Create a role within a mediator control plane", Long: `The medic role create subcommand lets you create new roles for a project within a mediator control plane.`, PreRun: func(cmd *cobra.Command, args []string) { if err := viper.BindPFlags(cmd.Flags()); err != nil { fmt.Fprintf(os.Stderr, "Error binding flags: %s\n", err) } }, Run: func(cmd *cobra.Command, args []string) { org := viper.GetString("org-id") project := viper.GetString("project-id") name := util.GetConfigValue("name", "name", cmd, "") isAdmin := viper.GetBool("is_admin") isProtected := viper.GetBool("is_protected") conn, err := util.GrpcForCommand(cmd) util.ExitNicelyOnError(err, "Error getting grpc connection") defer conn.Close() util.ExitNicelyOnError(err, "Error getting grpc connection") client := pb.NewRoleServiceClient(conn) ctx, cancel := util.GetAppContext() defer cancel() adminPtr := &isAdmin protectedPtr := &isProtected if project == "" { resp, err := client.CreateRoleByOrganization(ctx, &pb.CreateRoleByOrganizationRequest{ OrganizationId: org, Name: name.(string), IsAdmin: adminPtr, IsProtected: protectedPtr, }) util.ExitNicelyOnError(err, "Error creating role") out, err := util.GetJsonFromProto(resp) util.ExitNicelyOnError(err, "Error getting json from proto") fmt.Println(out) } else { resp, err := client.CreateRoleByProject(ctx, &pb.CreateRoleByProjectRequest{ OrganizationId: org, ProjectId: project, Name: name.(string), IsAdmin: adminPtr, IsProtected: protectedPtr, }) util.ExitNicelyOnError(err, "Error creating role") out, err := util.GetJsonFromProto(resp) util.ExitNicelyOnError(err, "Error getting json from proto") fmt.Println(out) } }, }
Role_createCmd represents the role create command
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.