config

package
v0.0.0-...-73e19b3 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PatternKeyProject is used to identify a Project.
	PatternKeyProject = PatternKey("project")
	// PatternKeyNamespace is used to identify a Project by the namespace it refers to.
	PatternKeyNamespace = PatternKey("namespace")
	// PatternKeyShoot is used to identify a Shoot.
	PatternKeyShoot = PatternKey("shoot")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Filename is the name of the gardenctl configuration file
	Filename string `json:"-"`
	// LinkKubeconfig defines if kubeconfig is symlinked with the target
	LinkKubeconfig *bool `json:"linkKubeconfig,omitempty"`
	// Gardens is a list of known Garden clusters
	Gardens []Garden `json:"gardens"`
}

Config holds the gardenctl configuration.

func LoadFromFile

func LoadFromFile(filename string) (*Config, error)

LoadFromFile parses a gardenctl config file and returns a Config struct.

func (*Config) ClientConfig

func (config *Config) ClientConfig(name string) (clientcmd.ClientConfig, error)

ClientConfig returns a deferred loading client config for a configured garden cluster.

func (*Config) DirectClientConfig

func (config *Config) DirectClientConfig(name string) (clientcmd.ClientConfig, error)

DirectClientConfig returns a directly loaded client config for a configured garden cluster.

func (*Config) Garden

func (config *Config) Garden(name string) (*Garden, error)

Garden returns the matching Garden cluster by name (identity or alias) from the list of configured Gardens. In case of ambigous names the first match is returned and identity is preferred over alias.

func (*Config) GardenNames

func (config *Config) GardenNames() []string

GardenNames returns a slice containing the names of the configured Gardens.

func (*Config) IndexOfGarden

func (config *Config) IndexOfGarden(name string) (int, bool)

IndexOfGarden returns the index of the Garden with the given name in the configured Gardens slice. If no Garden with this name is found it returns -1.

func (*Config) MatchPattern

func (config *Config) MatchPattern(preferredGardenName string, value string) (*PatternMatch, error)

MatchPattern matches a string against patterns defined in gardenctl config. If matched, the function creates and returns a PatternMatch from the provided target string.

func (*Config) Save

func (config *Config) Save() error

Save updates a gardenctl config file with the values passed via Config struct.

func (*Config) SymlinkTargetKubeconfig

func (config *Config) SymlinkTargetKubeconfig() bool

SymlinkTargetKubeconfig indicates if the kubeconfig of the current target should be always symlinked.

type Garden

type Garden struct {
	// Name is a unique identifier of this Garden that can be used to target this Garden
	Name string `json:"identity"`
	// Alias is a unique identifier of this Garden that can be used as an alternate name to target this Garden
	// +optional
	Alias string `json:"name,omitempty"`
	// Kubeconfig holds the path for the kubeconfig of the garden cluster
	Kubeconfig string `json:"kubeconfig"`
	// Context overrides the current-context of the garden cluster kubeconfig
	// +optional
	Context string `json:"context,omitempty"`
	// Patterns is a list of regex patterns that can be defined to use custom input formats for targeting
	// Use named capturing groups to match target values.
	// Supported capturing groups: project, namespace, shoot
	// +optional
	Patterns []string `json:"patterns,omitempty"`
	// AccessRestrictions is a list of access restriction definitions
	// +optional
	AccessRestrictions []ac.AccessRestriction `json:"accessRestrictions,omitempty"`
}

Garden represents one garden cluster.

func (*Garden) LoadRawConfig

func (g *Garden) LoadRawConfig() (*clientcmdapi.Config, error)

LoadRawConfig directly loads the raw config from file, validates the content and removes all the irrelevant pieces.

type PatternKey

type PatternKey string

PatternKey is a key that can be used to identify a value in a pattern.

type PatternMatch

type PatternMatch struct {
	// Garden is the matched Garden
	Garden string
	// Project is the matched Project
	Project string
	// Namespace is the matched Namespace, can be used to find the related project
	Namespace string
	// Shoot is the matched Shoot
	Shoot string
}

PatternMatch holds (target) values extracted from a provided string.

Jump to

Keyboard shortcuts

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