Documentation
¶
Index ¶
- Constants
- type Focus
- func (f *Focus) BackToLandscape() *Focus
- func (f *Focus) BackToProject() *Focus
- func (f *Focus) BackToWorkspaceOrProject() *Focus
- func (f *Focus) ClusterHashID() string
- func (f *Focus) DeepCopy() *Focus
- func (f *Focus) Focus() FocusType
- func (f *Focus) Id(pluginName string) string
- func (f *Focus) IsOnboardingCluster() bool
- func (f *Focus) IsPlatformCluster() bool
- func (f *Focus) Json() string
- func (f *Focus) Notification() string
- func (f *Focus) String() string
- func (f *Focus) ToCluster(cluster string) *Focus
- func (f *Focus) ToLandscape(landscape, cluster string) *Focus
- func (f *Focus) ToMCP(cluster string) *Focus
- func (f *Focus) ToOnboardingCluster(landscape string) *Focus
- func (f *Focus) ToPlatformCluster(landscape string) *Focus
- func (f *Focus) ToProject(project string) *Focus
- func (f *Focus) ToWorkspace(workspace string) *Focus
- type FocusType
- type MCPState
Constants ¶
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 (*Focus) BackToLandscape ¶
func (*Focus) BackToProject ¶
func (*Focus) BackToWorkspaceOrProject ¶
func (*Focus) ClusterHashID ¶
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) Focus ¶
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) IsOnboardingCluster ¶
func (*Focus) IsPlatformCluster ¶
func (*Focus) Json ¶
Json returns a JSON representation of the focus. Panics on error. Returns null if the focus is nil.
func (*Focus) Notification ¶
func (*Focus) String ¶
Yaml returns a YAML representation of the focus. Panics on error. Returns an empty string if the focus is nil.
func (*Focus) ToLandscape ¶
func (*Focus) ToOnboardingCluster ¶
func (*Focus) ToPlatformCluster ¶
func (*Focus) ToWorkspace ¶
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) Load ¶
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.