repository

package
v0.3.16 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2021 License: Apache-2.0 Imports: 29 Imported by: 7

Documentation

Index

Constants

View Source
const (
	WebhookNamespaceName = "capi-webhook-system"
)

Variables

This section is empty.

Functions

func NewComponents

func NewComponents(input ComponentsInput) (*components, error)

NewComponents returns a new objects embedding a component YAML file

It is important to notice that clusterctl applies a set of processing steps to the “raw” component YAML read from the provider repositories: 1. Checks for all the variables in the component YAML file and replace with corresponding config values 2. The variables replacement can be skipped using the SkipVariables flag in the input options 3. Ensure all the provider components are deployed in the target namespace (apply only to namespaced objects) 4. Ensure all the ClusterRoleBinding which are referencing namespaced objects have the name prefixed with the namespace name 5. Set the watching namespace for the provider controller 6. Adds labels to all the components in order to allow easy identification of the provider objects

func NewTemplate

func NewTemplate(input TemplateInput) (*template, error)

NewTemplate returns a new objects embedding a cluster template YAML file.

Types

type Client

type Client interface {
	config.Provider

	// GetVersion return the list of versions that are available in a provider repository
	GetVersions() ([]string, error)

	// Components provide access to YAML file for creating provider components.
	Components() ComponentsClient

	// Templates provide access to YAML file for generating workload cluster templates.
	// Please note that templates are expected to exist for the infrastructure providers only.
	Templates(version string) TemplateClient

	// Metadata provide access to YAML with the provider's metadata.
	Metadata(version string) MetadataClient
}

Client is used to interact with provider repositories. Provider repository are expected to contain two types of YAML files: - YAML files defining the provider components (CRD, Controller, RBAC etc.) - YAML files defining the cluster templates (Cluster, Machines)

func New

func New(provider config.Provider, configClient config.Client, options ...Option) (Client, error)

New returns a Client.

type Components

type Components interface {
	// configuration of the provider the provider components belongs to.
	config.Provider

	// Version of the provider.
	Version() string

	// Variables required by the provider components.
	// This value is derived by the component YAML.
	Variables() []string

	// Images required to install the provider components.
	// This value is derived by the component YAML.
	Images() []string

	// TargetNamespace where the provider components will be installed.
	// By default this value is derived by the component YAML, but it is possible to override it
	// during the creation of the Components object.
	TargetNamespace() string

	// WatchingNamespace defines the namespace where the provider controller is is watching (empty means all namespaces).
	// By default this value is derived by the component YAML, but it is possible to override it
	// during the creation of the Components object.
	WatchingNamespace() string

	// InventoryObject returns the clusterctl inventory object representing the provider that will be
	// generated by this components.
	InventoryObject() clusterctlv1.Provider

	// Yaml return the provider components in the form of a YAML file.
	Yaml() ([]byte, error)

	// InstanceObjs return the instance specific components in the form of a list of Unstructured objects.
	InstanceObjs() []unstructured.Unstructured

	// SharedObjs returns CRDs, web-hooks and all the components shared across instances in the form of a list of Unstructured objects.
	SharedObjs() []unstructured.Unstructured
}

Components wraps a YAML file that defines the provider components to be installed in a management cluster (CRD, Controller, RBAC etc.) It is important to notice that clusterctl applies a set of processing steps to the “raw” component YAML read from the provider repositories: 1. Checks for all the variables in the component YAML file and replace with corresponding config values 2. Ensure all the provider components are deployed in the target namespace (apply only to namespaced objects) 3. Ensure all the ClusterRoleBinding which are referencing namespaced objects have the name prefixed with the namespace name 4. Set the watching namespace for the provider controller 5. Adds labels to all the components in order to allow easy identification of the provider objects

type ComponentsClient

type ComponentsClient interface {
	Get(options ComponentsOptions) (Components, error)
}

ComponentsClient has methods to work with yaml file for generating provider components. Assets are yaml files to be used for deploying a provider into a management cluster.

type ComponentsInput added in v0.3.7

type ComponentsInput struct {
	Provider     config.Provider
	ConfigClient config.Client
	Processor    yaml.Processor
	RawYaml      []byte
	Options      ComponentsOptions
}

ComponentsInput represents all the inputs required by NewComponents

type ComponentsOptions added in v0.3.4

type ComponentsOptions struct {
	Version           string
	TargetNamespace   string
	WatchingNamespace string
	// Allows for skipping variable replacement in the component YAML
	SkipVariables bool
}

ComponentsOptions represents specific inputs that are passed in to clusterctl library. These are user specified inputs.

type MetadataClient

type MetadataClient interface {
	// Get returns the provider's metadata.
	Get() (*clusterctlv1.Metadata, error)
}

MetadataClient has methods to work with metadata hosted on a provider repository. Metadata are yaml files providing additional information about provider's assets like e.g the version compatibility Matrix.

type Option

type Option func(*repositoryClient)

Option is a configuration option supplied to New

func InjectRepository

func InjectRepository(repository Repository) Option

InjectRepository allows to override the repository implementation to use; by default, the repository implementation to use is created according to the repository URL.

func InjectYamlProcessor added in v0.3.7

func InjectYamlProcessor(p yaml.Processor) Option

InjectYamlProcessor allows you to override the yaml processor that the repository client uses. By default, the SimpleProcessor is used. This is true even if a nil processor is injected.

type Overrider added in v0.3.2

type Overrider interface {
	Path() string
}

Overrider provides behavior to determine the overrides layer.

type Repository

type Repository interface {
	// DefaultVersion returns the default provider version returned by a repository.
	// In case the repository URL points to latest, this method returns the current latest version; in other cases
	// it returns the version of the provider hosted in the repository.
	DefaultVersion() string

	// RootPath returns the path inside the repository where the YAML file for creating provider components and
	// the YAML file for generating workload cluster templates are stored.
	// This value is derived from the repository URL; all the paths returned by this interface should be relative to this path.
	RootPath() string

	// ComponentsPath return the path (a folder name or file name) of the YAML file for creating provider components.
	// This value is derived from the repository URL.
	ComponentsPath() string

	// GetFile return a file for a given provider version.
	GetFile(version string, path string) ([]byte, error)

	// GetVersion return the list of versions that are available in a provider repository
	GetVersions() ([]string, error)
}

Repository defines the behavior of a repository implementation. clusterctl is designed to support different repository types; each repository implementation should be aware of the provider version they are hosting, and possibly to host more than one version.

type Template

type Template interface {
	// Variables required by the template.
	// This value is derived by the template YAML.
	Variables() []string

	// TargetNamespace where the template objects will be installed.
	TargetNamespace() string

	// Yaml returns yaml defining all the cluster template objects as a byte array.
	Yaml() ([]byte, error)

	// Objs returns the cluster template as a list of Unstructured objects.
	Objs() []unstructured.Unstructured
}

Template wraps a YAML file that defines the cluster objects (Cluster, Machines etc.). It is important to notice that clusterctl applies a set of processing steps to the “raw” cluster template YAML read from the provider repositories: 1. Checks for all the variables in the cluster template YAML file and replace with corresponding config values 2. Ensure all the cluster objects are deployed in the target namespace

type TemplateClient

type TemplateClient interface {
	Get(flavor, targetNamespace string, listVariablesOnly bool) (Template, error)
}

TemplateClient has methods to work with cluster templates hosted on a provider repository. Templates are yaml files to be used for creating a guest cluster.

type TemplateClientInput added in v0.3.7

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

type TemplateInput added in v0.3.7

type TemplateInput struct {
	RawArtifact           []byte
	ConfigVariablesClient config.VariablesClient
	Processor             yaml.Processor
	TargetNamespace       string
	ListVariablesOnly     bool
}

Jump to

Keyboard shortcuts

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