store

package
v0.0.0-...-fe26432 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 56 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CmNameClusterIdentity is the config map name that contains the gardener cluster identity
	CmNameClusterIdentity = "cluster-identity"
	// KeyClusterIdentity is the key in the cluster identity config map
	KeyClusterIdentity = CmNameClusterIdentity
	// AllNamespacesDenominator is a character that indicates that all Shoot clusters should be considered for the search
	AllNamespacesDenominator = "/"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AWSLogrusBridgeLogger

type AWSLogrusBridgeLogger struct {
	Logger *logrus.Entry
}

AWSLogrusBridgeLogger is a Logger implementation that wraps the standard library logger, and delegates logging to it's Printf method.

func (AWSLogrusBridgeLogger) Logf

func (s AWSLogrusBridgeLogger) Logf(classification logging.Classification, format string, v ...interface{})

Logf logs the given classification and message to the underlying logger.

type AzureStore

type AzureStore struct {
	Logger *logrus.Entry
	// DiscoveredClustersMutex is a mutex allow many reads, one write mutex to synchronize writes
	// to the DiscoveredClusters map.
	// This can happen when a goroutine still discovers clusters while another goroutine computes the preview for a missing cluster.
	DiscoveredClustersMutex sync.RWMutex
	KubeconfigStore         types.KubeconfigStore
	AksClient               *armcontainerservice.ManagedClustersClient
	Config                  *types.StoreConfigAzure
	// DiscoveredClusters maps the kubeconfig path (az_<resource-group>--<cluster-name>) -> cluster
	// This is a cache for the clusters discovered during the initial search for kubeconfig paths
	// when not using a search index
	DiscoveredClusters map[string]*armcontainerservice.ManagedCluster
	StateDirectory     string
}

func NewAzureStore

func NewAzureStore(store types.KubeconfigStore, stateDir string) (*AzureStore, error)

NewAzureStore creates a new Azure store

func (*AzureStore) GetContextPrefix

func (s *AzureStore) GetContextPrefix(path string) string

func (*AzureStore) GetID

func (s *AzureStore) GetID() string

func (*AzureStore) GetKind

func (s *AzureStore) GetKind() types.StoreKind

func (*AzureStore) GetKubeconfigForPath

func (s *AzureStore) GetKubeconfigForPath(path string, tags map[string]string) ([]byte, error)

func (*AzureStore) GetLogger

func (s *AzureStore) GetLogger() *logrus.Entry

func (*AzureStore) GetSearchPreview

func (s *AzureStore) GetSearchPreview(path string, _ map[string]string) (string, error)

func (*AzureStore) GetStoreConfig

func (s *AzureStore) GetStoreConfig() types.KubeconfigStore

func (*AzureStore) InitializeAzureStore

func (s *AzureStore) InitializeAzureStore() error

InitializeAzureStore initializes the Azure store

func (*AzureStore) IsInitialized

func (s *AzureStore) IsInitialized() bool

IsInitialized checks if the store has been initialized already

func (*AzureStore) StartSearch

func (s *AzureStore) StartSearch(channel chan SearchResult)

StartSearch starts the search for AKS clusters Limitation: Two seperate subscriptions should not have the same (resource_group, cluster-name) touple

func (*AzureStore) VerifyKubeconfigPaths

func (s *AzureStore) VerifyKubeconfigPaths() error

type DigitalOceanStore

type DigitalOceanStore struct {
	Logger *logrus.Entry
	// DiscoveredClustersMutex is a mutex allow many reads, one write mutex to synchronize writes
	// to the DiscoveredClusters map.
	// This can happen when a goroutine still discovers clusters while another goroutine computes the preview for a missing cluster.
	DiscoveredClustersMutex                   sync.RWMutex
	ContextNameAndClusterNameToClusterIDMutex sync.RWMutex
	KubeconfigStore                           types.KubeconfigStore
	ContextToKubernetesService                map[string]do.KubernetesService
	Config                                    doks.DoctlConfig
}

func NewDigitalOceanStore

func NewDigitalOceanStore(store types.KubeconfigStore) (*DigitalOceanStore, error)

NewDigitalOceanStore creates a new DigitalOcean store

func (*DigitalOceanStore) GetContextPrefix

func (s *DigitalOceanStore) GetContextPrefix(path string) string

func (*DigitalOceanStore) GetID

func (s *DigitalOceanStore) GetID() string

func (*DigitalOceanStore) GetKind

func (s *DigitalOceanStore) GetKind() types.StoreKind

func (*DigitalOceanStore) GetKubeconfigForPath

func (d *DigitalOceanStore) GetKubeconfigForPath(path string, tags map[string]string) ([]byte, error)

GetKubeconfigForPath gets the kubeconfig bytes for the given kubeconfig path and tags For this store, instead of using the path to identify the kubeconfig in the backing store, the cluster ID in the tags metadata is used. Reason: the clusterID is a long non-intuitive string that we don't want to

func (*DigitalOceanStore) GetLogger

func (s *DigitalOceanStore) GetLogger() *logrus.Entry

func (*DigitalOceanStore) GetSearchPreview

func (d *DigitalOceanStore) GetSearchPreview(_ string, tags map[string]string) (string, error)

GetSearchPreview enhances the preview with information stored in the metadata tags (no API requests are being performed)

func (*DigitalOceanStore) GetStoreConfig

func (s *DigitalOceanStore) GetStoreConfig() types.KubeconfigStore

func (*DigitalOceanStore) InitializeDigitalOceanStore

func (d *DigitalOceanStore) InitializeDigitalOceanStore() error

InitializeDigitalOceanStore initializes the DigitalOcean store with digital ocean clients

func (*DigitalOceanStore) IsInitialized

func (s *DigitalOceanStore) IsInitialized() bool

IsInitialized checks if the store has been initialized with clients already

func (*DigitalOceanStore) StartSearch

func (d *DigitalOceanStore) StartSearch(channel chan SearchResult)

StartSearch starts the search for Digital Ocean clusters

func (*DigitalOceanStore) VerifyKubeconfigPaths

func (s *DigitalOceanStore) VerifyKubeconfigPaths() error

type EKSStore

type EKSStore struct {
	Logger          *logrus.Entry
	KubeconfigStore types.KubeconfigStore
	Client          *awseks.Client
	Config          *types.StoreConfigEKS
	// DiscoveredClusters maps the kubeconfig path (az_<resource-group>--<cluster-name>) -> cluster
	// This is a cache for the clusters discovered during the initial search for kubeconfig paths
	// when not using a search index
	DiscoveredClusters map[string]*eks.Cluster
	StateDirectory     string
}

func NewEKSStore

func NewEKSStore(store types.KubeconfigStore, stateDir string) (*EKSStore, error)

func (*EKSStore) GetContextPrefix

func (s *EKSStore) GetContextPrefix(path string) string

func (*EKSStore) GetID

func (s *EKSStore) GetID() string

func (*EKSStore) GetKind

func (s *EKSStore) GetKind() types.StoreKind

func (*EKSStore) GetKubeconfigForPath

func (s *EKSStore) GetKubeconfigForPath(path string, _ map[string]string) ([]byte, error)

func (*EKSStore) GetLogger

func (s *EKSStore) GetLogger() *logrus.Entry

func (*EKSStore) GetSearchPreview

func (s *EKSStore) GetSearchPreview(path string, optionalTags map[string]string) (string, error)

func (*EKSStore) GetStoreConfig

func (s *EKSStore) GetStoreConfig() types.KubeconfigStore

func (*EKSStore) InitializeEKSStore

func (s *EKSStore) InitializeEKSStore() error

func (*EKSStore) IsInitialized

func (s *EKSStore) IsInitialized() bool

func (*EKSStore) StartSearch

func (s *EKSStore) StartSearch(channel chan SearchResult)

func (*EKSStore) VerifyKubeconfigPaths

func (s *EKSStore) VerifyKubeconfigPaths() error

type FilesystemStore

type FilesystemStore struct {
	Logger          *logrus.Entry
	KubeconfigStore types.KubeconfigStore
	KubeconfigName  string
	// contains filtered or unexported fields
}

func NewFilesystemStore

func NewFilesystemStore(kubeconfigName string, kubeconfigStore types.KubeconfigStore) (*FilesystemStore, error)

func (*FilesystemStore) GetContextPrefix

func (s *FilesystemStore) GetContextPrefix(path string) string

func (*FilesystemStore) GetID

func (s *FilesystemStore) GetID() string

func (*FilesystemStore) GetKind

func (s *FilesystemStore) GetKind() types.StoreKind

func (*FilesystemStore) GetKubeconfigForPath

func (s *FilesystemStore) GetKubeconfigForPath(path string, _ map[string]string) ([]byte, error)

func (*FilesystemStore) GetLogger

func (s *FilesystemStore) GetLogger() *logrus.Entry

func (*FilesystemStore) GetStoreConfig

func (s *FilesystemStore) GetStoreConfig() types.KubeconfigStore

func (*FilesystemStore) StartSearch

func (s *FilesystemStore) StartSearch(channel chan SearchResult)

func (*FilesystemStore) VerifyKubeconfigPaths

func (s *FilesystemStore) VerifyKubeconfigPaths() error

type GKEStore

type GKEStore struct {
	Logger          *logrus.Entry
	KubeconfigStore types.KubeconfigStore
	GkeClient       *gkev1.Service
	Config          *types.StoreConfigGKE
	// DiscoveredClusters maps the kubeconfig path (gke--project-name--clusterName) -> cluster
	// This is a cache for the clusters discovered during the initial search for kubeconfig paths
	// when not using a search index
	DiscoveredClusters map[string]*gkev1.Cluster
	// ProjectNameToID contains a mapping projectName -> project ID
	// used to construct the kubeconfig path containing the project name instead of a technical project id
	ProjectNameToID map[string]string
	StateDirectory  string
}

func NewGKEStore

func NewGKEStore(store types.KubeconfigStore, stateDir string) (*GKEStore, error)

NewGKEStore creates a new GKE store

func (*GKEStore) GetContextPrefix

func (s *GKEStore) GetContextPrefix(path string) string

func (*GKEStore) GetID

func (s *GKEStore) GetID() string

func (*GKEStore) GetKind

func (s *GKEStore) GetKind() types.StoreKind

func (*GKEStore) GetKubeconfigForPath

func (s *GKEStore) GetKubeconfigForPath(path string, _ map[string]string) ([]byte, error)

func (*GKEStore) GetLogger

func (s *GKEStore) GetLogger() *logrus.Entry

func (*GKEStore) GetStoreConfig

func (s *GKEStore) GetStoreConfig() types.KubeconfigStore

func (*GKEStore) InitializeGKEStore

func (s *GKEStore) InitializeGKEStore() error

InitializeGKEStore initializes the store by listing all available projects for the Google Account Decoupled from the NewGKEStore() to be called when starting the search to reduce time when the CLI can start showing the fuzzy search

func (*GKEStore) IsInitialized

func (s *GKEStore) IsInitialized() bool

IsInitialized checks if the store has been initialized already

func (*GKEStore) StartSearch

func (s *GKEStore) StartSearch(channel chan SearchResult)

func (*GKEStore) VerifyKubeconfigPaths

func (s *GKEStore) VerifyKubeconfigPaths() error

type GardenConfig

type GardenConfig struct {
	// Identity is the cluster identity of the garden cluster.
	// See cluster-identity ConfigMap in kube-system namespace of the garden cluster
	Identity string `yaml:"identity"`

	// Kubeconfig holds the path for the kubeconfig of the garden cluster
	Kubeconfig string `yaml:"kubeconfig"`
}

GardenConfig holds the config of a garden cluster

type GardenerStore

type GardenerStore struct {
	Logger                    *logrus.Entry
	KubeconfigStore           types.KubeconfigStore
	GardenClient              gardenclient.Client
	Client                    client.Client
	Config                    *types.StoreConfigGardener
	LandscapeIdentity         string
	LandscapeName             string
	StateDirectory            string
	CachePathToShoot          map[string]gardencorev1beta1.Shoot
	PathToShootLock           sync.RWMutex
	CachePathToManagedSeed    map[string]seedmanagementv1alpha1.ManagedSeed
	PathToManagedSeedLock     sync.RWMutex
	CacheCaSecretNameToSecret map[string]corev1.Secret
	CaSecretNameToSecretLock  sync.RWMutex
}

func NewGardenerStore

func NewGardenerStore(store types.KubeconfigStore, stateDir string) (*GardenerStore, error)

NewGardenerStore creates a new Gardener store

func (*GardenerStore) GetContextPrefix

func (s *GardenerStore) GetContextPrefix(path string) string

func (*GardenerStore) GetControlplaneKubeconfigForShoot

func (s *GardenerStore) GetControlplaneKubeconfigForShoot(shootName, project string) ([]byte, *string, error)

func (*GardenerStore) GetID

func (s *GardenerStore) GetID() string

func (*GardenerStore) GetKind

func (s *GardenerStore) GetKind() types.StoreKind

func (*GardenerStore) GetKubeconfigForPath

func (s *GardenerStore) GetKubeconfigForPath(path string, _ map[string]string) ([]byte, error)

func (*GardenerStore) GetLogger

func (s *GardenerStore) GetLogger() *logrus.Entry

func (*GardenerStore) GetSearchPreview

func (s *GardenerStore) GetSearchPreview(path string, optionalTags map[string]string) (string, error)

func (*GardenerStore) GetStoreConfig

func (s *GardenerStore) GetStoreConfig() types.KubeconfigStore

func (*GardenerStore) InitializeGardenerStore

func (s *GardenerStore) InitializeGardenerStore() error

InitializeGardenerStore initializes the store using the provided Gardener kubeconfig decoupled from the NewGardenerStore() to be called when starting the search to reduce time when the CLI can start showing the fuzzy search

func (*GardenerStore) IsInitialized

func (s *GardenerStore) IsInitialized() bool

IsInitialized checks if the store has been initialized already

func (*GardenerStore) StartSearch

func (s *GardenerStore) StartSearch(channel chan SearchResult)

StartSearch starts the search for Shoots and Managed Seeds

func (*GardenerStore) VerifyKubeconfigPaths

func (s *GardenerStore) VerifyKubeconfigPaths() error

type GardenloginConfig

type GardenloginConfig struct {
	// Gardens is a list of known GardenConfig clusters
	Gardens []GardenConfig `yaml:"gardens"`
}

GardenloginConfig represents the config for the Gardenlogin-exec-provider that is required to work with the kubeconfig files obtained from the GardenConfig cluster If missing, this configuration is generated based on the Kubeswitch config

type KubeconfigStore

type KubeconfigStore interface {
	// GetID returns the unique store ID
	// should be
	// - "<store kind>.default" if the kubeconfigStore.ID is not set
	// - "<store kind>.<id>" if the kubeconfigStore.ID is set
	GetID() string

	// GetKind returns the store kind (e.g., filesystem)
	GetKind() types.StoreKind

	// GetContextPrefix returns the prefix for the kubeconfig context names displayed in the search result
	// includes the path to the kubeconfig in the backing store because some stores compute the prefix based on that
	GetContextPrefix(path string) string

	// VerifyKubeconfigPaths verifies that the configured search paths are valid
	// can also include additional preprocessing
	VerifyKubeconfigPaths() error

	// StartSearch starts the search over the configured search paths
	// and populates the results via the given channel
	StartSearch(channel chan SearchResult)

	// GetKubeconfigForPath returns the byte representation of the kubeconfig
	// the kubeconfig has to fetch the kubeconfig from its backing store (e.g., uses the HTTP API)
	// Optional tags might help identify the cluster in the backing store, but typically such information is already encoded in the kubeconfig path (implementation specific)
	GetKubeconfigForPath(path string, tags map[string]string) ([]byte, error)

	// GetLogger returns the logger of the store
	GetLogger() *logrus.Entry

	// GetStoreConfig returns the store's configuration from the switch config file
	GetStoreConfig() types.KubeconfigStore
}

type OVHKube

type OVHKube struct {
	ID      string `json:"id"`
	Name    string `json:"name"`
	Project string
}

type OVHStore

type OVHStore struct {
	Logger          *logrus.Entry
	KubeconfigStore types.KubeconfigStore
	Client          *ovh.Client
	OVHKubeCache    map[string]OVHKube // map[clusterID]OVHKube
}

func NewOVHStore

func NewOVHStore(store types.KubeconfigStore) (*OVHStore, error)

func (*OVHStore) GetContextPrefix

func (r *OVHStore) GetContextPrefix(path string) string

func (*OVHStore) GetID

func (r *OVHStore) GetID() string

func (*OVHStore) GetKind

func (r *OVHStore) GetKind() types.StoreKind

func (*OVHStore) GetKubeconfigForPath

func (r *OVHStore) GetKubeconfigForPath(path string, _ map[string]string) ([]byte, error)

func (*OVHStore) GetLogger

func (r *OVHStore) GetLogger() *logrus.Entry

func (*OVHStore) GetStoreConfig

func (r *OVHStore) GetStoreConfig() types.KubeconfigStore

func (*OVHStore) StartSearch

func (r *OVHStore) StartSearch(channel chan SearchResult)

func (*OVHStore) VerifyKubeconfigPaths

func (r *OVHStore) VerifyKubeconfigPaths() error

type Previewer

type Previewer interface {
	GetSearchPreview(path string, optionalTags map[string]string) (string, error)
}

Previewer can be optionally implemented by stores to show custom preview content before the kubeconfig

type RancherStore

type RancherStore struct {
	Logger          *logrus.Entry
	KubeconfigStore types.KubeconfigStore
	ClientOpts      *clientbase.ClientOpts
	Client          *managementClient.Client
}

func NewRancherStore

func NewRancherStore(store types.KubeconfigStore) (*RancherStore, error)

func (*RancherStore) GetContextPrefix

func (r *RancherStore) GetContextPrefix(path string) string

func (*RancherStore) GetID

func (r *RancherStore) GetID() string

func (*RancherStore) GetKind

func (r *RancherStore) GetKind() types.StoreKind

func (*RancherStore) GetKubeconfigForPath

func (r *RancherStore) GetKubeconfigForPath(path string, _ map[string]string) ([]byte, error)

func (*RancherStore) GetLogger

func (r *RancherStore) GetLogger() *logrus.Entry

func (*RancherStore) GetStoreConfig

func (r *RancherStore) GetStoreConfig() types.KubeconfigStore

func (*RancherStore) StartSearch

func (r *RancherStore) StartSearch(channel chan SearchResult)

func (*RancherStore) VerifyKubeconfigPaths

func (r *RancherStore) VerifyKubeconfigPaths() error

type ScalewayKube

type ScalewayKube struct {
	ID      string
	Name    string
	Project string
}

type ScalewayStore

type ScalewayStore struct {
	Logger             *logrus.Entry
	KubeconfigStore    types.KubeconfigStore
	Client             *scw.Client
	DiscoveredClusters map[string]ScalewayKube
}

func NewScalewayStore

func NewScalewayStore(store types.KubeconfigStore) (*ScalewayStore, error)

func (*ScalewayStore) GetContextPrefix

func (s *ScalewayStore) GetContextPrefix(path string) string

func (*ScalewayStore) GetID

func (s *ScalewayStore) GetID() string

func (*ScalewayStore) GetKind

func (r *ScalewayStore) GetKind() types.StoreKind

func (*ScalewayStore) GetKubeconfigForPath

func (s *ScalewayStore) GetKubeconfigForPath(path string, _ map[string]string) ([]byte, error)

func (*ScalewayStore) GetLogger

func (s *ScalewayStore) GetLogger() *logrus.Entry

func (*ScalewayStore) GetStoreConfig

func (s *ScalewayStore) GetStoreConfig() types.KubeconfigStore

func (*ScalewayStore) StartSearch

func (s *ScalewayStore) StartSearch(channel chan SearchResult)

func (*ScalewayStore) VerifyKubeconfigPaths

func (r *ScalewayStore) VerifyKubeconfigPaths() error

type SearchResult

type SearchResult struct {
	// KubeconfigPath is the kubeconfig path in the backing store which most of the time encodes enough information to
	// retrieve the kubeconfig associated with it.
	KubeconfigPath string
	// Tags contains the additional metadata that the store wants to associate with a context name.
	// This metadata is later handed over in the getKubeconfigForPath() function when retrieving the kubeconfig bytes for the path and might contain
	// information necessary to retrieve the kubeconfig from the backing store (such a unique ID for the cluster required for the API)
	Tags map[string]string
	// Error is an error which occured when trying to discover kubeconfig paths in the backing store
	Error error
}

SearchResult is a full kubeconfig path discovered from the kubeconfig store given the contained kubeconfig path, the store knows how to retrieve and return the actual kubeconfig

type VaultStore

type VaultStore struct {
	Logger             *logrus.Entry
	KubeconfigStore    types.KubeconfigStore
	Client             *vaultapi.Client
	VaultKeyKubeconfig string
	KubeconfigName     string
	EngineVersion      string
	// contains filtered or unexported fields
}

func NewVaultStore

func NewVaultStore(vaultAPIAddressFromFlag, vaultTokenFileName, kubeconfigName string, kubeconfigStore types.KubeconfigStore) (*VaultStore, error)

func (*VaultStore) GetContextPrefix

func (s *VaultStore) GetContextPrefix(path string) string

func (*VaultStore) GetID

func (s *VaultStore) GetID() string

func (*VaultStore) GetKind

func (s *VaultStore) GetKind() types.StoreKind

func (*VaultStore) GetKubeconfigForPath

func (s *VaultStore) GetKubeconfigForPath(path string, _ map[string]string) ([]byte, error)

func (*VaultStore) GetLogger

func (s *VaultStore) GetLogger() *logrus.Entry

func (*VaultStore) GetStoreConfig

func (s *VaultStore) GetStoreConfig() types.KubeconfigStore

func (*VaultStore) StartSearch

func (s *VaultStore) StartSearch(channel chan SearchResult)

func (*VaultStore) VerifyKubeconfigPaths

func (s *VaultStore) VerifyKubeconfigPaths() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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