completion

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

nolint:dupl

nolint:dupl

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CmdCompletionFuncToCobraCompletionFunc

func CmdCompletionFuncToCobraCompletionFunc(c CmdCompletionFunc) func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective)

CmdCompletionFuncToCobraCompletionFunc converts a CmdCompletionFunc into a cobra completion function.

func CompleterToCobraCompletionFunc

func CompleterToCobraCompletionFunc(c Completer) func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective)

CompleterToCobraCompletionFunc converts a Completer into a cobra completion function.

func ListKubeconfigClusterCompletionFunc

func ListKubeconfigClusterCompletionFunc(cmd *cobra.Command) ([]string, error)

ListKubeconfigClusterCompletionFunc knows how to list clusters from the kubeconfig.

func ListKubeconfigContextCompletionFunc

func ListKubeconfigContextCompletionFunc(cmd *cobra.Command) ([]string, error)

ListKubeconfigContextCompletionFunc knows how to list contexts from the kubeconfig.

func MakeCobraCompletionFunc

func MakeCobraCompletionFunc(f Func) func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective)

MakeCobraCompletionFunc converts a Func into a cobra completion function.

func RegisterFlagCompletions

func RegisterFlagCompletions(cmd *cobra.Command, completions []FlagCompletion) error

RegisterFlagCompletions registers all FlagCompletion entries and returns an error if any flag returned an error.

Types

type CmdCompletionFunc

type CmdCompletionFunc func(cmd *cobra.Command) ([]string, error)

CmdCompletionFunc is a completion func that only needs a *cobra.Command.

type Completer

type Completer interface {
	Complete(ctx context.Context, ctrlContext controllercontext.Context, namespace string) ([]string, error)
}

Completer is the interface of Func.

func NewSliceCompleter

func NewSliceCompleter(items any) Completer

NewSliceCompleter is a Completer from a slice of objects.

type FlagCompletion

type FlagCompletion struct {
	FlagName          string
	CompletionFunc    Func
	CmdCompletionFunc CmdCompletionFunc
	Completer         Completer
}

FlagCompletion defines a single flag completion entry.

type Func

type Func func(ctx context.Context, ctrlContext controllercontext.Context, namespace string) ([]string, error)

Func is a completion func, that knows how to return completions.

type ListJobConfigsCompleter

type ListJobConfigsCompleter struct {
	// If specified, overrides the sort function.
	Sort func(a, b *execution.JobConfig) bool

	// If specified, filters out job configs that should not appear in completions.
	Filter func(job *execution.JobConfig) bool

	// If specified, overrides the text formatted in the completion.
	// Use \t to add labels for the completion values.
	Format func(job *execution.JobConfig) string
}

ListJobConfigsCompleter is a Completer that lists job configs.

func (*ListJobConfigsCompleter) Complete

func (c *ListJobConfigsCompleter) Complete(ctx context.Context, ctrlContext controllercontext.Context, namespace string) ([]string, error)

type ListJobsCompleter

type ListJobsCompleter struct {
	// If specified, overrides the sort function.
	Sort func(a, b *execution.Job) bool

	// If specified, filters out jobs that should not appear in completions.
	Filter func(job *execution.Job) bool

	// If specified, overrides the text formatted in the completion.
	// Use \t to add labels for the completion values.
	Format func(job *execution.Job) string
}

ListJobsCompleter is a Completer that lists jobs.

func (*ListJobsCompleter) Complete

func (c *ListJobsCompleter) Complete(ctx context.Context, ctrlContext controllercontext.Context, namespace string) ([]string, error)

type ListNamespacesCompleter

type ListNamespacesCompleter struct {
	// If specified, overrides the sort function.
	Sort func(a, b *corev1.Namespace) bool

	// If specified, filters out job configs that should not appear in completions.
	Filter func(ns *corev1.Namespace) bool

	// If specified, overrides the text formatted in the completion.
	// Use \t to add labels for the completion values.
	Format func(ns *corev1.Namespace) string
}

ListNamespacesCompleter is a Completer that lists job configs.

func (*ListNamespacesCompleter) Complete

func (c *ListNamespacesCompleter) Complete(ctx context.Context, ctrlContext controllercontext.Context, _ string) ([]string, error)

Jump to

Keyboard shortcuts

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