plugin

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FgRunning   = theme.StatusRunning
	FgSucceeded = theme.StatusSucceeded
	FgPending   = theme.StatusPending
	FgFailed    = theme.StatusFailed
)

Status foreground colors shared by all plugins.

Functions

func HasNameCollision added in v0.3.0

func HasNameCollision(name string) bool

HasNameCollision reports whether more than one plugin has been registered with the given name (i.e. same plural name but different API groups).

func MarshalYAML

func MarshalYAML(obj *unstructured.Unstructured) (render.Content, error)

MarshalYAML serialises an Unstructured object to YAML, stripping noisy fields like metadata.managedFields to match kubectl's default behaviour.

func Register

func Register(p ResourcePlugin)

Register adds a plugin to the global registry.

func RegisterIfAbsent

func RegisterIfAbsent(p ResourcePlugin) bool

RegisterIfAbsent adds a plugin only if its GVR is not already registered. When the GVR is new but another plugin with the same name exists, the plugin is added to byNameAll, byGVR, and ordered (so it appears in All()) but NOT set as the primary byName entry. Returns true only when the plugin becomes the primary entry for its name.

func RenderStatus

func RenderStatus(phase string) string

RenderStatus returns the phase string with foreground color that is compatible with the table selection highlight.

func Reset

func Reset()

Reset clears the global registry. For testing only.

func StyledFg

func StyledFg(text string, c color.Color) string

StyledFg applies a foreground color and resets only the foreground (SGR 39) instead of a full reset (SGR 0). This preserves background colors set by outer styles such as the table selection highlight.

Types

type Column

type Column struct {
	Title string
	Width int
	Flex  bool
}

Column defines a table column.

type DefaultSorter

type DefaultSorter interface {
	DefaultSort() SortPreference
}

DefaultSorter is an optional interface plugins may implement to override the default sort column. If not implemented, NAME ascending is used.

type DrillDowner

type DrillDowner interface {
	DrillDown(obj *unstructured.Unstructured) (ResourcePlugin, []*unstructured.Unstructured)
}

DrillDowner is an optional interface for plugins that show child resources on Enter.

type GoToer

type GoToer interface {
	GoTo(obj *unstructured.Unstructured) (resourceName string, namespace string, ok bool)
}

GoToer is an optional interface for plugins that navigate to a different resource view on Enter.

type Refreshable

type Refreshable interface {
	Refresh(namespace string)
}

Refreshable is an optional interface for SelfPopulating plugins that need to re-fetch data when the namespace changes.

type ResourcePlugin

type ResourcePlugin interface {
	Name() string
	ShortName() string
	GVR() schema.GroupVersionResource
	IsClusterScoped() bool

	Columns() []Column
	Row(obj *unstructured.Unstructured) []string

	YAML(obj *unstructured.Unstructured) (render.Content, error)
	Describe(ctx context.Context, obj *unstructured.Unstructured) (render.Content, error)
}

ResourcePlugin is the contract every resource type must satisfy.

func All

func All() []ResourcePlugin

All returns all registered plugins in registration order.

func AllByName added in v0.3.0

func AllByName(name string) []ResourcePlugin

AllByName returns all plugins registered under a given name, across all API groups. Returns a copy of the internal slice.

func ByGVR

ByGVR looks up a plugin by its GroupVersionResource.

func ByKind

func ByKind(apiVersion, kind string) (ResourcePlugin, bool)

ByKind looks up a plugin by Kubernetes apiVersion and kind, using the discovery index to resolve the GVR first.

func ByName

func ByName(name string) (ResourcePlugin, bool)

ByName looks up a plugin by its name.

func ByQualifiedName added in v0.3.0

func ByQualifiedName(qualified string) (ResourcePlugin, bool)

ByQualifiedName looks up a plugin by a qualified name in the format "name.group/version" (e.g. "certificates.cert-manager.io/v1"). If the input does not contain a "/" it is not a qualified name and the lookup falls through to ByName for backward compatibility.

type SelfPopulating

type SelfPopulating interface {
	Objects() []*unstructured.Unstructured
}

SelfPopulating is an optional interface for plugins that manage their own object list instead of using the k8s.Store informer system. Used by synthetic views like api-resources that don't watch real K8s resources.

type SortPreference

type SortPreference struct {
	Column    string
	Ascending bool
}

SortPreference specifies a plugin's preferred default sort.

type Sortable

type Sortable interface {
	SortValue(obj *unstructured.Unstructured, column string) string
}

Sortable is an optional interface plugins may implement to provide sort keys for their columns. If a plugin does not implement Sortable, ResourceList falls back to built-in defaults for NAME and AGE columns.

The column parameter is always the upper-cased Column.Title (e.g. "STATUS"). Return "" from SortValue to fall back to built-in handling for that column.

type Uncoverable

type Uncoverable interface {
	DescribeUncovered(ctx context.Context, obj *unstructured.Unstructured) (render.Content, error)
}

Uncoverable is an optional interface plugins may implement to provide a describe view with resolved/uncovered environment variable values. The app layer probes for this interface via type assertion.

Jump to

Keyboard shortcuts

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