types

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: Apache-2.0 Imports: 2 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ValidConfigVersions = sets.NewString("v1alpha1")

ValidConfigVersions contains all valid config versions

ValidHookTypes contains all valid hook types

ValidStoreKinds contains all valid store kinds

Functions

This section is empty.

Types

type AuthProvider

type AuthProvider struct {
	// Cluster is the cluster identifier of the context
	Config map[string]string `yaml:"config"`
	// User is the user identifier of the context
	Name string `yaml:"name"`
}

AuthProvider cotnains the config and name of the kubeconfig auth provider plugin

type Cache

type Cache struct {
	Kind string `yaml:"kind"`
	// Config is store-specific configuration for the cache
	// Check the documentation for each cache to see configuration options
	Config interface{} `yaml:"config"`
}

CacheConfig contains the configuration for the cache

type Cluster

type Cluster struct {
	// CertificateAuthorityData contains CA info
	CertificateAuthorityData string `yaml:"certificate-authority-data,omitempty"`
	// Server is the API server address
	Server string `yaml:"server"`
	// Insecure defines if the API server can be accessed with no CA checks
	Insecure bool `yaml:"insecure-skip-tls-verify,omitempty"`
}

type Config

type Config struct {
	// Kind is the type of the config. Expects "SwitchConfig"
	Kind string `yaml:"kind"`
	// Version is the version of the config file.
	// Possible values: "v1alpha1"
	Version string `yaml:"version"`
	// KubeconfigName is the global default for how the kubeconfig is
	// identified in the backing store.
	// Can be overridden in the individual kubeconfig store configuration
	// + optional
	KubeconfigName *string `yaml:"kubeconfigName"`
	// ShowPreview configures if the selection dialog shows a sanitized preview of the kubeconfig file.
	// Can be overridden via command line flag --show-preview true/false
	// default: true
	// + optional
	ShowPreview *bool `yaml:"showPreview"`
	// ExecShell configures the shell to be used for switch exec -- "command"
	// If a shell (bash, zsh, sh) is provided, the command is executed like so
	// --> bash -c "your_command"
	ExecShell *string `yaml:"execShell"`
	// RefreshIndexAfter is the global default for how often
	// the index for this kubeconfig store shall be refreshed.
	// Not setting this field will cause kswitch to not use an index
	// Can be overridden in the individual kubeconfig store configuration
	// + optional
	RefreshIndexAfter *time.Duration `yaml:"refreshIndexAfter"`
	// Hooks defines configurations for commands that shall be executed prior to the search
	Hooks []Hook `yaml:"hooks"`
	// KubeconfigStores contains the configuration for kubeconfig stores
	KubeconfigStores []KubeconfigStore `yaml:"kubeconfigStores"`
}

type ConfigOld

type ConfigOld struct {
	Kind                          string           `yaml:"kind"`
	KubeconfigName                string           `yaml:"kubeconfigName"`
	KubeconfigRediscoveryInterval *time.Duration   `yaml:"kubeconfigRediscoveryInterval"`
	VaultAPIAddress               string           `yaml:"vaultAPIAddress"`
	Hooks                         []Hook           `yaml:"hooks"`
	KubeconfigPaths               []KubeconfigPath `yaml:"kubeconfigPaths"`
}

type Context

type Context struct {
	// Cluster is the cluster identifier of the context
	Cluster string `yaml:"cluster"`
	// User is the user identifier of the context
	User string
}

type ContextAlias

type ContextAlias struct {
	// ContextToAliasMapping defines how alias names are written
	// used internally by the kswitch tool
	ContextToAliasMapping map[string]string `yaml:"contextToAliasMapping"`
}

ContextAlias contains alias names for contexts

type EnvMap

type EnvMap struct {
	Name  string `yaml:"name"`
	Value string `yaml:"value"`
}

type ExecProvider

type ExecProvider struct {
	// APIVersion defines the versioned schema of this representation of an object.
	// Servers should convert recognized schemas to the latest internal value, and
	// may reject unrecognized values.
	// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources
	// +optional
	APIVersion         string   `yaml:"apiVersion,omitempty" protobuf:"bytes,2,opt,name=apiVersion"`
	Args               []string `yaml:"args"`
	Command            string   `yaml:"command"`
	Env                []EnvMap `yaml:"env"`
	InstallHint        string   `yaml:"installHint,omitempty"`
	ProvideClusterInfo bool     `yaml:"provideClusterInfo,omitempty"`
}

ExecProvider

type GCPAuthenticationType

type GCPAuthenticationType string

GCPAuthenticationType Required permission to list GKE clusters: container.clusters.list Requires to have the container.clusters.get permission. The least-privileged IAM role that provides this permission is container.clusterViewer.

const (
	// GcloudAuthentication is an identifier for the gcloud authentication type that requires and uses a local installation
	// of the gcloud command line tool
	// Google Application Default Credentials are used for authentication.
	// When using gcloud  'gcloud auth application-default login' so that
	// the library can find a valid access token provided via gcloud's oauth flow at the default location
	// cat $HOME/.config/gcloud/application_default_credentials.json
	GcloudAuthentication GCPAuthenticationType = "gcloud"
	// APIKeyAuthentication is an identifier for the authentication type with API keys
	// also see: https://cloud.google.com/docs/authentication/api-keys
	APIKeyAuthentication GCPAuthenticationType = "api-key"
	// ServiceAccountAuthentication is an identifier for the authentication type with GCP service accounts
	// also see: https://cloud.google.com/kubernetes-engine/docs/how-to/api-server-authentication#environments-without-gcloud
	// To be able to use kswitch with multiple GCP accounts at once, please use Service Accounts and configure one
	// GKE store per account
	ServiceAccountAuthentication GCPAuthenticationType = "service-account"
	// LegacyAuthentication is an identifier for the gcloud authentication type with legacy credentials
	// also see: https://cloud.google.com/kubernetes-engine/docs/how-to/api-server-authentication#legacy-auth
	LegacyAuthentication GCPAuthenticationType = "legacy"
)

type GKEAuthentication

type GKEAuthentication struct {
	// possible values:
	// defaults to "gcloud"
	// + optional
	AuthenticationType *GCPAuthenticationType `yaml:"authenticationType"`
	// APIKeyFilePath is the path on the local filesystem to the file that contains
	// an API key used to authenticate against the Google Kubernetes Engine API
	// + optional
	APIKeyFilePath *string `yaml:"apiKeyFilePath"`
	// ServiceAccountFilePath is the path on the local filesystem to the file that contains
	// the GCP service account used to authenticate against the Google Kubernetes Engine API
	// + optional
	ServiceAccountFilePath *string `yaml:"serviceAccountFilePath"`
}

type GKEPreferredEndpoint

type GKEPreferredEndpoint string
const (
	GkePrivateEndpoint GKEPreferredEndpoint = "private"
	GkePublicEndpoint  GKEPreferredEndpoint = "public"
	GkeDnsEndpoint     GKEPreferredEndpoint = "dns"
)

type Hook

type Hook struct {
	// Name is the name of the Hook
	Name string `yaml:"name"`
	// Type is the type of the Hook (either "Executable" or "InlineCommand")
	Type HookType `yaml:"type"`
	// Path defines the path to the executable that shall be called when the
	// Type is "Executable"
	Path *string `yaml:"path"`
	// Arguments are the arguments with which the external executable of a Hook of type
	// "Executable" will be called
	Arguments []string `yaml:"arguments"`
	// Execution contains configuration regarding the execution of the Hook
	Execution *struct {
		// Interval defines the interval how often the Hook is executed
		// if this field is not set, it can only be executed on demand with "switch hooks --hook-name <name>"
		Interval *time.Duration `yaml:"interval"`
	} `yaml:"execution"`
}

Hook contains configurations for a Hook

type HookState

type HookState struct {
	// HookName is the name of the Hooks
	HookName string `yaml:"hookName"`
	// LastExecutionTime is the last execution time of the hook
	// used to check if the Hook has to be executed again
	LastExecutionTime time.Time `yaml:"lastExecutionTime"`
}

HookState contains the definition for the hook state

type HookType

type HookType string

HookType is the type of hook (either "Executable" or "InlineCommand")

const (
	// HookTypeExecutable defines a hook that contains an external binary executable to be called
	HookTypeExecutable HookType = "Executable"
	// HookTypeInlineCommand defines a hook that directly contains bourne shell
	// commands to be executed
	HookTypeInlineCommand HookType = "InlineCommand"
)

type Index

type Index struct {
	// Kind defines which store kind this Index belongs to
	Kind StoreKind `yaml:"kind"`
	// ContextToPathMapping contains the actual index, mapping the context name
	// to the kubeconfig path in the backing store
	ContextToPathMapping map[string]string `yaml:"contextToPathMapping"`
	// ContextToTags contains optional metadata ("tags") for a context name
	// For instance, the DigitalOcean store uses this as the getKubeconfigForPath() requires to know the cluster_ID of a DOKS cluster, which
	// for beauty reasons, is not stored in the visible kubeconfig_path. The cluster_ID for a context_name is stored as a tag instead.
	ContextToTags map[string]map[string]string `yaml:"contextToTags"`
}

Index defines how an index for a kubeconfig store is written

type IndexState

type IndexState struct {
	// Kind defines which store kind this Index belongs to
	Kind StoreKind `yaml:"kind"`
	// LastUpdateTime is the last time the index has been updated
	LastUpdateTime time.Time `yaml:"lastExecutionTime"`
}

IndexState defines how the state of an index for a kubeconfig store is written

type KubeCluster

type KubeCluster struct {
	// Name is the name of the cluster
	Name string `yaml:"name"`
	// Cluster contains cluster configuration information
	Cluster Cluster `yaml:"cluster"`
}

KubeCluster is a cluster configuration of a kubeconfig file

type KubeConfig

type KubeConfig struct {
	// TypeMeta common k8s type meta definition
	TypeMeta TypeMeta `yaml:",inline"`
	// CurrentContext is the current context of the kubeconfig file
	CurrentContext string `yaml:"current-context"`
	// Contexts are all defined contexts of the kubeconfig file
	Contexts []KubeContext `yaml:"contexts"`
	// Clusters are the cluster configurations
	Clusters []KubeCluster `yaml:"clusters"`
	// Users are the user configurations
	Users []KubeUser `yaml:"users"`
}

KubeConfig is a representation of a kubeconfig file does not include sensitive fields that could include credentials used to show a preview of the Kubeconfig file

type KubeContext

type KubeContext struct {
	// Name is the name of the context
	Name string `yaml:"name"`
	// Context contains context configuration
	Context Context `yaml:"context"`
}

type KubeUser

type KubeUser struct {
	// Name is the name of the user
	// only parse the name, not the credentials
	Name string `yaml:"name"`
	// User contains user auth information
	User User `yaml:"user"`
}

KubeUser is a user in a kubeconfig file

type KubeconfigPath

type KubeconfigPath struct {
	Path  string    `yaml:"path"`
	Store StoreKind `yaml:"store"`
}

type KubeconfigStore

type KubeconfigStore struct {
	// ID is the ID of the kubeconfig store.
	// Used to write distinct index files for each store
	// Not required if only one store of a store kind is configured
	// + optional
	ID *string `yaml:"id"`
	// Kind identifies a supported store kind - filesystem, vault, Gardener.
	Kind StoreKind `yaml:"kind"`
	// KubeconfigName defines how the kubeconfig is identified in the backing store
	// For the Filesystem store, this is the name of the file that contains the kubeconfig
	// For the Vault store, this is the secret key
	// For other stores this field is not used
	// + optional
	KubeconfigName *string `yaml:"kubeconfigName"`
	// Paths contains the paths to search for in the backing store
	Paths []string `yaml:"paths"`
	// RefreshIndexAfter defines how often the index for this kubeconfig store shall be refreshed.
	// Not setting this field will cause kswitch to not use an index
	// + optional
	RefreshIndexAfter *time.Duration `yaml:"refreshIndexAfter"`
	// Required defines if errors when initializing this store should be logged
	// defaults to true
	// useful when configuring a kubeconfig store that is not always available
	// However, when searching on an index and wanting to retrieve the kubeconfig from an unavailable store,
	// it will throw an errors nonetheless
	// + optional
	Required *bool `yaml:"required"`
	// ShowPrefix configures if the search result should include store specific prefix (e.g for the filesystem store the parent directory name)
	// default: true
	ShowPrefix *bool `yaml:"showPrefix"`
	// Config is store-specific configuration.
	// Please check the documentation for each backing provider to see what configuration is
	// possible here
	Config interface{} `yaml:"config"`
	// Cache allows to cache the kubeconfigs in the backing store
	// + optional
	Cache *Cache `yaml:"cache"`
}

type StoreConfigAkamai

type StoreConfigAkamai struct {
	LinodeToken string `yaml:"linode_token"`
}

type StoreConfigAzure

type StoreConfigAzure struct {
	// SubscriptionID is the name of the Azure Subscription kswitch shall discover Azure clusters from
	// Please create on store per subscription
	// + optional
	SubscriptionID *string `yaml:"subscriptionID"`
	// Endpoint is the base URL for Azure.
	// Defaults to the public cloud endpoint "https://management.azure.com/"
	// Example Alternatives:
	// - Azure Germany: https://management.microsoftazure.de/
	// - Azure US Gov: https://management.usgovcloudapi.net/
	// - Azure China: https://management.chinacloudapi.cn/
	// + optional
	Endpoint *string `yaml:"endpoint"`
	// ResourceGroups limits the search to clusters within the given resource groups
	// + optional
	ResourceGroups []string `yaml:"resourceGroups"`
}

type StoreConfigCapi

type StoreConfigCapi struct {
	// KubeconfigPath is the path on the local filesystem pointing to the kubeconfig
	// for the management cluster. If none is specified the current context will be used to look up clusters
	KubeconfigPath string `yaml:"kubeconfigPath"`
}

type StoreConfigEKS

type StoreConfigEKS struct {
	// Region is the AWS region to search for clusters https://docs.aws.amazon.com/general/latest/gr/rande.html
	Region *string `yaml:"region"`
	// Profile is the named profile to authenticate with https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html
	Profile string `yaml:"profile"`
}

type StoreConfigExoscale

type StoreConfigExoscale struct {
	ExoscaleAPIKey    string `yaml:"exoscaleAPIKey"`
	ExoscaleSecretKey string `yaml:"exoscaleSecretKey"`
}

type StoreConfigGKE

type StoreConfigGKE struct {
	// GKEAuthentication contains authentication configuration for GCP
	GKEAuthentication *GKEAuthentication `yaml:"Authentication"`
	// GCPAccount is the name of the gcp account kswitch shall discover GKE clusters from
	// Only used when relying on gcloud authentication.
	// Used to verify that gcloud currently has the correct account activated
	// However, will not actively activate another account (has to be done manually by the user).
	// If not specified, will use the currently activated account when using gcloud
	// + optional
	GCPAccount *string `yaml:"gcpAccount"`
	// ProjectID contains an optional list of projects that will be considered in the search for existing GKE clusters.
	// If no projects are given, will discover clusters from every found project.
	ProjectIDs []string `yaml:"projectIDs"`
	// PreferredEndpoint is the preferred endpoint to use for the GKE API.
	PreferredEndpoint *GKEPreferredEndpoint `yaml:"preferredEndpoint"`
}

type StoreConfigGardener

type StoreConfigGardener struct {
	// GardenerAPIKubeconfigPath is the path on the local filesystem pointing to the kubeconfig
	// for the Gardener API server
	GardenerAPIKubeconfigPath string `yaml:"gardenerAPIKubeconfigPath"`
	// LandscapeName is a custom name for the Gardener landscape
	// uses this name instead of the default ID from the Gardener API ConfigMap "cluster-identity"
	// also used as the store ID if the kubeconfig store ID is not specified
	// + optional
	LandscapeName *string `yaml:"landscapeName"`
}

type StoreConfigOVH

type StoreConfigOVH struct {
	OVHApplicationKey    string `yaml:"application_key"`
	OVHApplicationSecret string `yaml:"application_secret"`
	OVHConsumerKey       string `yaml:"consumer_key"`
	OVHEndpoint          string `yaml:"endpoint"`
}

type StoreConfigPlugin

type StoreConfigPlugin struct {
	CmdPath string   `yaml:"cmdPath"`
	Args    []string `yaml:"args"`
}

type StoreConfigRancher

type StoreConfigRancher struct {
	// RancherAPIAddress is the URL of the Rancher API, e.g. https://rancher.example.com/v3
	RancherAPIAddress string `yaml:"rancherAPIAddress"`
	// RancherToken is the token used to authenticate against the Rancher API, format: token-12abc:bmjlzslas......x4hv5ptc29wt4sfk
	RancherToken string `yaml:"rancherToken"`
}

type StoreConfigScaleway

type StoreConfigScaleway struct {
	ScalewayOrganizationID string `yaml:"organization_id"`
	ScalewayAccessKey      string `yaml:"access_key"`
	ScalewaySecretKey      string `yaml:"secret_key"`
	ScalewayRegion         string `yaml:"region"`
}

type StoreConfigVault

type StoreConfigVault struct {
	// VaultAPIAddress is the URL of the Vault API
	VaultAPIAddress    string `yaml:"vaultAPIAddress"`
	VaultEngineVersion string `yaml:"vaultEngineVersion"`
	VaultKeyKubeconfig string `yaml:"vaultKeyKubeconfig"`
}

type StoreKind

type StoreKind string

StoreKind identifies a supported store kind - filesystem, vault, Gardener.

const (
	// StoreKindFilesystem is an identifier for the filesystem store
	StoreKindFilesystem StoreKind = "filesystem"
	// StoreKindVault is an identifier for the vault store
	StoreKindVault StoreKind = "vault"
	// StoreKindGardener is an identifier for the gardener store
	StoreKindGardener StoreKind = "gardener"
	// StoreKindGKE is an identifier for the GKE store
	StoreKindGKE StoreKind = "gke"
	// StoreKindAzure is an identifier for the Azure store
	StoreKindAzure StoreKind = "azure"
	// StoreKindEKS is an identifier for the EKS store
	StoreKindEKS StoreKind = "eks"
	// StoreKindExoscale is an identifier for the Exoscale store
	StoreKindExoscale StoreKind = "exoscale"
	// StoreKindRancher is an identifier for the Rancher store
	StoreKindRancher StoreKind = "rancher"
	// StoreKindOVH is an identifier for the OVH store
	StoreKindOVH StoreKind = "ovh"
	// StoreKindScaleway is an identifier for the Scaleway store
	StoreKindScaleway StoreKind = "scaleway"
	// StoreKindDigitalOcean is an identifier for the Azure store
	StoreKindDigitalOcean StoreKind = "digitalocean"
	// StoreKindAkamai is an identifier for the Akamai store
	StoreKindAkamai StoreKind = "akamai"
	// StoreKindCapi is an identifier for the CAPI store
	StoreKindCapi StoreKind = "capi"
	// StoreKindPlugin is an identifier for the Plugin store
	StoreKindPlugin StoreKind = "plugin"
)

type TypeMeta

type TypeMeta struct {
	// Kind is a string value representing the REST resource this object represents.
	// Servers may infer this from the endpoint the client submits requests to.
	// Cannot be updated.
	// In CamelCase.
	// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds
	// +optional
	Kind string `yaml:"kind,omitempty" protobuf:"bytes,1,opt,name=kind"`

	// APIVersion defines the versioned schema of this representation of an object.
	// Servers should convert recognized schemas to the latest internal value, and
	// may reject unrecognized values.
	// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources
	// +optional
	APIVersion string `yaml:"apiVersion,omitempty" protobuf:"bytes,2,opt,name=apiVersion"`
}

type User

type User struct {
	// AuthProvider contains configuration for an external auth provider
	AuthProvider *AuthProvider `yaml:"auth-provider,omitempty"`
	// ExecProvider
	ExecProvider *ExecProvider `yaml:"exec,omitempty"`
}

User contains the AuthInformation for a user

Jump to

Keyboard shortcuts

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