state

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 8 Imported by: 0

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