kube

package
v0.7.0-rc5 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2022 License: MPL-2.0 Imports: 29 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 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 InClusterConfigClusterName added in v0.7.0

func InClusterConfigClusterName() string

func RestConfig added in v0.3.2

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

Types

type ClientGetter added in v0.7.0

type ClientGetter interface {
	Client(ctx context.Context) (client.Client, error)
}

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

type ClusterConfig struct {
	DefaultConfig *rest.Config
	ClusterName   string
}

ClusterConfig is used to hold the default *rest.Config and the cluster name.

type ConfigGetter added in v0.7.0

type ConfigGetter interface {
	Config(ctx context.Context) *rest.Config
}

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.

func (*DefaultClientGetter) Client added in v0.7.0

Client creates a new Kubernetes client using the *rest.Config returned from its ConfigGetter.

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.

func (*DefaultKubeGetter) Kube added in v0.7.0

func (g *DefaultKubeGetter) Kube(ctx context.Context) (Kube, error)

Kube creates a new Kube client using the *rest.Config returned from its ConfigGetter.

type ImpersonatingConfigGetter added in v0.7.0

type ImpersonatingConfigGetter struct {
	// contains filtered or unexported fields
}

ImpersonatingConfigGetter is an implementation of the ConfigGetter interface that returns configs based on a base one. It inspects the context for a principal and if it finds one, it configures the *rest.Config to impersonate that principal. Otherwise it returns a copy of the base config.

func NewImpersonatingConfigGetter added in v0.7.0

func NewImpersonatingConfigGetter(cfg *rest.Config, insecure bool) *ImpersonatingConfigGetter

NewImpersonatingConfigGetter creates and returns a ConfigGetter with a known config.

func (*ImpersonatingConfigGetter) Config added in v0.7.0

Config returns a *rest.Config configured to impersonate a user or use the default service account credentials.

type Kube

type Kube interface {
	Apply(ctx context.Context, manifest []byte, namespace string) error
	GetClusterName(ctx context.Context) (string, 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, additionalSchemes ...func(*apiruntime.Scheme) error) (Kube, client.Client, error)

type KubeGetter added in v0.7.0

type KubeGetter interface {
	Kube(ctx context.Context) (Kube, error)
}

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) Apply added in v0.2.0

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

func (*KubeHTTP) GetClusterName added in v0.2.0

func (k *KubeHTTP) GetClusterName(ctx context.Context) (string, 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) Raw added in v0.6.0

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

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
	ConfigRepo    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