Documentation ¶
Index ¶
- Constants
- func LoadAndStoreKubeConfigs(kubeConfigStore ContextStore, kubeConfigs string, source int) error
- func LoadAndWatchFiles(kubeConfigStore ContextStore, paths string, source int)
- func RemoveContextFromFile(context string, path string) error
- func WriteToFile(config clientcmdapi.Config, path string) error
- type Context
- func GetInClusterContext(oidcIssuerURL string, oidcClientID string, oidcClientSecret string, ...) (*Context, error)
- func LoadContextsFromAPIConfig(config *api.Config, skipProxySetup bool) ([]Context, []error)
- func LoadContextsFromBase64String(kubeConfig string, source int) ([]Context, error)
- func LoadContextsFromFile(kubeConfigPath string, source int) ([]Context, error)
- func LoadContextsFromMultipleFiles(kubeConfigs string, source int) ([]Context, error)
- func (c *Context) AuthType() string
- func (c *Context) ClientConfig() clientcmd.ClientConfig
- func (c *Context) ClientSetWithToken(token string) (*kubernetes.Clientset, error)
- func (c *Context) OidcConfig() (*OidcConfig, error)
- func (c *Context) ProxyRequest(writer http.ResponseWriter, request *http.Request) error
- func (c *Context) RESTConfig() (*rest.Config, error)
- func (c *Context) SetupProxy() error
- func (c *Context) SourceStr() string
- type ContextStore
- type OidcConfig
Constants ¶
const ( KubeConfig = 1 << iota DynamicCluster InCluster )
const InClusterContextName = "main"
TODO: Use a different way to avoid name clashes with other clusters.
Variables ¶
This section is empty.
Functions ¶
func LoadAndStoreKubeConfigs ¶
func LoadAndStoreKubeConfigs(kubeConfigStore ContextStore, kubeConfigs string, source int) error
LoadAndStoreKubeConfigs loads contexts from the given kubeconfig files and stores them in the given context store. Note: No need to remove contexts from the store, since adding a context with the same name will overwrite the old one.
func LoadAndWatchFiles ¶
func LoadAndWatchFiles(kubeConfigStore ContextStore, paths string, source int)
LoadAndWatchFiles loads kubeconfig files and watches them for changes.
func RemoveContextFromFile ¶
RemoveContextFromFile removes the given context and its related cluster and user from the kubeconfig file.
func WriteToFile ¶
func WriteToFile(config clientcmdapi.Config, path string) error
WriteToFile writes the given config to the kubeconfig file.
Types ¶
type Context ¶
type Context struct { Name string `json:"name"` KubeContext *api.Context `json:"kubeContext"` Cluster *api.Cluster `json:"cluster"` AuthInfo *api.AuthInfo `json:"authInfo"` Source int `json:"source"` OidcConf *OidcConfig `json:"oidcConfig"` Internal bool `json:"internal"` // contains filtered or unexported fields }
Context contains all information related to a kubernetes context.
func GetInClusterContext ¶
func GetInClusterContext(oidcIssuerURL string, oidcClientID string, oidcClientSecret string, oidcScopes string, ) (*Context, error)
GetInClusterContext returns the in-cluster context.
func LoadContextsFromAPIConfig ¶
LoadContextsFromAPIConfig loads contexts from the given api.Config.
func LoadContextsFromBase64String ¶
LoadContextsFromBase64String loads contexts from the given kubeconfig string.
func LoadContextsFromFile ¶
LoadContextsFromFile loads contexts from the given kubeconfig file.
func LoadContextsFromMultipleFiles ¶
LoadContextsFromMultipleFiles loads contexts from the given kubeconfig files.
func (*Context) ClientConfig ¶
func (c *Context) ClientConfig() clientcmd.ClientConfig
ClientConfig returns a clientcmd.ClientConfig for the context.
func (*Context) ClientSetWithToken ¶
func (c *Context) ClientSetWithToken(token string) (*kubernetes.Clientset, error)
ClientSetWithToken returns a kubernetes clientset for the context.
func (*Context) OidcConfig ¶
func (c *Context) OidcConfig() (*OidcConfig, error)
OidcConfig returns the oidc config for the context.
func (*Context) ProxyRequest ¶
ProxyRequest proxies the given request to the cluster.
func (*Context) RESTConfig ¶
RESTConfig returns a rest.Config for the context.
func (*Context) SetupProxy ¶
SetupProxy sets up a reverse proxy for the context.
type ContextStore ¶
type ContextStore interface { AddContext(headlampContext *Context) error GetContexts() ([]*Context, error) GetContext(name string) (*Context, error) RemoveContext(name string) error AddContextWithKeyAndTTL(headlampContext *Context, key string, ttl time.Duration) error UpdateTTL(key string, ttl time.Duration) error }
ContextStore is an interface for storing and retrieving contexts.
func NewContextStore ¶
func NewContextStore() ContextStore
NewContextStore creates a new ContextStore.