Documentation ¶
Index ¶
- Constants
- Variables
- func EnsureFinalizer(ctx context.Context, c client.Client, o client.Object, finalizer string) error
- func FindDirUpwards(path, dirName string, maxSteps int) (string, error)
- func GetEnvOrDefault(envKey, defaultValue string) string
- func GetIntEnvWithDefault(envKey string, def int) int
- func GetKubernetesVersion(restClientGetter genericclioptions.RESTClientGetter) (*version.Info, error)
- func GetOwnerReference(obj metav1.Object, kind string) *metav1.OwnerReference
- func GetSecretKeyFromSecretKeyReference(ctx context.Context, c client.Client, namespace string, ...) (string, error)
- func IgnoreAlreadyExists(err error) error
- func IsSecretContainsKey(s *corev1.Secret, key string) bool
- func LabelSelectorPredicate(s metav1.LabelSelector) predicate.Predicate
- func LogIntoContext(ctx context.Context, keysAndValues ...interface{}) context.Context
- func LogIntoContextFromRequest(ctx context.Context, req ctrl.Request) context.Context
- func NewClientConfigLoaderFromBytes(kubeConfig []byte) clientcmd.ClientConfigLoader
- func NewClientConfigLoaderFromSecret(kubeConfig *corev1.Secret) clientcmd.ClientConfigLoader
- func NewHeadscaleGRPCClient(url, apiKey string) (v1.HeadscaleServiceClient, error)
- func NewHeadscaleGRPCSocketClient(socketPath string) (v1.HeadscaleServiceClient, error)
- func NewHeadscaleK8sClientFromRestClientGetter(restClientGetter genericclioptions.RESTClientGetter, ...) (client.Client, error)
- func NewK8sClient(cfg *rest.Config) (client.Client, error)
- func NewK8sClientFromCluster(ctx context.Context, c client.Client, cluster *greenhousev1alpha1.Cluster) (client.Client, error)
- func NewK8sClientFromRestClientGetter(restClientGetter genericclioptions.RESTClientGetter) (client.Client, error)
- func PredicateByName(name string) predicate.Predicate
- func PredicateClusterByAccessMode(accessMode greenhousev1alpha1.ClusterAccessMode) predicate.Predicate
- func PredicateFilterBySecretType(secretType corev1.SecretType) predicate.Predicate
- func PredicateSecretContainsKey(key string) predicate.Predicate
- func RemoveFinalizer(ctx context.Context, c client.Client, o client.Object, finalizer string) error
- func ValidateSecretForKubeConfig(secret *corev1.Secret) error
- type ClientConfigGetter
- func (g *ClientConfigGetter) GetDefaultFilename() string
- func (g *ClientConfigGetter) GetExplicitFile() string
- func (g *ClientConfigGetter) GetLoadingPrecedence() []string
- func (g *ClientConfigGetter) GetStartingConfig() (*clientcmdapi.Config, error)
- func (g *ClientConfigGetter) IsDefaultConfig(config *rest.Config) bool
- func (g *ClientConfigGetter) IsExplicitFile() bool
- func (g *ClientConfigGetter) Load() (*clientcmdapi.Config, error)
- type DeletionResult
- type KubeClientOption
- type OperationResult
- func CreateOrPatch(ctx context.Context, c client.Client, obj client.Object, mutate func() error) (OperationResult, error)
- func Patch(ctx context.Context, c client.Client, obj client.Object, mutate func() error) (OperationResult, error)
- func PatchStatus(ctx context.Context, c client.Client, obj client.Object, mutate func() error) (OperationResult, error)
- type RestClientGetter
- func NewRestClientGetterForInCluster(namespace string, opts ...KubeClientOption) (*RestClientGetter, error)
- func NewRestClientGetterFromBytes(config []byte, namespace string, opts ...KubeClientOption) *RestClientGetter
- func NewRestClientGetterFromRestConfig(cfg *rest.Config, namespace string, opts ...KubeClientOption) *RestClientGetter
- func NewRestClientGetterFromSecret(secret *corev1.Secret, namespace string, opts ...KubeClientOption) (*RestClientGetter, error)
- type RuntimeOptions
Constants ¶
const (
SocketWritePermissions = 0o666
)
Variables ¶
var PredicatePluginWithHelmSpec = func() predicate.Funcs { return predicate.NewPredicateFuncs(func(o client.Object) bool { if pluginDefinition, ok := o.(*greenhousev1alpha1.PluginDefinition); ok { return pluginDefinition.Spec.HelmChart != nil } return false }) }
PredicatePluginWithHelmSpec filters PluginDefinitions without an HelmChart specification.
var Scheme = runtime.NewScheme()
Functions ¶
func EnsureFinalizer ¶
EnsureFinalizer ensures a finalizer is present on the object. Returns an error on failure.
func FindDirUpwards ¶
Searches for a directory upwards starting from the given path.
func GetEnvOrDefault ¶
GetEnvOrDefault returns the value of the environment variable or the default value.
func GetIntEnvWithDefault ¶
func GetKubernetesVersion ¶
func GetKubernetesVersion(restClientGetter genericclioptions.RESTClientGetter) (*version.Info, error)
GetKubernetesVersion returns the kubernetes git version using the discovery client.
func GetOwnerReference ¶
func GetOwnerReference(obj metav1.Object, kind string) *metav1.OwnerReference
GetOwnerReference returns the OwnerReference if found else nil.
func GetSecretKeyFromSecretKeyReference ¶
func GetSecretKeyFromSecretKeyReference(ctx context.Context, c client.Client, namespace string, secretReference greenhousev1alpha1.SecretKeyReference) (string, error)
GetSecretKeyFromSecretKeyReference returns the value of the secret identified by SecretKeyReference or an error.
func IgnoreAlreadyExists ¶
IgnoreAlreadyExists returns nil on IsAlreadyExists errors.
func IsSecretContainsKey ¶
IsSecretContainsKey checks whether the given secret contains a key.
func LabelSelectorPredicate ¶
func LabelSelectorPredicate(s metav1.LabelSelector) predicate.Predicate
LabelSelectorPredicate constructs a Predicate from a LabelSelector. Only objects matching the LabelSelector will be admitted. Credit https://github.com/kubernetes-sigs/controller-runtime/blob/v0.10.1/pkg/predicate/predicate.go#L323-L333.
func LogIntoContext ¶
func NewClientConfigLoaderFromBytes ¶
func NewClientConfigLoaderFromBytes(kubeConfig []byte) clientcmd.ClientConfigLoader
func NewClientConfigLoaderFromSecret ¶
func NewClientConfigLoaderFromSecret(kubeConfig *corev1.Secret) clientcmd.ClientConfigLoader
func NewHeadscaleGRPCClient ¶
func NewHeadscaleGRPCClient(url, apiKey string) (v1.HeadscaleServiceClient, error)
NewHeadscaleGRPCClient returns a new gRPC client for the Headscale API.
func NewHeadscaleGRPCSocketClient ¶
func NewHeadscaleGRPCSocketClient(socketPath string) (v1.HeadscaleServiceClient, error)
func NewHeadscaleK8sClientFromRestClientGetter ¶
func NewHeadscaleK8sClientFromRestClientGetter(restClientGetter genericclioptions.RESTClientGetter, proxy, headscaleAddress string) (client.Client, error)
func NewK8sClient ¶
NewK8sClient returns a Kubernetes client with registered schemes for the given config or an error.
func NewK8sClientFromCluster ¶
func NewK8sClientFromCluster(ctx context.Context, c client.Client, cluster *greenhousev1alpha1.Cluster) (client.Client, error)
NewK8sClientFromCluster returns a client.Client based on the given clusters kubeconfig secret.
func NewK8sClientFromRestClientGetter ¶
func NewK8sClientFromRestClientGetter(restClientGetter genericclioptions.RESTClientGetter) (client.Client, error)
NewK8sClientFromRestClientGetter returns a Kubernetes client with registered schemes for the given RESTClientGetter or an error.
func PredicateByName ¶
func PredicateClusterByAccessMode ¶
func PredicateClusterByAccessMode(accessMode greenhousev1alpha1.ClusterAccessMode) predicate.Predicate
func PredicateFilterBySecretType ¶
func PredicateFilterBySecretType(secretType corev1.SecretType) predicate.Predicate
PredicateFilterBySecretType filters secrets by the given type.
func PredicateSecretContainsKey ¶
PredicateSecretContainsKey filters secrets by the given key.
func RemoveFinalizer ¶
RemoveFinalizer removes a finalizer from an object. Returns an error on failure.
Types ¶
type ClientConfigGetter ¶
type ClientConfigGetter struct {
// contains filtered or unexported fields
}
ClientConfigGetter implements the clientcmd.ClientConfigLoader interface.
func (*ClientConfigGetter) GetDefaultFilename ¶
func (g *ClientConfigGetter) GetDefaultFilename() string
func (*ClientConfigGetter) GetExplicitFile ¶
func (g *ClientConfigGetter) GetExplicitFile() string
func (*ClientConfigGetter) GetLoadingPrecedence ¶
func (g *ClientConfigGetter) GetLoadingPrecedence() []string
func (*ClientConfigGetter) GetStartingConfig ¶
func (g *ClientConfigGetter) GetStartingConfig() (*clientcmdapi.Config, error)
func (*ClientConfigGetter) IsDefaultConfig ¶
func (g *ClientConfigGetter) IsDefaultConfig(config *rest.Config) bool
func (*ClientConfigGetter) IsExplicitFile ¶
func (g *ClientConfigGetter) IsExplicitFile() bool
func (*ClientConfigGetter) Load ¶
func (g *ClientConfigGetter) Load() (*clientcmdapi.Config, error)
type DeletionResult ¶
type DeletionResult string
DeletionResult is the action result of a Delete call
const ( // DeletionResultDeleted means that the resource has been deleted DeletionResultDeleted DeletionResult = "deleted" // DeletionResultNotFound means that the resource was not found DeletionResultNotFound DeletionResult = "not found" // DeletionResultNone means that the resource has not been changed DeletionResultNone DeletionResult = "unchanged" )
type KubeClientOption ¶
type KubeClientOption func(*RestClientGetter)
func WithDiscoveryOpts ¶
func WithDiscoveryOpts(qps float32, burst int) KubeClientOption
WithDiscoveryOpts allows overwriting the discovery QPS and Burst
func WithOverrides ¶
func WithOverrides(overrides clientcmd.ConfigOverrides) KubeClientOption
func WithPersistentConfig ¶
func WithPersistentConfig() KubeClientOption
func WithRuntimeOptions ¶
func WithRuntimeOptions(o RuntimeOptions) KubeClientOption
WithRuntimeOptions allows overwriting client QPS and Burst
type OperationResult ¶
type OperationResult string
OperationResult is the action result of a CreateOrUpdate call
const ( // OperationResultNone means that the resource has not been changed OperationResultNone OperationResult = "unchanged" // OperationResultCreated means that a new resource is created OperationResultCreated OperationResult = "created" // OperationResultUpdated means that an existing resource is updated OperationResultUpdated OperationResult = "updated" )
func CreateOrPatch ¶
func CreateOrPatch(ctx context.Context, c client.Client, obj client.Object, mutate func() error) (OperationResult, error)
CreateOrPatch creates or patches the given object using the mutate function. Returns the result and an error.
type RestClientGetter ¶
type RestClientGetter struct {
// contains filtered or unexported fields
}
Implements the genericclioptions.RESTClientGetter interface and additionally allows to access the KubeConfig from Bytes/Secret.
func NewRestClientGetterForInCluster ¶
func NewRestClientGetterForInCluster(namespace string, opts ...KubeClientOption) (*RestClientGetter, error)
func NewRestClientGetterFromBytes ¶
func NewRestClientGetterFromBytes(config []byte, namespace string, opts ...KubeClientOption) *RestClientGetter
NewRestClientGetterFromBytes returns a RestClientGetter from a []bytes containing a Kube Config.
func NewRestClientGetterFromRestConfig ¶
func NewRestClientGetterFromRestConfig(cfg *rest.Config, namespace string, opts ...KubeClientOption) *RestClientGetter
NewRestClientGetterFromRestConfig returns a RestClientGetter from a in-memory kube config.
func NewRestClientGetterFromSecret ¶
func NewRestClientGetterFromSecret(secret *corev1.Secret, namespace string, opts ...KubeClientOption) (*RestClientGetter, error)
NewRestClientGetterFromSecret returns a RestClientGetter from a secret containing a Kube Config.
func (*RestClientGetter) ToDiscoveryClient ¶
func (cg *RestClientGetter) ToDiscoveryClient() (discovery.CachedDiscoveryInterface, error)
func (*RestClientGetter) ToRESTConfig ¶
func (cg *RestClientGetter) ToRESTConfig() (*rest.Config, error)
func (*RestClientGetter) ToRESTMapper ¶
func (cg *RestClientGetter) ToRESTMapper() (meta.RESTMapper, error)
func (*RestClientGetter) ToRawKubeConfigLoader ¶
func (cg *RestClientGetter) ToRawKubeConfigLoader() clientcmd.ClientConfig
type RuntimeOptions ¶
type RuntimeOptions struct { // QPS indicates the maximum QPS to the master from this client. Default is 50. QPS float32 // Maximum burst for throttle. Default is 300. Burst int }
RuntimeOptions contains the runtime options for the Kubernetes client.
func (RuntimeOptions) BindFlags ¶
func (o RuntimeOptions) BindFlags(fs *pflag.FlagSet)
BindFlags will parse the given flagset for runtime option flags and set the runtime options accordingly. Defaults QPS to 50 and Burst to 300 if the flag was not set.