Documentation
¶
Overview ¶
Package profile provides the CLI subcommand for managing profiles
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ProfileCmd = &cobra.Command{ Use: "profile", Short: "Manage profiles within a mediator control plane", Long: `The medic profile subcommands allows the management of profiles within a mediator controlplane.`, RunE: func(cmd *cobra.Command, args []string) error { return cmd.Usage() }, }
ProfileCmd is the root command for the profile subcommands
View Source
var Profile_createCmd = &cobra.Command{ Use: "create", Short: "Create a profile within a mediator control plane", Long: `The medic profile create subcommand lets you create new profiles 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) } }, RunE: func(cmd *cobra.Command, args []string) error { f := util.GetConfigValue("file", "file", cmd, "").(string) proj := viper.GetString("project") var err error var preader io.Reader if f == "" { return fmt.Errorf("error: file must be set") } if f == "-" { preader = os.Stdin } else { f = filepath.Clean(f) fopen, err := os.Open(f) if err != nil { return fmt.Errorf("error opening file: %w", err) } defer fopen.Close() preader = fopen } conn, err := util.GrpcForCommand(cmd) util.ExitNicelyOnError(err, "Error getting grpc connection") defer conn.Close() client := pb.NewProfileServiceClient(conn) ctx, cancel := util.GetAppContext() defer cancel() p, err := engine.ParseYAML(preader) if err != nil { return fmt.Errorf("error reading profile from file: %w", err) } if proj != "" { if p.Context == nil { p.Context = &pb.Context{} } p.Context.Project = &proj } resp, err := client.CreateProfile(ctx, &pb.CreateProfileRequest{ Profile: p, }) if err != nil { return fmt.Errorf("error creating profile: %w", err) } table := initializeTable(cmd) renderProfileTable(resp.GetProfile(), table) table.Render() return nil }, }
Profile_createCmd represents the profile create command
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.