project

package
v0.0.5 Latest Latest
Warning

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

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

Documentation

Overview

Package project contains the project logic for the control plane

Index

Constants

This section is empty.

Variables

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

ProjectCmd is the root command for the project subcommands

View Source
var Project_createCmd = &cobra.Command{
	Use:   "create",
	Short: "Create a project within a mediator control plane",
	Long: `The medic project create subcommand lets you create new projects 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 := viper.GetString("org-id")
		isProtected := viper.GetBool("is_protected")

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

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

		protectedPtr := &isProtected

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

Project_createCmd is the command for creating a project

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