group

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package group contains the group logic for the control plane

Index

Constants

This section is empty.

Variables

View Source
var GroupCmd = &cobra.Command{
	Use:   "group",
	Short: "Manage groups within a mediator control plane",
	Long: `The medic group commands allow the management of groups within a 
mediator control plane.`,
	RunE: func(cmd *cobra.Command, args []string) error {
		return cmd.Usage()
	},
}

GroupCmd is the root command for the group subcommands

View Source
var Group_createCmd = &cobra.Command{
	Use:   "create",
	Short: "Create a group within a mediator control plane",
	Long: `The medic group create subcommand lets you create new groups 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) {

		name := util.GetConfigValue("name", "name", cmd, "")
		description := util.GetConfigValue("description", "description", cmd, "")
		organization := util.GetConfigValue("org-id", "org-id", cmd, int32(0)).(int32)
		isProtected := viper.GetBool("is_protected")

		conn, err := util.GrpcForCommand(cmd)
		util.ExitNicelyOnError(err, "Error getting grpc connection")
		defer conn.Close()

		client := pb.NewGroupServiceClient(conn)
		ctx, cancel := util.GetAppContext()
		defer cancel()

		protectedPtr := &isProtected

		resp, err := client.CreateGroup(ctx, &pb.CreateGroupRequest{
			Name:           name.(string),
			Description:    description.(string),
			OrganizationId: organization,
			IsProtected:    protectedPtr,
		})
		util.ExitNicelyOnError(err, "Error creating group")
		out, err := util.GetJsonFromProto(resp)
		util.ExitNicelyOnError(err, "Error getting json from proto")
		fmt.Println(out)
	},
}

Group_createCmd is the command for creating a group

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL