Documentation ¶
Overview ¶
Package repository implements clusterctl repository functionality.
Index ¶
- func AlterComponents(comps Components, alterFn ComponentsAlterFn) error
- type Client
- type ClusterClassClient
- type ClusterClassClientInput
- type Components
- type ComponentsAlterFn
- type ComponentsClient
- type ComponentsInput
- type ComponentsOptions
- type MemoryRepository
- func (f *MemoryRepository) ComponentsPath() string
- func (f *MemoryRepository) DefaultVersion() string
- func (f *MemoryRepository) GetFile(version string, path string) ([]byte, error)
- func (f *MemoryRepository) GetVersions() ([]string, error)
- func (f *MemoryRepository) RootPath() string
- func (f *MemoryRepository) WithDefaultVersion(version string) *MemoryRepository
- func (f *MemoryRepository) WithFile(version, path string, content []byte) *MemoryRepository
- func (f *MemoryRepository) WithMetadata(version string, metadata *clusterctlv1.Metadata) *MemoryRepository
- func (f *MemoryRepository) WithPaths(rootPath, componentsPath string) *MemoryRepository
- func (f *MemoryRepository) WithVersions(version ...string) *MemoryRepository
- type MetadataClient
- type Option
- type Overrider
- type Repository
- type Template
- type TemplateClient
- type TemplateClientInput
- type TemplateInput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AlterComponents ¶ added in v0.99.99
func AlterComponents(comps Components, alterFn ComponentsAlterFn) error
AlterComponents provides a mechanism to alter the component.Objs from outside the repository module.
Types ¶
type Client ¶
type Client interface { config.Provider // 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 // GetVersions 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 // ClusterClasses provide access to YAML file for the ClusterClasses available // for the provider. ClusterClasses(version string) ClusterClassClient // 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).
type ClusterClassClient ¶ added in v0.99.99
type ClusterClassClient interface {
Get(name, targetNamespace string, skipTemplateProcess bool) (Template, error)
}
ClusterClassClient has methods to work with cluster class templates hosted on a provider repository. Templates are yaml files to be used for creating a guest cluster.
type ClusterClassClientInput ¶ added in v0.99.99
type ClusterClassClientInput struct {
// contains filtered or unexported fields
}
ClusterClassClientInput is an input struct for newClusterClassClient.
type Components ¶
type Components interface { // Provider holds configuration of the provider the provider components belong 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 // 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) // Objs return the components in the form of a list of Unstructured objects. Objs() []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. Adds labels to all the components in order to allow easy identification of the provider objects.
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 SkipTemplateProcess 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. Adds labels to all the components in order to allow easy identification of the provider objects.
type ComponentsAlterFn ¶ added in v0.99.99
type ComponentsAlterFn func(objs []unstructured.Unstructured) ([]unstructured.Unstructured, error)
ComponentsAlterFn defines the function that is used to alter the components.Objs().
type ComponentsClient ¶
type ComponentsClient interface { Raw(options ComponentsOptions) ([]byte, error) 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 // SkipTemplateProcess allows for skipping the call to the template processor, including also variable replacement in the component YAML. // NOTE this works only if the rawYaml is a valid yaml by itself, like e.g when using envsubst/the simple processor. SkipTemplateProcess bool }
ComponentsOptions represents specific inputs that are passed in to clusterctl library. These are user specified inputs.
type MemoryRepository ¶ added in v0.4.1
type MemoryRepository struct {
// contains filtered or unexported fields
}
MemoryRepository contains an instance of the repository data.
func NewMemoryRepository ¶ added in v0.4.1
func NewMemoryRepository() *MemoryRepository
NewMemoryRepository returns a new MemoryRepository instance.
func (*MemoryRepository) ComponentsPath ¶ added in v0.4.1
func (f *MemoryRepository) ComponentsPath() string
ComponentsPath returns ComponentsPath for this repository NOTE: The ComponentsPath is a required info usually derived from the repository configuration, and it is used to identify the components yaml for the provider.
func (*MemoryRepository) DefaultVersion ¶ added in v0.4.1
func (f *MemoryRepository) DefaultVersion() string
DefaultVersion returns the default version for this repository. NOTE: The DefaultVersion is a required info usually derived from the repository configuration, and it is used whenever the users gets files from the repository without providing a specific version.
func (*MemoryRepository) GetFile ¶ added in v0.4.1
func (f *MemoryRepository) GetFile(version string, path string) ([]byte, error)
GetFile returns a file for a given provider version. NOTE: If the provided version is missing, the default version is used.
func (*MemoryRepository) GetVersions ¶ added in v0.4.1
func (f *MemoryRepository) GetVersions() ([]string, error)
GetVersions returns the list of versions that are available.
func (*MemoryRepository) RootPath ¶ added in v0.4.1
func (f *MemoryRepository) RootPath() string
RootPath returns the RootPath for this repository. NOTE: The RootPath is a required info usually derived from the repository configuration, and it is used to map the file path to the internal repository structure.
func (*MemoryRepository) WithDefaultVersion ¶ added in v0.4.1
func (f *MemoryRepository) WithDefaultVersion(version string) *MemoryRepository
WithDefaultVersion allows setting of the default version.
func (*MemoryRepository) WithFile ¶ added in v0.4.1
func (f *MemoryRepository) WithFile(version, path string, content []byte) *MemoryRepository
WithFile allows setting of a file for a given version. NOTE: - If the provided version is missing, a new one will be generated automatically. - If the defaultVersion has not been set, it will be initialized with the first version passed in WithFile(). - If the version is "latest" or "", nothing will be added.
func (*MemoryRepository) WithMetadata ¶ added in v0.4.1
func (f *MemoryRepository) WithMetadata(version string, metadata *clusterctlv1.Metadata) *MemoryRepository
WithMetadata allows setting of the metadata.
func (*MemoryRepository) WithPaths ¶ added in v0.4.1
func (f *MemoryRepository) WithPaths(rootPath, componentsPath string) *MemoryRepository
WithPaths allows setting of the rootPath and componentsPath fields.
func (*MemoryRepository) WithVersions ¶ added in v0.4.1
func (f *MemoryRepository) WithVersions(version ...string) *MemoryRepository
WithVersions allows setting of the available versions. NOTE: When adding a file to the repository for a specific version, a version is automatically generated if missing; this func allows to define versions without any file.
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
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 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) // GetVersions 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.
func NewGitHubRepository ¶ added in v0.99.99
func NewGitHubRepository(providerConfig config.Provider, configVariablesClient config.VariablesClient, opts ...githubRepositoryOption) (Repository, error)
NewGitHubRepository returns a gitHubRepository implementation.
func NewGitLabRepository ¶ added in v1.2.0
func NewGitLabRepository(providerConfig config.Provider, configVariablesClient config.VariablesClient) (Repository, error)
NewGitLabRepository returns a gitLabRepository implementation.
type Template ¶
type Template interface { // Variables used by the template. // This value is derived from the template YAML. Variables() []string // VariableMap used by the template with their default values. If the value is `nil`, there is no // default and the variable is required. // This value is derived from the template YAML. VariableMap() map[string]*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.
func MergeTemplates ¶ added in v0.99.99
MergeTemplates merges the provided Templates into one Template. Notes on the merge operation:
- The merge operation returns an error if all the templates do not have the same TargetNamespace.
- The Variables of the resulting template is a union of all Variables in the templates.
- The default value is picked from the first template that defines it. The defaults of the same variable in the subsequent templates will be ignored. (e.g when merging a cluster template and its ClusterClass, the default value from the template takes precedence)
- The Objs of the final template will be a union of all the Objs in the templates.
func NewTemplate ¶
func NewTemplate(input TemplateInput) (Template, error)
NewTemplate returns a new objects embedding a cluster template YAML file.
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
}
TemplateClientInput is an input strict for newTemplateClient.
type TemplateInput ¶ added in v0.3.7
type TemplateInput struct { RawArtifact []byte ConfigVariablesClient config.VariablesClient Processor yaml.Processor TargetNamespace string SkipTemplateProcess bool }
TemplateInput is an input struct for NewTemplate.