modelconfig

package
v0.0.0-...-947b840 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IP_IN_CIDR  = "ipInCidr"
	LB_REQUIRED = "lbRequired"
	VALID_HOST  = "validHost"
	VALID_POOL  = "validPool"
)

Keys of custom validators

Variables

This section is empty.

Functions

This section is empty.

Types

type Addons

type Addons struct {
	Kubespray string `yaml:"kubespray,omitempty" opt:"-"`
	Rook      Rook   `yaml:"rook,omitempty"`
}

func (Addons) Validate

func (a Addons) Validate() error

type CIDRv4

type CIDRv4 string

func (CIDRv4) Validate

func (cidr CIDRv4) Validate() error

type Cluster

type Cluster struct {
	Name         string       `yaml:"name"`
	Network      Network      `yaml:"network"`
	NodeTemplate NodeTemplate `yaml:"nodeTemplate"`
	Nodes        Nodes        `yaml:"nodes"`
}

func (Cluster) Validate

func (c Cluster) Validate() error

type Config

type Config struct {
	Hosts      []Host     `yaml:"hosts"`
	Cluster    Cluster    `yaml:"cluster"`
	Kubernetes Kubernetes `yaml:"kubernetes"`
	Addons     Addons     `yaml:"addons,omitempty"`
	Kubitect   Kubitect   `yaml:"kubitect,omitempty"`
}

func MockConfig

func MockConfig(t *testing.T) Config

func (*Config) SetDefaults

func (c *Config) SetDefaults()

func (Config) Validate

func (c Config) Validate() error

type Connection

type Connection struct {
	User User           `yaml:"user,omitempty"`
	IP   IPv4           `yaml:"ip,omitempty"`
	Type ConnectionType `yaml:"type"`
	SSH  ConnectionSSH  `yaml:"ssh,omitempty"`
}

func (Connection) Validate

func (c Connection) Validate() error

type ConnectionSSH

type ConnectionSSH struct {
	Keyfile File `yaml:"keyfile,omitempty"`
	Port    Port `yaml:"port,omitempty"`
	Verify  bool `yaml:"verify,omitempty"`
}

func (*ConnectionSSH) SetDefaults

func (s *ConnectionSSH) SetDefaults()

func (ConnectionSSH) Validate

func (s ConnectionSSH) Validate() error

type ConnectionType

type ConnectionType string
const (
	LOCAL     ConnectionType = "local"
	LOCALHOST ConnectionType = "localhost" // equivalent to local
	REMOTE    ConnectionType = "remote"
)

func (ConnectionType) Validate

func (t ConnectionType) Validate() error

type CpuMode

type CpuMode string
const (
	CUSTOM      CpuMode = "custom"
	PASSTHROUGH CpuMode = "host-passthrough"
)

func (CpuMode) Validate

func (m CpuMode) Validate() error

type DataDisk

type DataDisk struct {
	Name string `yaml:"name" opt:",id"`
	Pool string `yaml:"pool"`
	Size GB     `yaml:"size"`
}

func (DataDisk) Validate

func (d DataDisk) Validate() error

type DataResourcePool

type DataResourcePool struct {
	Name string `yaml:"name" opt:",id"`
	Path string `yaml:"path"`
}

func (*DataResourcePool) SetDefaults

func (rp *DataResourcePool) SetDefaults()

func (DataResourcePool) Validate

func (rp DataResourcePool) Validate() error

type DnsMode

type DnsMode string
const (
	COREDNS DnsMode = "coredns"
	KUBEDNS DnsMode = "kubedns"
)

func (DnsMode) Validate

func (m DnsMode) Validate() error

type File

type File string

func MockPKey

func MockPKey(t *testing.T) File

func (File) Validate

func (f File) Validate() error

type GB

type GB int

func (GB) Validate

func (size GB) Validate() error

type Host

type Host struct {
	Name                 string             `yaml:"name" opt:",id"`
	Default              bool               `yaml:"default"`
	Connection           Connection         `yaml:"connection,omitempty"`
	MainResourcePoolPath string             `yaml:"mainResourcePoolPath"`
	DataResourcePools    []DataResourcePool `yaml:"dataResourcePools,omitempty"`
}

func MockLocalHost

func MockLocalHost(t *testing.T, name string, def bool) Host

func MockRemoteHost

func MockRemoteHost(t *testing.T, name string, def bool, verify bool) Host

func (*Host) SetDefaults

func (h *Host) SetDefaults()

func (Host) Validate

func (h Host) Validate() error

type IP

type IP string

func (IP) Validate

func (ip IP) Validate() error

type IPv4

type IPv4 string

func (IPv4) Validate

func (ip IPv4) Validate() error

type Instance

type Instance interface {
	GetTypeName() string
	GetID() string
	GetIP() IPv4
	GetMAC() MAC
}

type Kubernetes

type Kubernetes struct {
	Version       KubernetesVersion `yaml:"version"`
	DnsMode       DnsMode           `yaml:"dnsMode"`
	NetworkPlugin NetworkPlugin     `yaml:"networkPlugin"`
	Other         Other             `yaml:"other"`
}

func (*Kubernetes) SetDefaults

func (k *Kubernetes) SetDefaults()

func (Kubernetes) Validate

func (k Kubernetes) Validate() error

type KubernetesVersion

type KubernetesVersion string

func (KubernetesVersion) Validate

func (ver KubernetesVersion) Validate() error

type Kubitect

type Kubitect struct {
	Url     URL           `yaml:"url,omitempty"`
	Version MasterVersion `yaml:"version,omitempty"`
}

func (Kubitect) Validate

func (k Kubitect) Validate() error

type LB

type LB struct {
	VIP             IPv4            `yaml:"vip,omitempty"`
	VirtualRouterId *Uint8          `yaml:"virtualRouterId,omitempty"`
	Default         LBDefault       `yaml:"default"`
	Instances       []LBInstance    `yaml:"instances,omitempty"`
	ForwardPorts    []LBPortForward `yaml:"forwardPorts,omitempty"`
}

func (*LB) SetDefaults

func (lb *LB) SetDefaults()

func (LB) Validate

func (lb LB) Validate() error

type LBDefault

type LBDefault struct {
	CPU          VCpu `yaml:"cpu"`
	RAM          GB   `yaml:"ram"`
	MainDiskSize GB   `yaml:"mainDiskSize"`
}

func (*LBDefault) SetDefaults

func (def *LBDefault) SetDefaults()

func (LBDefault) Validate

func (def LBDefault) Validate() error

type LBInstance

type LBInstance struct {
	Name         string `yaml:"name,omitempty" opt:"-"`
	Id           string `yaml:"id" opt:",id"`
	Host         string `yaml:"host,omitempty"`
	IP           IPv4   `yaml:"ip,omitempty"`
	MAC          MAC    `yaml:"mac,omitempty"`
	CPU          VCpu   `yaml:"cpu"`
	RAM          GB     `yaml:"ram"`
	MainDiskSize GB     `yaml:"mainDiskSize"`
	Priority     *Uint8 `yaml:"priority,omitempty"`
}

func (LBInstance) GetID

func (i LBInstance) GetID() string

func (LBInstance) GetIP

func (i LBInstance) GetIP() IPv4

func (LBInstance) GetMAC

func (i LBInstance) GetMAC() MAC

func (LBInstance) GetTypeName

func (i LBInstance) GetTypeName() string

func (LBInstance) Validate

func (i LBInstance) Validate() error

type LBPortForward

type LBPortForward struct {
	Name       string              `yaml:"name"`
	Port       Port                `yaml:"port"`
	TargetPort Port                `yaml:"targetPort,omitempty"`
	Target     LBPortForwardTarget `yaml:"target"`
}

func (*LBPortForward) SetDefaults

func (pf *LBPortForward) SetDefaults()

func (LBPortForward) Validate

func (pf LBPortForward) Validate() error

type LBPortForwardTarget

type LBPortForwardTarget string
const (
	WORKERS LBPortForwardTarget = "workers"
	MASTERS LBPortForwardTarget = "masters"
	ALL     LBPortForwardTarget = "all"
)

func (LBPortForwardTarget) Validate

func (pft LBPortForwardTarget) Validate() error

type Labels

type Labels map[string]string

func (Labels) Validate

func (l Labels) Validate() error

type MAC

type MAC string

func (MAC) Validate

func (mac MAC) Validate() error

type Master

type Master struct {
	Default   MasterDefault    `yaml:"default"`
	Instances []MasterInstance `yaml:"instances"`
}

func (*Master) SetDefaults

func (m *Master) SetDefaults()

func (Master) Validate

func (m Master) Validate() error

type MasterDefault

type MasterDefault struct {
	CPU          VCpu       `yaml:"cpu"`
	RAM          GB         `yaml:"ram"`
	MainDiskSize GB         `yaml:"mainDiskSize"`
	Labels       Labels     `yaml:"labels,omitempty"`
	Taints       []Taint    `yaml:"taints,omitempty"`
	DataDisks    []DataDisk `yaml:"dataDisks,omitempty"`
}

func (*MasterDefault) SetDefaults

func (def *MasterDefault) SetDefaults()

func (MasterDefault) Validate

func (d MasterDefault) Validate() error

type MasterInstance

type MasterInstance struct {
	Name         string     `yaml:"name,omitempty" opt:"-"`
	Id           string     `yaml:"id" opt:",id"`
	Host         string     `yaml:"host,omitempty"`
	IP           IPv4       `yaml:"ip,omitempty"`
	MAC          MAC        `yaml:"mac,omitempty"`
	CPU          VCpu       `yaml:"cpu"`
	RAM          GB         `yaml:"ram"`
	MainDiskSize GB         `yaml:"mainDiskSize"`
	DataDisks    []DataDisk `yaml:"dataDisks,omitempty"`
	Labels       Labels     `yaml:"labels,omitempty"`
	Taints       []Taint    `yaml:"taints,omitempty"`
}

func (MasterInstance) GetID

func (i MasterInstance) GetID() string

func (MasterInstance) GetIP

func (i MasterInstance) GetIP() IPv4

func (MasterInstance) GetMAC

func (i MasterInstance) GetMAC() MAC

func (MasterInstance) GetTypeName

func (i MasterInstance) GetTypeName() string

func (MasterInstance) Validate

func (i MasterInstance) Validate() error

type MasterVersion

type MasterVersion string

func (MasterVersion) Validate

func (ver MasterVersion) Validate() error

type Network

type Network struct {
	CIDR    CIDRv4        `yaml:"cidr"`
	Gateway *IPv4         `yaml:"gateway,omitempty"`
	Mode    NetworkMode   `yaml:"mode"`
	Bridge  NetworkBridge `yaml:"bridge,omitempty"`
}

func (*Network) SetDefaults

func (n *Network) SetDefaults()

func (Network) Validate

func (n Network) Validate() error

type NetworkBridge

type NetworkBridge string

func (NetworkBridge) Validate

func (br NetworkBridge) Validate() error

type NetworkMode

type NetworkMode string
const (
	NAT    NetworkMode = "nat"
	ROUTE  NetworkMode = "route"
	BRIDGE NetworkMode = "bridge"
)

func (NetworkMode) Validate

func (mode NetworkMode) Validate() error

type NetworkPlugin

type NetworkPlugin string
const (
	CALICO      NetworkPlugin = "calico"
	CILIUM      NetworkPlugin = "cilium"
	CANAL       NetworkPlugin = "canal"
	FLANNEL     NetworkPlugin = "flannel"
	WEAVE       NetworkPlugin = "weave"
	KUBE_ROUTER NetworkPlugin = "kube-router"
)

func (NetworkPlugin) Validate

func (p NetworkPlugin) Validate() error

type NodeTemplate

type NodeTemplate struct {
	User         User            `yaml:"user"`
	OS           OS              `yaml:"os"`
	SSH          NodeTemplateSSH `yaml:"ssh,omitempty"`
	CpuMode      CpuMode         `yaml:"cpuMode,omitempty"`
	DNS          []IP            `yaml:"dns,omitempty"`
	UpdateOnBoot bool            `yaml:"updateOnBoot"`
}

func (*NodeTemplate) SetDefaults

func (n *NodeTemplate) SetDefaults()

func (NodeTemplate) Validate

func (n NodeTemplate) Validate() error

type NodeTemplateSSH

type NodeTemplateSSH struct {
	AddToKnownHosts bool `yaml:"addToKnownHosts"`
	PrivateKeyPath  File `yaml:"privateKeyPath"`
}

func (*NodeTemplateSSH) SetDefaults

func (ssh *NodeTemplateSSH) SetDefaults()

func (NodeTemplateSSH) Validate

func (ssh NodeTemplateSSH) Validate() error

type Nodes

type Nodes struct {
	Master       Master `yaml:"master"`
	Worker       Worker `yaml:"worker,omitempty"`
	LoadBalancer LB     `yaml:"loadBalancer,omitempty"`
}

func MockNodes

func MockNodes(t *testing.T) Nodes

func (Nodes) IPs

func (n Nodes) IPs() []string

func (Nodes) Instances

func (n Nodes) Instances() []Instance

func (Nodes) MACs

func (n Nodes) MACs() []string

func (Nodes) Validate

func (n Nodes) Validate() error

type OS

type OS struct {
	Distro           OSDistro           `yaml:"distro"`
	NetworkInterface OSNetworkInterface `yaml:"networkInterface"`
	Source           OSSource           `yaml:"source"`
}

func (*OS) SetDefaults

func (s *OS) SetDefaults()

func (OS) Validate

func (s OS) Validate() error

type OSDistro

type OSDistro string
const (
	UBUNTU   OSDistro = "ubuntu"
	UBUNTU20 OSDistro = "ubuntu20"
	UBUNTU22 OSDistro = "ubuntu22"
	DEBIAN   OSDistro = "debian"
	DEBIAN11 OSDistro = "debian11"
)

func (OSDistro) Validate

func (d OSDistro) Validate() error

type OSNetworkInterface

type OSNetworkInterface string

func (OSNetworkInterface) Validate

func (nic OSNetworkInterface) Validate() error

type OSSource

type OSSource string

func (OSSource) Validate

func (os OSSource) Validate() error

type Other

type Other struct {
	AutoRenewCertificates bool `yaml:"autoRenewCertificates"`
	CopyKubeconfig        bool `yaml:"copyKubeconfig"`
}

type Port

type Port int

func (Port) Validate

func (p Port) Validate() error

type Rook

type Rook struct {
	Enabled      bool    `yaml:"enabled"`
	Version      Version `yaml:"version"`
	NodeSelector Labels  `yaml:"nodeSelector"`
}

func (Rook) Validate

func (r Rook) Validate() error

type Taint

type Taint string

func (Taint) Validate

func (t Taint) Validate() error

type URL

type URL string

func (URL) Validate

func (u URL) Validate() error

type Uint8

type Uint8 int

Uint8 is intentionally set to int to avoid panic if value is set outside the uint8 size.

For example, if LB priority is set to -1, raising a custom error is not possible since go will panic when converting -1 to uint8.

func (Uint8) Validate

func (u Uint8) Validate() error

type User

type User string

func (User) Validate

func (u User) Validate() error

type VCpu

type VCpu int

func (VCpu) Validate

func (s VCpu) Validate() error

type Version

type Version string

func (Version) Validate

func (ver Version) Validate() error

type Worker

type Worker struct {
	Default   WorkerDefault    `yaml:"default"`
	Instances []WorkerInstance `yaml:"instances,omitempty"`
}

func (*Worker) SetDefaults

func (w *Worker) SetDefaults()

func (Worker) Validate

func (w Worker) Validate() error

type WorkerDefault

type WorkerDefault struct {
	CPU          VCpu       `yaml:"cpu"`
	RAM          GB         `yaml:"ram"`
	MainDiskSize GB         `yaml:"mainDiskSize"`
	Labels       Labels     `yaml:"labels,omitempty"`
	Taints       []Taint    `yaml:"taints,omitempty"`
	DataDisks    []DataDisk `yaml:"dataDisks,omitempty"`
}

func (*WorkerDefault) SetDefaults

func (def *WorkerDefault) SetDefaults()

func (WorkerDefault) Validate

func (d WorkerDefault) Validate() error

type WorkerInstance

type WorkerInstance struct {
	Name         string     `yaml:"name,omitempty" opt:"-"`
	Id           string     `yaml:"id" opt:",id"`
	Host         string     `yaml:"host,omitempty"`
	IP           IPv4       `yaml:"ip,omitempty"`
	MAC          MAC        `yaml:"mac,omitempty"`
	CPU          VCpu       `yaml:"cpu"`
	RAM          GB         `yaml:"ram"`
	MainDiskSize GB         `yaml:"mainDiskSize"`
	DataDisks    []DataDisk `yaml:"dataDisks,omitempty"`
	Labels       Labels     `yaml:"labels,omitempty"`
	Taints       []Taint    `yaml:"taints,omitempty"`
}

func (WorkerInstance) GetID

func (i WorkerInstance) GetID() string

func (WorkerInstance) GetIP

func (i WorkerInstance) GetIP() IPv4

func (WorkerInstance) GetMAC

func (i WorkerInstance) GetMAC() MAC

func (WorkerInstance) GetTypeName

func (i WorkerInstance) GetTypeName() string

func (WorkerInstance) Validate

func (i WorkerInstance) Validate() error

Jump to

Keyboard shortcuts

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