config

package
v0.3.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2020 License: Apache-2.0 Imports: 11 Imported by: 23

Documentation

Index

Constants

View Source
const (
	ClusterAPIProviderName          = "cluster-api"
	KubeadmBootstrapProviderName    = "kubeadm"
	KubeadmControlPlaneProviderName = "kubeadm"
	AWSProviderName                 = "aws"
	AzureProviderName               = "azure"
	Metal3ProviderName              = "metal3"
	OpenStackProviderName           = "openstack"
	VSphereProviderName             = "vsphere"
	ProvidersConfigKey              = "providers"
)
View Source
const ConfigFolder = ".cluster-api"

ConfigFolder defines the name of the config folder under $home

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

Variables

This section is empty.

Functions

This section is empty.

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
}

Client is used to interact with the clusterctl configurations. Clusterctl v2 handles two types of configs: 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

func New

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

New returns a Client for interacting with the clusterctl configuration.

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