Documentation
¶
Index ¶
- Constants
- Variables
- func CreateScheme() *apiruntime.Scheme
- func IsClusterReady(l logger.Logger, k Kube) error
- func RestConfig() (*rest.Config, string, error)
- type ClientGetter
- type ClusterConfig
- type ClusterStatus
- type ConfigGetter
- type DefaultClientGetter
- type DefaultKubeGetter
- type Kube
- type KubeGetter
- type KubeHTTP
- func (k *KubeHTTP) Apply(ctx context.Context, manifest []byte, namespace string) error
- func (k *KubeHTTP) Delete(ctx context.Context, manifest []byte) error
- func (c *KubeHTTP) DeleteByName(ctx context.Context, name string, gvr schema.GroupVersionResource, ...) error
- func (k *KubeHTTP) FetchNamespaceWithLabel(ctx context.Context, key string, value string) (*corev1.Namespace, error)
- func (k *KubeHTTP) FluxPresent(ctx context.Context) (bool, error)
- func (k *KubeHTTP) GetApplication(ctx context.Context, name types.NamespacedName) (*wego.Application, error)
- func (k *KubeHTTP) GetApplications(ctx context.Context, namespace string) ([]wego.Application, error)
- func (k *KubeHTTP) GetClusterName(ctx context.Context) (string, error)
- func (k *KubeHTTP) GetClusterStatus(ctx context.Context) ClusterStatus
- func (k *KubeHTTP) GetResource(ctx context.Context, name types.NamespacedName, resource Resource) error
- func (k KubeHTTP) GetSecret(ctx context.Context, name types.NamespacedName) (*corev1.Secret, error)
- func (k *KubeHTTP) GetWegoConfig(ctx context.Context, namespace string) (*WegoConfig, error)
- func (k *KubeHTTP) NamespacePresent(ctx context.Context, namespace string) (bool, error)
- func (k *KubeHTTP) Raw() client.Client
- func (k *KubeHTTP) SecretPresent(ctx context.Context, secretName string, namespace string) (bool, error)
- func (k *KubeHTTP) SetResource(ctx context.Context, resource Resource) error
- func (k *KubeHTTP) SetWegoConfig(ctx context.Context, config WegoConfig, namespace string) (*corev1.ConfigMap, error)
- type Resource
- type WegoConfig
Constants ¶
const FluxNamespace = "flux-system"
const WeGOCRDName = "apps.wego.weave.works"
const (
WegoConfigMapName = "weave-gitops-config"
)
Variables ¶
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") )
var ErrNamespaceNotFound = errors.New("namespace not found")
var ( //ErrWegoConfigNotFound indicates weave gitops config could not be found ErrWegoConfigNotFound = errors.New("Wego Config not found") )
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
Types ¶
type ClientGetter ¶ added in v0.7.0
ClientGetter implementations should create a Kubernetes client from a context.
func NewDefaultClientGetter ¶ added in v0.7.0
func NewDefaultClientGetter(configGetter ConfigGetter, clusterName string, schemeBuilder ...func(*runtime.Scheme) error) ClientGetter
NewDefaultClientGetter creates a new DefaultClientGetter
type ClusterConfig ¶ added in v0.7.0
ClusterConfig is used to hold the default *rest.Config and the cluster name.
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 ConfigGetter ¶ added in v0.7.0
ConfigGetter implementations should extract the details from a context and create a *rest.Config for use in clients.
type DefaultClientGetter ¶ added in v0.7.0
type DefaultClientGetter struct {
// contains filtered or unexported fields
}
DefaultClientGetter implements the ClientGetter interface and uses a ConfigGetter to get a *rest.Config and create a Kubernetes client.
type DefaultKubeGetter ¶ added in v0.7.0
type DefaultKubeGetter struct {
// contains filtered or unexported fields
}
DefaultKubeGetter implements the KubeGetter interface and uses a ConfigGetter to get a *rest.Config and create a Kube client.
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
}
type KubeGetter ¶ added in v0.7.0
KubeGetter implementations should create a Kube client from a context.
func NewDefaultKubeGetter ¶ added in v0.7.0
func NewDefaultKubeGetter(configGetter ConfigGetter, clusterName string) KubeGetter
NewDefaultKubeGetter creates a new DefaultKubeGetter
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) DeleteByName ¶ added in v0.2.3
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 (*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 (*KubeHTTP) GetClusterName ¶ added in v0.2.0
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 (*KubeHTTP) GetWegoConfig ¶ added in v0.6.0
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.