models

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2023 License: MPL-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package models provides cluster template models (for each sub-document of multi-doc YAML).

Index

Constants

View Source
const KindCluster = "Cluster"

KindCluster is Cluster model kind.

View Source
const KindControlPlane = "ControlPlane"

KindControlPlane is ControlPlane model kind.

View Source
const KindMachine = "Machine"

KindMachine is a Machine model kind.

View Source
const KindWorkers = "Workers"

KindWorkers is Workers model kind.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

type Cluster struct {
	Meta `yaml:",inline"`

	// Name is the name of the cluster.
	Name string `yaml:"name"`

	// Labels are the user labels to apply to the cluster.
	Labels map[string]string `yaml:"labels"`

	// Kubernetes settings.
	Kubernetes KubernetesCluster `yaml:"kubernetes"`

	// Talos settings.
	Talos TalosCluster `yaml:"talos"`

	// Cluster-wide patches.
	Patches PatchList `yaml:"patches"`
}

Cluster is a top-level template object.

func (*Cluster) Translate

func (cluster *Cluster) Translate(TranslateContext) ([]resource.Resource, error)

Translate into Omni resources.

func (*Cluster) Validate

func (cluster *Cluster) Validate() error

Validate the model.

type ControlPlane

type ControlPlane struct {
	MachineSet `yaml:",inline"`
}

ControlPlane describes Cluster controlplane nodes.

func (*ControlPlane) Translate

func (controlplane *ControlPlane) Translate(ctx TranslateContext) ([]resource.Resource, error)

Translate the model.

func (*ControlPlane) Validate

func (controlplane *ControlPlane) Validate() error

Validate the model.

type KubernetesCluster

type KubernetesCluster struct {
	// Version is the Kubernetes version.
	Version string `yaml:"version"`
}

KubernetesCluster is a Kubernetes cluster settings.

func (*KubernetesCluster) Validate

func (kubernetes *KubernetesCluster) Validate() error

Validate the model.

type List

type List []Model

List implements a list of models, essentially it's a template.

func (List) ClusterName

func (l List) ClusterName() (string, error)

ClusterName retruns the name of the cluster in the template.

func (List) Translate

func (l List) Translate() ([]resource.Resource, error)

Translate a set of models (template) to a set of Omni resources.

Translate assumes that the template is valid.

func (List) Validate

func (l List) Validate() error

Validate the set of models as a complete template.

Each model should be valid, but also the set of models should be complete.

type Machine

type Machine struct {
	Meta `yaml:",inline"`

	// Machine name (ID).
	Name MachineID `yaml:"name"`

	// Install specification.
	Install MachineInstall `yaml:"install"`

	// ClusterMachine patches.
	Patches PatchList `yaml:"patches"`
}

Machine provides customization for a specific machine.

func (*Machine) Translate

func (machine *Machine) Translate(context TranslateContext) ([]resource.Resource, error)

Translate the model.

func (*Machine) Validate

func (machine *Machine) Validate() error

Validate the model.

type MachineID

type MachineID string

MachineID is a Machine UUID.

func (MachineID) Validate

func (id MachineID) Validate() error

Validate the model.

type MachineIDList

type MachineIDList []MachineID

MachineIDList is a list of Machine UUIDs.

func (MachineIDList) Validate

func (l MachineIDList) Validate() error

Validate the list of machines.

type MachineInstall

type MachineInstall struct {
	// Disk device name.
	Disk string `yaml:"disk"`
}

MachineInstall provides machine install configuration.

func (*MachineInstall) Validate

func (install *MachineInstall) Validate() error

Validate the model.

type MachineSet

type MachineSet struct {
	Meta `yaml:",inline"`

	// ControlPlane machines.
	Machines MachineIDList `yaml:"machines"`

	// Controlplane patches.
	Patches PatchList `yaml:"patches"`
}

MachineSet is a base model for controlplane and workers.

type Meta

type Meta struct {
	Kind string `yaml:"kind"`
}

Meta is embedded into all template objects.

type Model

type Model interface {
	Validate() error
	Translate(TranslateContext) ([]resource.Resource, error)
}

Model is a base interface for cluster templates.

func New

func New(kind string) (Model, error)

New creates a model by kind.

type Patch

type Patch struct {
	// Name of the patch.
	//
	// Optional for 'path' patches, mandatory for 'inline' patches.
	Name string `yaml:"name"`

	// File path to the file containing the patch.
	//
	// Mutually exclusive with `inline:`.
	File string `yaml:"file"`

	// Inline patch content.
	Inline map[string]any `yaml:"inline"`
}

Patch is a Talos machine configuration patch.

func (*Patch) Translate

func (patch *Patch) Translate(prefix string, weight int, labels ...pair.Pair[string, string]) (*omni.ConfigPatch, error)

Translate the model into a resource.

func (*Patch) Validate

func (patch *Patch) Validate() error

Validate the model.

type PatchList

type PatchList []Patch

PatchList is a list of patches.

func (PatchList) Translate

func (l PatchList) Translate(prefix string, baseWeight int, labels ...pair.Pair[string, string]) ([]resource.Resource, error)

Translate the list of patches into a list of resources.

func (PatchList) Validate

func (l PatchList) Validate() error

Validate the model.

type TalosCluster

type TalosCluster struct {
	// Version is the Talos version.
	Version string `yaml:"version"`
}

TalosCluster is a Talos cluster settings.

func (*TalosCluster) Validate

func (talos *TalosCluster) Validate() error

Validate the model.

type TranslateContext

type TranslateContext struct {
	// ClusterName is the name of the cluster.
	ClusterName string
}

TranslateContext is a context for translation.

type Workers

type Workers struct {
	MachineSet `yaml:",inline"`
}

Workers describes Cluster worker nodes.

func (*Workers) Translate

func (workers *Workers) Translate(ctx TranslateContext) ([]resource.Resource, error)

Translate the model.

func (*Workers) Validate

func (workers *Workers) Validate() error

Validate the model.

Jump to

Keyboard shortcuts

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