org

package
v0.0.6 Latest Latest
Warning

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

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

Documentation

Overview

Package org contains the organization logic for the control plane

Index

Constants

This section is empty.

Variables

View Source
var OrgCmd = &cobra.Command{
	Use:   "org",
	Short: "Manage organizations within a mediator control plane",
	Long: `The medic org commands manage organizations within a mediator
control plane.`,
	RunE: func(cmd *cobra.Command, args []string) error {
		return cmd.Usage()
	},
}

OrgCmd is the root command for the org subcommands

View Source
var Org_createCmd = &cobra.Command{
	Use:   "create",
	Short: "Create an organization within a mediator control plane",
	Long: `The medic org create subcommand lets you create new organizations
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, "")
		company := util.GetConfigValue("company", "company", cmd, "")
		create := util.GetConfigValue("create-default-records", "create-default-records", cmd, false)

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

		util.ExitNicelyOnError(err, "Error getting grpc connection")

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

		resp, err := client.CreateOrganization(ctx, &pb.CreateOrganizationRequest{
			Name:                 name.(string),
			Company:              company.(string),
			CreateDefaultRecords: create.(bool),
		})
		util.ExitNicelyOnError(err, "Error creating organization")

		out, err := util.GetJsonFromProto(resp)
		util.ExitNicelyOnError(err, "Error getting json from proto")
		fmt.Println(out)
	},
}

Org_createCmd is the command for creating an organization

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