store

package
v0.0.0-...-bbd9c0a Latest Latest
Warning

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

Go to latest
Published: May 16, 2023 License: Apache-2.0 Imports: 45 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) ([]byte, error)

func (*AzureStore) GetLogger

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

func (*AzureStore) GetSearchPreview

func (s *AzureStore) GetSearchPreview(path 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 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) ([]byte, error)

func (*EKSStore) GetLogger

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

func (*EKSStore) GetSearchPreview

func (s *EKSStore) GetSearchPreview(path 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) ([]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) ([]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) ([]byte, error)

func (*GardenerStore) GetLogger

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

func (*GardenerStore) GetSearchPreview

func (s *GardenerStore) GetSearchPreview(path 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)
	GetKubeconfigForPath(path 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 Previewer

type Previewer interface {
	GetSearchPreview(path 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) ([]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 SearchResult

type SearchResult struct {
	KubeconfigPath string
	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
	KubeconfigName  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) ([]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