kubectlplugin

package
v0.0.0-...-b1ade4b Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

package kubectlplugin contains helpers for building kubectl plugins.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

This section is empty.

Variables

View Source
var ResourceKindColumn = Column{
	Name:        "Kind",
	Description: "Kubernetes resource kind",
}

Functions

func As

func As[T any](object runtime.Object) T

Types

type CobraOpts

type CobraOpts func(*cobra.Command)

func WithArgs

func WithArgs(args cobra.PositionalArgs, validArgs []string) CobraOpts

func WithVersion

func WithVersion(version string) CobraOpts

type Column

type Column struct {
	Name        string
	Description string
}

type ConfigFlags

func NewConfigFlags

func NewConfigFlags() *ConfigFlags

func (*ConfigFlags) AddFlags

func (f *ConfigFlags) AddFlags(cmd *cobra.Command)

func (*ConfigFlags) ToPrinter

func (f *ConfigFlags) ToPrinter() (printers.ResourcePrinter, error)

type Handler

type Handler func(args HandlerArgs) (runtime.Object, error)

type HandlerArgs

type HandlerArgs struct {
	Runner
	Cmd  *cobra.Command
	Args []string
}

func (HandlerArgs) ToResourceFinder

func (a HandlerArgs) ToResourceFinder(resources ...string) genericclioptions.ResourceFinder

type Runner

type Runner struct {
	ConfigFlags *ConfigFlags

	KubeApi      kubernetes.Interface
	DiscoveryApi discovery.DiscoveryInterface
	DynamicApi   dynamic.Interface
	// contains filtered or unexported fields
}

func NewRunner

func NewRunner(handler Handler, opts ...RunnerOpts) *Runner

func (*Runner) GetAllServerResources

func (r *Runner) GetAllServerResources() ([]schema.GroupVersionResource, error)

func (*Runner) ToCobraCommand

func (r *Runner) ToCobraCommand(use, short string, opts ...CobraOpts) *cobra.Command

type RunnerOpts

type RunnerOpts func(*Runner)

func WithAllNamespaces

func WithAllNamespaces() RunnerOpts

func WithDefaultDiscoveryApi

func WithDefaultDiscoveryApi() RunnerOpts

func WithDefaultKubeApi

func WithDefaultKubeApi() RunnerOpts

func WithDiscoveryApiV2

func WithDiscoveryApiV2(discoveryApi discovery.DiscoveryInterface, dynamicApi dynamic.Interface) RunnerOpts

func WithKubeApi

func WithKubeApi(kubeApi kubernetes.Interface) RunnerOpts

func WithResourcePrinters

func WithResourcePrinters() RunnerOpts

func WithTablePrinter

func WithTablePrinter() RunnerOpts

type TableBuilder

type TableBuilder struct {
	Table metaV1.Table
	// contains filtered or unexported fields
}

func NewTableBuilder

func NewTableBuilder() *TableBuilder

func (*TableBuilder) AddRow

func (tb *TableBuilder) AddRow(object runtime.Object, cells map[string]any)

func (*TableBuilder) AdditionalColumns

func (tb *TableBuilder) AdditionalColumns(columns ...Column) *TableBuilder

Directories

Path Synopsis
package testing contains helpers for testing kubectl plugins built with kubectlplugin.
package testing contains helpers for testing kubectl plugins built with kubectlplugin.

Jump to

Keyboard shortcuts

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