state

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: MIT Imports: 8 Imported by: 4 modules, 3 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteGenericState

func WriteGenericState(path string, lastCommand string, lastPlugin string) error

WriteGenericState builds a GenericState object from the given parameters and writes it to the given path as json.

Types

type GenericState

type GenericState struct {
	// LastUsed holds information about the last used kubeswitcher command
	LastUsed *LastUsed `json:"lastUsed,omitempty"`
}

type LastUsed

type LastUsed struct {
	// Command is the last used command
	Command string `json:"command,omitempty"`
	// Plugin is the name of the plugin that handled the last command
	Plugin string `json:"plugin,omitempty"`
}

LastUsed holds information about the last used kubeswitcher command

type State

type State struct {
	GenericState `json:"genericState"`
	// RawPluginState holds the plugin-specific state.
	// As this needs to be parsed by the plugin itself, the file is just read and dumped into this field.
	RawPluginState []byte `json:"pluginState"`
	// contains filtered or unexported fields
}

State holds information about the current state. This is stored in files between command calls and contains information like the last used command.

func LoadState

func LoadState(genericStatePath, pluginStatePath string) (*State, error)

LoadState reads the state from the given files.

func (*State) Reload

func (s *State) Reload() error

Reload updates the state object with the current state from the files.

type TypedState

type TypedState[T any] struct {
	*State
	PluginState T
}

func LoadTypedState

func LoadTypedState[T any](genericStatePath, pluginStatePath, expectedPluginName string) (*TypedState[T], error)

LoadTypedState loads the state and then attempts to unmarshal the plugin state into the given type. If expectedPluginName is non-empty, the function will throw an StateFromAnotherPluginError if the last used plugin differs from the expected one.

Jump to

Keyboard shortcuts

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