config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2021 License: Apache-2.0 Imports: 18 Imported by: 22

Documentation

Overview

Package config implements clusterctl config functionality.

Index

Constants

View Source
const (
	// CertManagerConfigKey defines the name of the top level config key for cert-manager configuration.
	CertManagerConfigKey = "cert-manager"

	// CertManagerDefaultVersion defines the default cert-manager version to be used by clusterctl.
	CertManagerDefaultVersion = "v1.5.3"

	// CertManagerDefaultURL defines the default cert-manager repository url to be used by clusterctl.
	// NOTE: At runtime /latest will be replaced with the CertManagerDefaultVersion or with the
	// version defined by the user in the clusterctl configuration file.
	CertManagerDefaultURL = "https://github.com/jetstack/cert-manager/releases/latest/cert-manager.yaml"

	// CertManagerDefaultTimeout defines the default cert-manager timeout to be used by clusterctl.
	CertManagerDefaultTimeout = 10 * time.Minute
)
View Source
const (
	AWSProviderName       = "aws"
	AzureProviderName     = "azure"
	DockerProviderName    = "docker"
	DOProviderName        = "digitalocean"
	GCPProviderName       = "gcp"
	Metal3ProviderName    = "metal3"
	NestedProviderName    = "nested"
	OpenStackProviderName = "openstack"
	PacketProviderName    = "packet"
	SideroProviderName    = "sidero"
	VSphereProviderName   = "vsphere"
	MAASProviderName      = "maas"
)

Infra providers.

View Source
const (
	KubeadmBootstrapProviderName = "kubeadm"
	TalosBootstrapProviderName   = "talos"
	AWSEKSBootstrapProviderName  = "aws-eks"
)

Bootstrap providers.

View Source
const (
	KubeadmControlPlaneProviderName = "kubeadm"
	TalosControlPlaneProviderName   = "talos"
	AWSEKSControlPlaneProviderName  = "aws-eks"
	NestedControlPlaneProviderName  = "nested"
)

ControlPlane providers.

View Source
const (
	// ConfigFolder defines the name of the config folder under $home.
	ConfigFolder = ".cluster-api"
	// ConfigName defines the name of the config file under ConfigFolder.
	ConfigName = "clusterctl"
	// DownloadConfigFile is the config file when fetching the config from a remote location.
	DownloadConfigFile = "clusterctl-download.yaml"
)
View Source
const (
	// CertManagerImageComponent define the name of the cert-manager component in image overrides.
	CertManagerImageComponent = "cert-manager"
)
View Source
const (
	ClusterAPIProviderName = "cluster-api"
)

Core providers.

View Source
const (
	// GitHubTokenVariable defines a variable hosting the GitHub access token.
	GitHubTokenVariable = "github-token"
)
View Source
const (
	ProvidersConfigKey = "providers"
)

Other.

Variables

This section is empty.

Functions

This section is empty.

Types

type CertManager added in v0.4.0

type CertManager interface {
	// URL returns the name of the cert-manager repository.
	// If empty, "https://github.com/jetstack/cert-manager/releases/latest/cert-manager.yaml" will be used.
	URL() string

	// Version returns the cert-manager version to install.
	// If empty, a default version will be used.
	Version() string

	// Timeout returns the timeout for cert-manager to start.
	// If empty, 10m will will be used.
	Timeout() string
}

CertManager defines cert-manager configuration.

func NewCertManager added in v0.4.0

func NewCertManager(url, version, timeout string) CertManager

NewCertManager creates a new CertManager with the given configuration.

type CertManagerClient added in v0.4.0

type CertManagerClient interface {
	// Get returns the cert-manager configuration.
	Get() (CertManager, error)
}

CertManagerClient has methods to work with cert-manager configurations.

type Client

type Client interface {
	// CertManager provide access to the cert-manager configurations.
	CertManager() CertManagerClient

	// Providers provide access to provider configurations.
	Providers() ProvidersClient

	// Variables provide access to environment variables and/or variables defined in the clusterctl configuration file.
	Variables() VariablesClient

	// ImageMeta provide access to to image meta configurations.
	ImageMeta() ImageMetaClient
}

Client is used to interact with the clusterctl configurations. Clusterctl v2 handles the following configurations: 1. The cert manager configuration (URL of the repository) 2. The configuration of the providers (name, type and URL of the provider repository) 3. Variables used when installing providers/creating clusters. Variables can be read from the environment or from the config file 4. The configuration about image overrides.

func New

func New(path string, options ...Option) (Client, error)

New returns a Client for interacting with the clusterctl configuration.

type ImageMetaClient

type ImageMetaClient interface {
	// AlterImage alters an image name according to the current image override configurations.
	AlterImage(component, image string) (string, error)
}

ImageMetaClient has methods to work with image meta configurations.

type MemoryReader added in v0.4.3

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

MemoryReader provides a reader implementation backed by a map. This is to be used by the operator to place config from a secret and the ProviderSpec.Fetchconfig.

func NewMemoryReader added in v0.4.3

func NewMemoryReader() *MemoryReader

NewMemoryReader return a new MemoryReader.

func (*MemoryReader) AddProvider added in v0.4.3

func (f *MemoryReader) AddProvider(name string, ttype clusterctlv1.ProviderType, url string) (*MemoryReader, error)

AddProvider adds the given provider to the "providers" map entry and returns any errors.

func (*MemoryReader) Get added in v0.4.3

func (f *MemoryReader) Get(key string) (string, error)

Get gets a value for the given key.

func (*MemoryReader) Init added in v0.4.3

func (f *MemoryReader) Init(_ string) error

Init initialize the reader.

func (*MemoryReader) Set added in v0.4.3

func (f *MemoryReader) Set(key, value string)

Set sets a value for the given key.

func (*MemoryReader) UnmarshalKey added in v0.4.3

func (f *MemoryReader) UnmarshalKey(key string, rawval interface{}) error

UnmarshalKey gets a value for the given key, then unmarshal it.

type Option

type Option func(*configClient)

Option is a configuration option supplied to New.

func InjectReader

func InjectReader(reader Reader) Option

InjectReader allows to override the default configuration reader used by clusterctl.

type Provider

type Provider interface {
	// Name returns the name of the provider.
	Name() string

	// Type returns the type of the provider.
	Type() clusterctlv1.ProviderType

	// URL returns the name of the provider repository.
	URL() string

	// SameAs returns true if two providers have the same name and type.
	// Please note that this uniquely identifies a provider configuration, but not the provider instances in the cluster
	// because it is possible to create many instances of the same provider.
	SameAs(other Provider) bool

	// ManifestLabel returns the cluster.x-k8s.io/provider label value for a provider.
	// Please note that this label uniquely identifies the provider, e.g. bootstrap-kubeadm, but not the instances of
	// the provider, e.g. namespace-1/bootstrap-kubeadm and namespace-2/bootstrap-kubeadm
	ManifestLabel() string

	// Less func can be used to ensure a consist order of provider lists.
	Less(other Provider) bool
}

Provider defines a provider configuration.

func NewProvider

func NewProvider(name string, url string, ttype clusterctlv1.ProviderType) Provider

NewProvider creates a new Provider with the given input.

type ProvidersClient

type ProvidersClient interface {
	// List returns all the provider configurations, including provider configurations hard-coded in clusterctl
	// and user-defined provider configurations read from the clusterctl configuration file.
	// In case of conflict, user-defined provider override the hard-coded configurations.
	List() ([]Provider, error)

	// Get returns the configuration for the provider with a given name/type.
	// In case the name/type does not correspond to any existing provider, an error is returned.
	Get(name string, providerType clusterctlv1.ProviderType) (Provider, error)
}

ProvidersClient has methods to work with provider configurations.

type Reader

type Reader interface {
	// Init allows to initialize the configuration reader.
	Init(path string) error

	// Get returns a configuration value of type string.
	// In case the configuration value does not exists, it returns an error.
	Get(key string) (string, error)

	// Set allows to set an explicit override for a config value.
	// e.g. It is used to set an override from a flag value over environment/config file variables.
	Set(key, value string)

	// UnmarshalKey reads a configuration value and unmarshals it into the provided value object.
	UnmarshalKey(key string, value interface{}) error
}

Reader define the behaviours of a configuration reader.

type VariablesClient

type VariablesClient interface {
	// Get returns a variable value. If the variable is not defined an error is returned.
	// In case the same variable is defined both within the environment variables and clusterctl configuration file,
	// the environment variables value takes precedence.
	Get(key string) (string, error)

	// Set allows to set an explicit override for a config value.
	// e.g. It is used to set an override from a flag value over environment/config file variables.
	Set(key, values string)
}

VariablesClient has methods to work with environment variables and with variables defined in the clusterctl configuration file.

Jump to

Keyboard shortcuts

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