Documentation ¶
Index ¶
- type ClusterClient
- func NewFakeClusterClient(ctx context.Context, config *ClusterClientConfig) (ClusterClient, error)
- func NewFakeClusterClientError(ctx context.Context, config *ClusterClientConfig) (ClusterClient, error)
- func NewKubeClusterClient(ctx context.Context, config *ClusterClientConfig) (ClusterClient, error)
- type ClusterClientConfig
- type ClusterClientGenerator
- type FakeClusterClient
- func (cc *FakeClusterClient) Apply(ctx context.Context, paths []string, serverSide bool) ([]byte, error)
- func (cc *FakeClusterClient) ApplyStructured(ctx context.Context, paths []string, serverSide bool) ([]apply.Result, error)
- func (cc *FakeClusterClient) Close() error
- func (cc *FakeClusterClient) Config() *config.ClusterConfig
- func (cc *FakeClusterClient) Diff(ctx context.Context, paths []string, serverSide bool) ([]byte, error)
- func (cc *FakeClusterClient) DiffStructured(ctx context.Context, paths []string, serverSide bool) ([]diff.Result, error)
- func (cc *FakeClusterClient) GetNamespaceUID(ctx context.Context, namespace string) (string, error)
- func (cc *FakeClusterClient) GetStoreValue(ctx context.Context, key string) (string, error)
- func (cc *FakeClusterClient) SetStoreValue(ctx context.Context, key string, value string) error
- func (cc *FakeClusterClient) Summary(ctx context.Context) (string, error)
- type KubeClusterClient
- func (cc *KubeClusterClient) Apply(ctx context.Context, paths []string, serverSide bool) ([]byte, error)
- func (cc *KubeClusterClient) ApplyStructured(ctx context.Context, paths []string, serverSide bool) ([]apply.Result, error)
- func (cc *KubeClusterClient) Close() error
- func (cc *KubeClusterClient) Config() *config.ClusterConfig
- func (cc *KubeClusterClient) Diff(ctx context.Context, paths []string, serverSide bool) ([]byte, error)
- func (cc *KubeClusterClient) DiffStructured(ctx context.Context, paths []string, serverSide bool) ([]diff.Result, error)
- func (cc *KubeClusterClient) GetNamespaceUID(ctx context.Context, namespace string) (string, error)
- func (cc *KubeClusterClient) GetStoreValue(ctx context.Context, key string) (string, error)
- func (cc *KubeClusterClient) SetStoreValue(ctx context.Context, key string, value string) error
- func (cc *KubeClusterClient) Summary(ctx context.Context) (string, error)
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. DiffStructured(ctx context.Context, paths []string, serverSide bool) ([]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, ) ([]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 ¶
GetStoreValue gets the value of the argument key.
func (*FakeClusterClient) SetStoreValue ¶
SetStoreValue sets the argument key to the argument value.
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, ) ([]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 ¶
GetStoreValue gets the value of the argument key.
func (*KubeClusterClient) SetStoreValue ¶
SetStoreValue sets the value of the argument key to the argument value.