cluster

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2022 License: MIT Imports: 20 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClusterClient

type ClusterClient interface {
	// Apply applies all of the configs at the given path.
	Apply(ctx context.Context, paths []string, serverSide bool) ([]byte, error)

	// ApplyStructured applies all of the configs at the given path and returns structured,
	// as opposed to raw, outputs
	ApplyStructured(ctx context.Context, paths []string, serverSide bool) ([]apply.Result, error)

	// Diff gets the diffs between the configs at the given path and the actual state of resources
	// in the cluster.
	Diff(ctx context.Context, paths []string, serverSide bool) ([]byte, error)

	// Diff gets the diffs between the configs at the given path and the actual state of resources
	// in the cluster.
	//
	// The diffCommand argument can be set to use a custom diff command in place of the default
	// (kubeapply kdiff).
	DiffStructured(
		ctx context.Context,
		paths []string,
		serverSide bool,
		diffCommand string,
	) ([]diff.Result, error)

	// Summary returns a summary of all workloads in the cluster.
	Summary(ctx context.Context) (string, error)

	// GetStoreValue gets the value of the given key.
	GetStoreValue(ctx context.Context, key string) (string, error)

	// SetStoreValue sets the given key/value pair in the cluster.
	SetStoreValue(ctx context.Context, key string, value string) error

	// Config returns the config for this cluster.
	Config() *config.ClusterConfig

	// GetNamespaceUID returns the kubernetes identifier for a given namespace in this cluster.
	GetNamespaceUID(ctx context.Context, namespace string) (string, error)

	// Close cleans up this client.
	Close() error
}

ClusterClient is an interface that interacts with the API of a single Kubernetes cluster.

func NewFakeClusterClient

func NewFakeClusterClient(
	ctx context.Context,
	config *ClusterClientConfig,
) (ClusterClient, error)

NewFakeClusterClient returns a FakeClusterClient that works without errors.

func NewFakeClusterClientError

func NewFakeClusterClientError(
	ctx context.Context,
	config *ClusterClientConfig,
) (ClusterClient, error)

NewFakeClusterClientError returns a FakeClusterClient that simulates an error when running kubectl.

func NewKubeClusterClient

func NewKubeClusterClient(
	ctx context.Context,
	config *ClusterClientConfig,
) (ClusterClient, error)

NewKubeClusterClient creates a new ClusterClient instance for a real Kubernetes cluster.

type ClusterClientConfig

type ClusterClientConfig struct {
	// CheckApplyConsistency indicates whether we should check whether an apply is done with
	// the same SHA as the last diff in the cluster.
	CheckApplyConsistency bool

	// ClusterConfig is the config for the cluster that we are communicating with.
	ClusterConfig *config.ClusterConfig

	// Debug indicates whether commands should be run with debug-level logging.
	Debug bool

	// KeepConfigs indicates whether kube client should keep around intermediate
	// yaml manifests. These are useful for debugging when there are apply errors.
	KeepConfigs bool

	// HeadSHA is the SHA of the current branch. Used for consistency checking, can be omitted
	// if that option is false.
	HeadSHA string

	// UseColors indicates whether output should include colors. Currently only applies to diff
	// operations.
	UseColors bool

	// UseLocks indicates whether a cluster-specific lock should be acquired before any diff
	// and expand operations.
	UseLocks bool

	// SpinnerObj is a pointer to a Spinner instance. If unset, no spinner is used. Currently
	// only applies to diff operations.
	SpinnerObj *spinner.Spinner

	// StreamingOutput indicates whether results should be streamed out to stdout and stderr.
	// Currently only applies to apply operations.
	StreamingOutput bool
}

ClusterClientConfig stores the configuration necessary to create a ClusterClient.

type ClusterClientGenerator

type ClusterClientGenerator func(
	ctx context.Context,
	config *ClusterClientConfig,
) (ClusterClient, error)

ClusterClientGenerator generates a ClusterClient from a config.

type FakeClusterClient

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

FakeClusterClient is a fake implementation of a ClusterClient. For testing purposes only.

func (*FakeClusterClient) Apply

func (cc *FakeClusterClient) Apply(
	ctx context.Context,
	paths []string,
	serverSide bool,
) ([]byte, error)

Apply runs a fake apply using the configs in the argument path.

func (*FakeClusterClient) ApplyStructured

func (cc *FakeClusterClient) ApplyStructured(
	ctx context.Context,
	paths []string,
	serverSide bool,
) ([]apply.Result, error)

ApplyStructured runs a fake structured apply using the configs in the argument path.

func (*FakeClusterClient) Close

func (cc *FakeClusterClient) Close() error

Close closes the client.

func (*FakeClusterClient) Config

func (cc *FakeClusterClient) Config() *config.ClusterConfig

Config returns this client's cluster config.

func (*FakeClusterClient) Diff

func (cc *FakeClusterClient) Diff(
	ctx context.Context,
	paths []string,
	serverSide bool,
) ([]byte, error)

Diff runs a fake diff using the configs in the argument path.

func (*FakeClusterClient) DiffStructured

func (cc *FakeClusterClient) DiffStructured(
	ctx context.Context,
	paths []string,
	serverSide bool,
	diffCommand string,
) ([]diff.Result, error)

Diff runs a fake diff using the configs in the argument path.

func (*FakeClusterClient) GetNamespaceUID

func (cc *FakeClusterClient) GetNamespaceUID(
	ctx context.Context,
	namespace string,
) (string, error)

GetNamespaceUID returns the kubernetes identifier for a given namespace in this cluster.

func (*FakeClusterClient) GetStoreValue

func (cc *FakeClusterClient) GetStoreValue(ctx context.Context, key string) (string, error)

GetStoreValue gets the value of the argument key.

func (*FakeClusterClient) SetStoreValue

func (cc *FakeClusterClient) SetStoreValue(ctx context.Context, key string, value string) error

SetStoreValue sets the argument key to the argument value.

func (*FakeClusterClient) Summary

func (cc *FakeClusterClient) Summary(ctx context.Context) (string, error)

Summary creates a fake summary output of the current cluster state.

type KubeClusterClient

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

KubeClusterClient is an implementation of a ClusterClient that hits an actual Kubernetes API. It's backed by a kube.OrderedClient which, in turn, wraps kubectl.

func (*KubeClusterClient) Apply

func (cc *KubeClusterClient) Apply(
	ctx context.Context,
	paths []string,
	serverSide bool,
) ([]byte, error)

Apply does a kubectl apply for the resources at the argument path.

func (*KubeClusterClient) ApplyStructured

func (cc *KubeClusterClient) ApplyStructured(
	ctx context.Context,
	paths []string,
	serverSide bool,
) ([]apply.Result, error)

ApplyStructured does a structured kubectl apply for the resources at the argument path.

func (*KubeClusterClient) Close

func (cc *KubeClusterClient) Close() error

Close closes the client and cleans up all of the associated resources.

func (*KubeClusterClient) Config

func (cc *KubeClusterClient) Config() *config.ClusterConfig

Config returns this client's cluster config.

func (*KubeClusterClient) Diff

func (cc *KubeClusterClient) Diff(
	ctx context.Context,
	paths []string,
	serverSide bool,
) ([]byte, error)

Diff runs a kubectl diff between the configs at the argument path and the associated resources in the cluster. It returns raw output that can be immediately printed to the console.

func (*KubeClusterClient) DiffStructured

func (cc *KubeClusterClient) DiffStructured(
	ctx context.Context,
	paths []string,
	serverSide bool,
	diffCommand string,
) ([]diff.Result, error)

DiffStructured runs a kubectl diff between the configs at the argument path and the associated resources in the cluster. It returns a structured result that can be used printed to a table.

func (*KubeClusterClient) GetNamespaceUID

func (cc *KubeClusterClient) GetNamespaceUID(
	ctx context.Context,
	namespace string,
) (string, error)

GetNamespaceUID returns the kubernetes identifier for a given namespace in this cluster.

func (*KubeClusterClient) GetStoreValue

func (cc *KubeClusterClient) GetStoreValue(ctx context.Context, key string) (string, error)

GetStoreValue gets the value of the argument key.

func (*KubeClusterClient) SetStoreValue

func (cc *KubeClusterClient) SetStoreValue(ctx context.Context, key string, value string) error

SetStoreValue sets the value of the argument key to the argument value.

func (*KubeClusterClient) Summary

func (cc *KubeClusterClient) Summary(ctx context.Context) (string, error)

Summary returns a summary of the current cluster state.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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