config

package
v0.3.11-rc.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2020 License: Apache-2.0 Imports: 17 Imported by: 22

Documentation

Index

Constants

View Source
const (
	// Core providers
	ClusterAPIProviderName = "cluster-api"

	// Infra providers
	AWSProviderName       = "aws"
	AzureProviderName     = "azure"
	DockerProviderName    = "docker"
	DOProviderName        = "digitalocean"
	Metal3ProviderName    = "metal3"
	OpenStackProviderName = "openstack"
	PacketProviderName    = "packet"
	SideroProviderName    = "sidero"
	VSphereProviderName   = "vsphere"

	// Bootstrap providers
	KubeadmBootstrapProviderName = "kubeadm"
	TalosBootstrapProviderName   = "talos"
	AWSEKSBootstrapProviderName  = "aws-eks"

	// ControlPlane providers
	KubeadmControlPlaneProviderName = "kubeadm"
	TalosControlPlaneProviderName   = "talos"
	AWSEKSControlPlaneProviderName  = "aws-eks"

	// Other
	ProvidersConfigKey = "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 (
	// GitHubTokenVariable defines a variable hosting the GitHub access token
	GitHubTokenVariable = "github-token"
)

Variables

This section is empty.

Functions

func InjectConfigPaths added in v0.3.4

func InjectConfigPaths(configPaths []string) viperReaderOption

Types

type Client

type Client interface {
	// 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 configuration of the providers (name, type and URL of the provider repository) 2. Variables used when installing providers/creating clusters. Variables can be read from the environment or from the config file 3. 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 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

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