Documentation ¶
Index ¶
- Variables
- func GetCommandFlagHandler(command *cobra.Command, flag string) (predictor complete.Predictor, ok bool)
- func GetCommandHandler(command *cobra.Command) (predictor complete.Predictor, ok bool)
- func NewParsedArgs(args complete.Args, cmd *cobra.Command) parsedArgs
- func RegisterCommandFlagHandler(command *cobra.Command, flag string, predictor ContextualizedPredictor)
- func RegisterCommandHandler(command *cobra.Command, predictor ContextualizedPredictor)
- type ContextualizedPredictor
Constants ¶
This section is empty.
Variables ¶
var AppCompletionHandler = func(cmd *cobra.Command, args parsedArgs, context *genericclioptions.Context) (completions []string) { completions = make([]string, 0) applications, err := application.List(context.Client) if err != nil { return completions } for _, app := range applications { if args.commands[app.Name] { return nil } completions = append(completions, app.Name) } return }
AppCompletionHandler provides completion for the app commands
var ComponentNameCompletionHandler = func(cmd *cobra.Command, args parsedArgs, context *genericclioptions.Context) (completions []string) { completions = make([]string, 0) components, err := component.List(context.Client, context.Application) if err != nil { return completions } for _, component := range components { if args.commands[component.Name] { return nil } completions = append(completions, component.Name) } return completions }
ComponentNameCompletionHandler provides component name completion
var CreateCompletionHandler = func(cmd *cobra.Command, args parsedArgs, context *genericclioptions.Context) (completions []string) { completions = make([]string, 0) catalogList, err := catalog.List(context.Client) if err != nil { return completions } for _, builder := range catalogList { if args.commands[builder.Name] { return nil } completions = append(completions, builder.Name) } return completions }
CreateCompletionHandler provides componet type completion in odo create command
var FileCompletionHandler = func(cmd *cobra.Command, args parsedArgs, context *genericclioptions.Context) (completions []string) { completions = append(completions, complete.PredictFiles("*").Predict(args.original)...) return }
FileCompletionHandler provides suggestions for files and directories
var LinkCompletionHandler = func(cmd *cobra.Command, args parsedArgs, context *genericclioptions.Context) (completions []string) { completions = make([]string, 0) components, err := component.List(context.Client, context.Application) if err != nil { return completions } services, err := service.List(context.Client, context.Application) if err != nil { return completions } for _, component := range components { if val, ok := args.commands[component.Name]; ok && val { return nil } if component.Name != context.Component() { completions = append(completions, component.Name) } } for _, service := range services { if val, ok := args.commands[service.Name]; ok && val { return nil } completions = append(completions, service.Name) } return completions }
LinkCompletionHandler provides completion for the odo link The function returns both components and services
var ProjectNameCompletionHandler = func(cmd *cobra.Command, args parsedArgs, context *genericclioptions.Context) (completions []string) { completions = make([]string, 0) projects, err := project.List(context.Client) if err != nil { return completions } for _, project := range projects { if args.commands[project.Name] { return nil } completions = append(completions, project.Name) } return completions }
ProjectNameCompletionHandler provides project name completion
var ServiceClassCompletionHandler = func(cmd *cobra.Command, args parsedArgs, context *genericclioptions.Context) (completions []string) { completions = make([]string, 0) services, err := context.Client.GetClusterServiceClasses() if err != nil { complete.Log("error retrieving services") return completions } complete.Log(fmt.Sprintf("found %d services", len(services))) for _, class := range services { if args.commands[class.Spec.ExternalName] { return nil } completions = append(completions, class.Spec.ExternalName) } return }
ServiceClassCompletionHandler provides catalog service class name completion
var ServiceCompletionHandler = func(cmd *cobra.Command, args parsedArgs, context *genericclioptions.Context) (completions []string) { completions = make([]string, 0) services, err := service.List(context.Client, context.Application) if err != nil { return completions } for _, class := range services { if args.commands[class.Name] { return nil } completions = append(completions, class.Name) } return }
ServiceCompletionHandler provides service name completion for the current project and application
var ServiceParameterCompletionHandler = func(cmd *cobra.Command, args parsedArgs, context *genericclioptions.Context) (completions []string) { completions = make([]string, 0) if len(args.original.Completed) < 2 { complete.Log("Couldn't extract the service name") return completions } inputServiceName := args.original.Completed[1] inputPlanName := args.flagValues["plan"] complete.Log(fmt.Sprintf("Using input: serviceName = %s, servicePlan = %s", inputServiceName, inputPlanName)) _, servicePlans, err := service.GetServiceClassAndPlans(context.Client, inputServiceName) if err != nil { complete.Log("Error retrieving details of service") return completions } var matchingServicePlan *service.ServicePlan = nil if len(servicePlans) == 0 { complete.Log("Service has no plans so no parameters can be found") return completions } else if len(servicePlans) == 1 && inputPlanName == "" { matchingServicePlan = &servicePlans[0] } else { for _, servicePlan := range servicePlans { if servicePlan.Name == inputPlanName { matchingServicePlan = &servicePlan break } } if matchingServicePlan == nil { complete.Log("No service plan for the service matched the supplied plan name") return completions } } alreadyAddedParameters := args.flagValues["parameters"] for _, servicePlanParameter := range matchingServicePlan.Parameters { if !strings.Contains(alreadyAddedParameters, servicePlanParameter.Name) { completions = append(completions, servicePlanParameter.Name) } } return completions }
ServiceParameterCompletionHandler provides completion for the parameter names of a selected service and plan
var ServicePlanCompletionHandler = func(cmd *cobra.Command, args parsedArgs, context *genericclioptions.Context) (completions []string) { completions = make([]string, 0) if len(args.original.Completed) < 2 { complete.Log("Couldn't extract the service name") return completions } inputServiceName := args.original.Completed[1] complete.Log(fmt.Sprintf("Using input: serviceName = %s", inputServiceName)) clusterServiceClass, err := context.Client.GetClusterServiceClass(inputServiceName) if err != nil { complete.Log("Error retrieving details of service") return completions } servicePlans, err := context.Client.GetClusterPlansFromServiceName(clusterServiceClass.Name) if err != nil { complete.Log("Error retrieving details of plans of service") return completions } for _, servicePlan := range servicePlans { completions = append(completions, servicePlan.Spec.ExternalName) } return completions }
ServicePlanCompletionHandler provides completion for the the plan of a selected service
var StorageDeleteCompletionHandler = func(cmd *cobra.Command, args parsedArgs, context *genericclioptions.Context) (completions []string) { completions = make([]string, 0) storages, err := storage.List(context.Client, context.Component(), context.Application) if err != nil { return completions } for _, storage := range storages { if args.commands[storage.Name] { return nil } completions = append(completions, storage.Name) } return completions }
StorageDeleteCompletionHandler provides storage name completion for storage delete
var StorageMountCompletionHandler = func(cmd *cobra.Command, args parsedArgs, context *genericclioptions.Context) (completions []string) { completions = make([]string, 0) storages, err := storage.ListUnmounted(context.Client, context.Application) if err != nil { return completions } for _, storage := range storages { if args.commands[storage.Name] { return nil } completions = append(completions, storage.Name) } return completions }
StorageMountCompletionHandler provides storage name completion for storage mount
var StorageUnMountCompletionHandler = func(cmd *cobra.Command, args parsedArgs, context *genericclioptions.Context) (completions []string) { completions = make([]string, 0) storages, err := storage.ListMounted(context.Client, context.Component(), context.Application) if err != nil { return completions } for _, storage := range storages { if args.commands[storage.Name] { return nil } completions = append(completions, storage.Name) } return completions }
StorageUnMountCompletionHandler provides storage name completion for storage unmount
var URLCompletionHandler = func(cmd *cobra.Command, args parsedArgs, context *genericclioptions.Context) (completions []string) { completions = make([]string, 0) urls, err := url.List(context.Client, context.Component(), context.Application) if err != nil { return completions } for _, url := range urls { if args.commands[url.Name] { return nil } completions = append(completions, url.Name) } return }
URLCompletionHandler provides completion for the url commands
var UnlinkCompletionHandler = func(cmd *cobra.Command, args parsedArgs, context *genericclioptions.Context) (completions []string) { completions = make([]string, 0) dcOfCurrentComponent, err := getDCOfComponent(context) if err != nil || dcOfCurrentComponent == nil { return completions } components, err := component.List(context.Client, context.Application) if err != nil { return completions } services, err := service.List(context.Client, context.Application) if err != nil { return completions } for _, component := range components { if val, ok := args.commands[component.Name]; ok && val { return nil } if component.Name != context.Component() { for _, envFromSourceName := range dcOfCurrentComponent.Spec.Template.Spec.Containers[0].EnvFrom { if strings.Contains(envFromSourceName.SecretRef.Name, component.Name) { completions = append(completions, component.Name) } } } } for _, service := range services { if val, ok := args.commands[service.Name]; ok && val { return nil } for _, envFromSourceName := range dcOfCurrentComponent.Spec.Template.Spec.Containers[0].EnvFrom { if strings.Contains(envFromSourceName.SecretRef.Name, service.Name) { completions = append(completions, service.Name) } } } return completions }
LinkCompletionHandler provides completion for the odo link The function returns both components and services
Functions ¶
func GetCommandFlagHandler ¶
func GetCommandFlagHandler(command *cobra.Command, flag string) (predictor complete.Predictor, ok bool)
GetCommandFlagHandler retrieves the command handler associated with the specified flag of the specified command or nil otherwise
func GetCommandHandler ¶
GetCommandHandler retrieves the command handler associated with the specified command or nil otherwise
func NewParsedArgs ¶ added in v0.0.16
NewParsedArgs creates a parsed representation of the provided arguments for the specified command. Mostly exposed for tests.
func RegisterCommandFlagHandler ¶
func RegisterCommandFlagHandler(command *cobra.Command, flag string, predictor ContextualizedPredictor)
RegisterCommandFlagHandler registers the provided ContextualizedPredictor as a completion handler for the specified flag of the specified command
func RegisterCommandHandler ¶
func RegisterCommandHandler(command *cobra.Command, predictor ContextualizedPredictor)
RegisterCommandHandler registers the provided ContextualizedPredictor as a completion handler for the specified command
Types ¶
type ContextualizedPredictor ¶
type ContextualizedPredictor func(cmd *cobra.Command, args parsedArgs, context *genericclioptions.Context) []string
ContextualizedPredictor predicts completion based on specified arguments, potentially using the context provided by the specified client to resolve the entities to be completed