state

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MCPClusterOnboarding = "<onboarding>"
	MCPClusterPlatform   = "<platform>"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Focus

type Focus struct {
	Landscape string `json:"landscape"`
	Cluster   string `json:"cluster,omitempty"`
	Project   string `json:"project,omitempty"`
	Workspace string `json:"workspace,omitempty"`
}

func NewEmptyFocus

func NewEmptyFocus() *Focus

func NewFocus

func NewFocus(landscape, project, workspace, cluster string) *Focus

NewFocus creates a new focus.

func (*Focus) BackToLandscape

func (f *Focus) BackToLandscape() *Focus

func (*Focus) BackToProject

func (f *Focus) BackToProject() *Focus

func (*Focus) BackToWorkspaceOrProject

func (f *Focus) BackToWorkspaceOrProject() *Focus

func (*Focus) ClusterHashID

func (f *Focus) ClusterHashID() string

ClusterHashID returns a hash representing the cluster of the focus. This returns '<onboarding>' or '<platform>' if the focus is Landscape, the hash id, if the focus is Cluster or MCP, and an empty string otherwise. Note that the ID is only unique within a given landscape.

func (*Focus) DeepCopy

func (f *Focus) DeepCopy() *Focus

func (*Focus) Focus

func (f *Focus) Focus() FocusType

Focus returns the type of the current focus. This is computed based on the fields that are set (= not an empty string). - Landscape + Cluster (<onboarding> or <platform>): landscape - Landscape + Cluster (other): cluster - Landscape + Project: project - Landscape + Project + Workspace: worksapce - Landscape + Project + Workspace + Cluster: mcp - Otherwise: unknown

func (*Focus) Id

func (f *Focus) Id(pluginName string) string

func (*Focus) IsOnboardingCluster

func (f *Focus) IsOnboardingCluster() bool

func (*Focus) IsPlatformCluster

func (f *Focus) IsPlatformCluster() bool

func (*Focus) Json

func (f *Focus) Json() string

Json returns a JSON representation of the focus. Panics on error. Returns null if the focus is nil.

func (*Focus) Notification

func (f *Focus) Notification() string

func (*Focus) String

func (f *Focus) String() string

Yaml returns a YAML representation of the focus. Panics on error. Returns an empty string if the focus is nil.

func (*Focus) ToCluster

func (f *Focus) ToCluster(cluster string) *Focus

func (*Focus) ToLandscape

func (f *Focus) ToLandscape(landscape, cluster string) *Focus

func (*Focus) ToMCP

func (f *Focus) ToMCP(cluster string) *Focus

func (*Focus) ToOnboardingCluster

func (f *Focus) ToOnboardingCluster(landscape string) *Focus

func (*Focus) ToPlatformCluster

func (f *Focus) ToPlatformCluster(landscape string) *Focus

func (*Focus) ToProject

func (f *Focus) ToProject(project string) *Focus

func (*Focus) ToWorkspace

func (f *Focus) ToWorkspace(workspace string) *Focus

type FocusType

type FocusType string
const (
	FocusTypeLandscape FocusType = "landscape"
	FocusTypeProject   FocusType = "project"
	FocusTypeWorkspace FocusType = "workspace"
	FocusTypeMCP       FocusType = "mcp"
	FocusTypeCluster   FocusType = "cluster"
	FocusTypeUnknown   FocusType = "unknown"
)

func (FocusType) Short

func (ft FocusType) Short() string

type MCPState

type MCPState struct {
	Focus                       *Focus `json:"focus"`
	PlatformClusterKubeconfig   []byte `json:"platformClusterKubeconfig,omitempty"`   // holds the kubeconfig of the platform cluster, if it has already been fetched
	OnboardingClusterKubeconfig []byte `json:"onboardingClusterKubeconfig,omitempty"` // holds the kubeconfig of the onboarding cluster, if it has already been fetched
}

func DetermineMCPStateFromRawState

func DetermineMCPStateFromRawState(con *libcontext.Context, cfg *config.MCPConfig, rawState *libstate.State) (*MCPState, error)

DetermineMCPStateFromRawState takes the raw kubeswitcher state and tries to determine the MCP state from it based on the plugin that handled the last command and the content of the plugin state. If the state was handled by this plugin, it is loaded directly. If the state was handled by the garden plugin, it is inferred from the garden state based on the Gardener landscape and project targeted in the last command as well as the mapping of Gardener projects to MCP landscapes specified in the config. If the state was handled by the kind plugin, it is inferred from the kind state based on the targeted kind cluster and the mapping of kind clusters to MCP landscapes specified in the config. If the state was handled by the builtin custom command, it is inferred from the kubeconfig path and content of the currently selected cluster and the kubeconfig paths and contents specified in the config for the platform and onboarding cluster of each landscape. If the state was handled by any other plugin or if inferring the state from the garden or kind plugin state fails, nil is returned. This should return an error only its own state cannot be loaded, not if something goes wrong while trying to infer the state from other plugins' states, since the latter is just an optimization and not critical for correctness.

func (*MCPState) DeepCopy

func (s *MCPState) DeepCopy() *MCPState

func (*MCPState) Id

func (s *MCPState) Id(pluginName string) string

func (*MCPState) Load

func (s *MCPState) Load(con *libcontext.Context, cfg *config.MCPConfig) (bool, error)

Load fills the receiver state object with the data from the kubeswitcher state. The first return value is true if any state was actually loaded, false otherwise.

func (*MCPState) Notification

func (s *MCPState) Notification() string

func (*MCPState) YAML

func (s *MCPState) YAML() ([]byte, error)

String returns a YAML representation of the state.

Jump to

Keyboard shortcuts

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