Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound is when a resource is not found. ErrNotFound = errors.New("resource not found") )
Functions ¶
Types ¶
type Cluster ¶
type Cluster struct {
// Config is the parsed Kubernetes configuration.
Config *clientcmdapi.Config
// Prefix is an optional secret prefix to avoid collisions when the
// same remote os defined in different contexts e.g. create a cluster,
// import that cluster as a region.
Prefix string
}
Cluster identifies a Kubernetes cluster and allows a CD driver to access it for management.
type Driver ¶
type Driver interface {
// Kind allows provisioners to make decisions based on the driver
// in use e.g. if the CD is broken in some way and needs manual
// intervention. Use of this is discouraged, and pull requests will
// be rejected if there's no evidence of an upstream fix to remove
// your hack.
Kind() DriverKind
// ListHelmApplications gets all applications that match the resource identifier.
ListHelmApplications(ctx context.Context, id *ResourceIdentifier) (map[*ResourceIdentifier]*HelmApplication, error)
// CreateOrUpdateHelmApplication creates or updates a helm application idempotently.
CreateOrUpdateHelmApplication(ctx context.Context, id *ResourceIdentifier, app *HelmApplication) error
// DeleteHelmApplication deletes an existing helm application.
DeleteHelmApplication(ctx context.Context, id *ResourceIdentifier, backgroundDelete bool) error
// CreateOrUpdateCluster creates or updates a cluster idempotently.
CreateOrUpdateCluster(ctx context.Context, id *ResourceIdentifier, cluster *Cluster) error
// DeleteCluster deletes an existing cluster.
DeleteCluster(ctx context.Context, id *ResourceIdentifier) error
}
Driver is an abstraction around CD tools such as ArgoCD or Flux, this is a low level driver interface that configures things like remote clusters and Helm applications.
func FromContext ¶
type DriverKind ¶
type DriverKind string
DriverKind allows the provisioners to make CD specific hacks for when the underlying provider is broken in some way.
const (
DriverKindArgoCD DriverKind = "argocd"
)
type DriverKindFlag ¶
type DriverKindFlag struct {
Kind DriverKind
}
DriverKindFlag wraps up the driver kind in a flag that can be used on the CLI.
func (*DriverKindFlag) Set ¶
func (s *DriverKindFlag) Set(in string) error
Set implemenets the pflag.Value interface.
func (*DriverKindFlag) String ¶
func (s *DriverKindFlag) String() string
String implemenets the pflag.Value interface.
func (*DriverKindFlag) Type ¶
func (s *DriverKindFlag) Type() string
Type implemenets the pflag.Value interface.
type HelmApplication ¶
type HelmApplication struct {
// Repo is a URL to either a Helm or Git repository.
Repo string
// Chart is required when using a Helm repository.
Chart string
// Branch is required when using a Git repository.
Branch string
// Path is required when using a Git repository.
Path string
// Version is either the Helm chart version, or a Git branch, tag or
// hash.
Version string
// Release is the name of the release.
Release string
// Parameters is a set of Helm value overrides.
Parameters []HelmApplicationParameter
// Values is an interface to an arbitrary data structure that can
// be marshaled into a values.yaml file. The idea here is you can
// generate values file data types from a values.schema.json, or
// just thown in a free-form map[string]interface{} thing.
Values interface{}
// Cluster identifies the cluster to install on to.
// By definition we require the CD provider to support multiple
// clusters to support cluster manager lane virtual clusters, and the
// CAPI Kubernetes clusters we create.
Cluster *ResourceIdentifier
// Namespace identifies the namespace to install in to.
Namespace string
// CreateNamespace defines that the CD provider must create the
// namespace as the chart does not.
CreateNamespace bool
// IgnoreDifferences can be set when the driver support self-healing
// e.g. reversion of manual changes. This is important as the CD
// may do a diff, and constantly reconcile due to resource mutation
// by an external controller.
IgnoreDifferences []HelmApplicationField
// ServerSideApply may be implemented by a driver. It avoids large
// annotations, especially for CRDs, that may fail due to buffer overflow.
// TODO: This is the default in flux2 (v0.18.0), and can be deprecated if
// argo can be moved to using it by default.
ServerSideApply bool
// AllowDegraded allows us to tolerate degraded state and allow a success
// to be reported rather than a failure.
AllowDegraded bool
}
HelmApplication defines a driver agnostic Helm application.
type HelmApplicationField ¶
HelmApplicationField identifies JSON paths within a resource type.
type HelmApplicationParameter ¶
type HelmApplicationParameter struct {
// Name is a json path the to the parameter.
Name string
// Value is the value of the parameter. The value may
// be anything supported by Helm's --set flag.
Value string
}
HelmApplicationParameter defines a single key/value parameter to be passed to Helm. How it is passed may be via a values.yaml or --set CLI flag as decided by the ContinuousDeployment driver.
type ResourceIdentifier ¶
type ResourceIdentifier struct {
// Name can either be a unique name, in which case labels are
// not required, or a generic name that may be used more than
// once, in which case you will need labels to add context to
// make it unique.
Name string
// Labels specify the context of a name. For example if we have
// an application called "nginx", then it would alias with other
// instances of it. Labels provide a way to inject context e.g.
// I live in namespace X, on cluster Y.
Labels []ResourceIdentifierLabel
}
ResourceIdentifier allows a HelmApplication or a Cluster to be uniquely identified by the CD driver. How it uses this information is specific to the driver.
type ResourceIdentifierLabel ¶
type ResourceIdentifierLabel struct {
// Name is the label name.
Name string
// Value is the label value.
Value string
}
ResourceIdentifierLabel is a single key/value pair that can be used to specify context in a resource identifier.