kube

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2022 License: MPL-2.0 Imports: 33 Imported by: 14

Documentation

Index

Constants

View Source
const FluxNamespace = "flux-system"
View Source
const WeGOCRDName = "apps.wego.weave.works"
View Source
const (
	WegoConfigMapName = "weave-gitops-config"
)

Variables

View Source
var (
	GVRSecret         schema.GroupVersionResource = corev1.SchemeGroupVersion.WithResource("secrets")
	GVRApp            schema.GroupVersionResource = wego.GroupVersion.WithResource("apps")
	GVRKustomization  schema.GroupVersionResource = kustomizev2.GroupVersion.WithResource("kustomizations")
	GVRGitRepository  schema.GroupVersionResource = sourcev1.GroupVersion.WithResource("gitrepositories")
	GVRHelmRepository schema.GroupVersionResource = sourcev1.GroupVersion.WithResource("helmrepositories")
	GVRHelmRelease    schema.GroupVersionResource = helmv2.GroupVersion.WithResource("helmreleases")
)
View Source
var ErrNamespaceNotFound = errors.New("namespace not found")
View Source
var (
	//ErrWegoConfigNotFound indicates weave gitops config could not be found
	ErrWegoConfigNotFound = errors.New("Wego Config not found")
)
View Source
var InClusterConfig func() (*rest.Config, error) = func() (*rest.Config, error) {
	return rest.InClusterConfig()
}

InClusterConfig defines a function for checking if this code is executing in kubernetes. This can be overriden if needed.

Functions

func CreateScheme added in v0.2.0

func CreateScheme() *apiruntime.Scheme

func IsClusterReady added in v0.5.0

func IsClusterReady(l logger.Logger, k Kube) error

func RestConfig added in v0.3.2

func RestConfig() (*rest.Config, string, error)

Types

type ClusterStatus

type ClusterStatus int
const (
	Unknown ClusterStatus = iota
	Unmodified
	FluxInstalled
	GitOpsInstalled
)

func (ClusterStatus) String

func (cs ClusterStatus) String() string

Function to translate ClusterStatus to a string

type Kube

type Kube interface {
	Apply(ctx context.Context, manifest []byte, namespace string) error
	Delete(ctx context.Context, manifest []byte) error
	DeleteByName(ctx context.Context, name string, gvr schema.GroupVersionResource, namespace string) error
	SecretPresent(ctx context.Context, string, namespace string) (bool, error)
	GetApplications(ctx context.Context, namespace string) ([]wego.Application, error)
	FluxPresent(ctx context.Context) (bool, error)
	NamespacePresent(ctx context.Context, namespace string) (bool, error)
	GetClusterName(ctx context.Context) (string, error)
	GetClusterStatus(ctx context.Context) ClusterStatus
	GetApplication(ctx context.Context, name types.NamespacedName) (*wego.Application, error)
	GetResource(ctx context.Context, name types.NamespacedName, resource Resource) error
	SetResource(ctx context.Context, resource Resource) error
	GetSecret(ctx context.Context, name types.NamespacedName) (*corev1.Secret, error)
	FetchNamespaceWithLabel(ctx context.Context, key string, value string) (*corev1.Namespace, error)
	SetWegoConfig(ctx context.Context, config WegoConfig, namespace string) (*corev1.ConfigMap, error)
	GetWegoConfig(ctx context.Context, namespace string) (*WegoConfig, error)
	Raw() client.Client
}

func NewKubeHTTPClient added in v0.2.0

func NewKubeHTTPClient() (Kube, client.Client, error)

func NewKubeHTTPClientWithConfig added in v0.4.1

func NewKubeHTTPClientWithConfig(config *rest.Config, contextName string) (Kube, client.Client, error)

type KubeHTTP added in v0.2.0

type KubeHTTP struct {
	Client      client.Client
	ClusterName string
	DynClient   dynamic.Interface
	RestMapper  meta.RESTMapper
}

This is an alternative implementation of the kube.Kube interface, specifically designed to query the K8s API directly instead of relying on `kubectl` to be present in the PATH.

func (*KubeHTTP) Apply added in v0.2.0

func (k *KubeHTTP) Apply(ctx context.Context, manifest []byte, namespace string) error

func (*KubeHTTP) Delete added in v0.2.0

func (k *KubeHTTP) Delete(ctx context.Context, manifest []byte) error

func (*KubeHTTP) DeleteByName added in v0.2.3

func (c *KubeHTTP) DeleteByName(ctx context.Context, name string, gvr schema.GroupVersionResource, namespace string) error

func (*KubeHTTP) FetchNamespaceWithLabel added in v0.6.1

func (k *KubeHTTP) FetchNamespaceWithLabel(ctx context.Context, key string, value string) (*corev1.Namespace, error)

FetchNamespaceWithLabel fetches a namespace where a label follows key=value

func (*KubeHTTP) FluxPresent added in v0.2.0

func (k *KubeHTTP) FluxPresent(ctx context.Context) (bool, error)

func (*KubeHTTP) GetApplication added in v0.2.0

func (k *KubeHTTP) GetApplication(ctx context.Context, name types.NamespacedName) (*wego.Application, error)

func (*KubeHTTP) GetApplications added in v0.2.0

func (k *KubeHTTP) GetApplications(ctx context.Context, namespace string) ([]wego.Application, error)

func (*KubeHTTP) GetClusterName added in v0.2.0

func (k *KubeHTTP) GetClusterName(ctx context.Context) (string, error)

func (*KubeHTTP) GetClusterStatus added in v0.2.0

func (k *KubeHTTP) GetClusterStatus(ctx context.Context) ClusterStatus

func (*KubeHTTP) GetResource added in v0.2.1

func (k *KubeHTTP) GetResource(ctx context.Context, name types.NamespacedName, resource Resource) error

func (KubeHTTP) GetSecret added in v0.2.5

func (k KubeHTTP) GetSecret(ctx context.Context, name types.NamespacedName) (*corev1.Secret, error)

func (*KubeHTTP) GetWegoConfig added in v0.6.0

func (k *KubeHTTP) GetWegoConfig(ctx context.Context, namespace string) (*WegoConfig, error)

GetWegoConfig fetches the wego config saved in the cluster in a given namespace. If an empty namespace is passed it will search in all namespaces and return the first one it finds.

func (*KubeHTTP) NamespacePresent added in v0.3.2

func (k *KubeHTTP) NamespacePresent(ctx context.Context, namespace string) (bool, error)

func (*KubeHTTP) Raw added in v0.6.0

func (k *KubeHTTP) Raw() client.Client

func (*KubeHTTP) SecretPresent added in v0.2.0

func (k *KubeHTTP) SecretPresent(ctx context.Context, secretName string, namespace string) (bool, error)

func (*KubeHTTP) SetResource added in v0.4.1

func (k *KubeHTTP) SetResource(ctx context.Context, resource Resource) error

func (*KubeHTTP) SetWegoConfig added in v0.6.0

func (k *KubeHTTP) SetWegoConfig(ctx context.Context, config WegoConfig, namespace string) (*corev1.ConfigMap, error)

type Resource added in v0.2.1

type Resource interface {
	client.Object
}

type WegoConfig added in v0.6.0

type WegoConfig struct {
	FluxNamespace string
	WegoNamespace string
}

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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