config

package
v0.0.0-...-626ffdb Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APIVersion         = "v1alpha1"
	DefaultClusterName = "k3smanager"
	DefaultNetworkCIDR = "10.0.0.0/16"
	DefaultSSHPort     = 22
	GlobalCIDR         = "0.0.0.0/0"
	GlobalCIDRv6       = "::/0"
)

Variables

View Source
var ErrInvalidAPIVersion = errors.New("invalid api version")

Functions

func ValidateAPIVersion

func ValidateAPIVersion(version string) error

Ensure the API version is valid - this doesn't really do anything at the moment, but exists for future-proofing

func ValidateTaintEffect

func ValidateTaintEffect(fl validator.FieldLevel) bool

Types

type Cluster

type Cluster struct {
	Name string `json:"name,omitempty" env:"NAME" validate:"required"`

	ManagerPool ClusterNodePool `json:"managerPool" envPrefix:"MANAGER_POOL_" validate:"required"`
	// @todo(sje): envPrefix not yet supported for slices
	// @link https://github.com/caarlos0/env/issues/298
	WorkerPools []ClusterNodePool `json:"workerPools" validate:"dive,required"`
}

type ClusterNodePool

type ClusterNodePool struct {
	Name   string      `json:"name" env:"NAME" validate:"required"`
	Count  int         `json:"count" env:"COUNT" validate:"required,gt=0"`
	Labels []NodeLabel `json:"labels,omitempty" validate:"dive,required"`
	Taints []NodeTaint `json:"taints,omitempty" validate:"dive,required"`

	// All of these values are provider-specific
	Type     string  `json:"type" env:"TYPE" validate:"required"`
	Location string  `json:"location" env:"LOCATION" validate:"required"`
	Image    *string `json:"image,omitempty" env:"IMAGE"` // If not specified, this will use the default as-specified by the provider
	Arch     *string `json:"arch,omitempty" env:"ARCH"`   // If not specified, this will use the default as-specified by the provider
}

type Config

type Config struct {
	APIVersion string `json:"apiVersion" validate:"required"`

	Cluster    `json:"cluster" envPrefix:"CLUSTER_"`
	K3s        `json:"k3s" envPrefix:"K3S_"`
	Networking `json:"networking" envPrefix:"NETWORKING_"`

	Provider `json:"provider" envPrefix:"PROVIDER_"`
}

func Load

func Load(data []byte) (*Config, error)

func New

func New() (*Config, error)

func (*Config) ToYAML

func (c *Config) ToYAML() ([]byte, error)

func (*Config) Validate

func (c *Config) Validate() error

type K3s

type K3s struct {
	Datastore K3sDatastore `json:"datastore" envPrefix:"K3S_DATASTORE_" validate:"required"`
	Version   string       `json:"version,omitempty" env:"VERSION"` // If empty, uses the latest
}

type K3sDatastore

type K3sDatastore struct {
	Type     K3sDatastoreType `json:"type" env:"TYPE" validate:"required"`
	Endpoint string           `json:"endpoint,omitempty" env:"ENDPOINT" validate:"required_if=Type external"`
}

type K3sDatastoreType

type K3sDatastoreType string
const (
	K3S_DATASTORE_TYPE_ETCD     K3sDatastoreType = "etcd"
	K3S_DATASTORE_TYPE_EXTERNAL K3sDatastoreType = "external"
)

type Networking

type Networking struct {
	NetworkingAllowed `json:"allowed" envPrefix:"ALLOWED_"`
	Location          string `json:"location" env:"LOCATION" validate:"required"`
	SSHPort           int    `json:"sshPort" env:"SSH_PORT" validate:"required,numeric"`
	Subnet            string `json:"subnet" env:"SUBNET" validate:"required,cidr"`
}

type NetworkingAllowed

type NetworkingAllowed struct {
	API string `json:"api" env:"API" validate:"required,cidr"`
	SSH string `json:"ssh" env:"SSH" validate:"required,cidr"`
}

type NodeLabel

type NodeLabel struct {
	Key   string `json:"key" env:"KEY" validate:"required"`
	Value string `json:"value" env:"VALUE" validate:"required"`
}

type NodeTaint

type NodeTaint struct {
	Key    string             `json:"key" env:"KEY" validate:"required"`
	Value  string             `json:"value" env:"VALUE" validate:"required"`
	Effect corev1.TaintEffect `json:"effect,omitempty" env:"EFFECT" validate:"taintEffect"`
}

type Provider

type Provider struct {
	ID     string         `json:"id" env:"ID"`
	Config map[string]any `json:"config" env:"CONFIG"` // Dependent upon the provider used
}

Jump to

Keyboard shortcuts

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