config

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package config contains the config structs and loading logic for Topf

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Endpoint

type Endpoint url.URL

Endpoint is a wrapper around url.URL that marshals/unmarshals as a string

func (Endpoint) MarshalYAML

func (e Endpoint) MarshalYAML() (any, error)

MarshalYAML implements yaml.Marshaler to transparently convert url.URL to a string

func (Endpoint) String

func (e Endpoint) String() string

func (*Endpoint) UnmarshalYAML

func (e *Endpoint) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler to transparently parse from a string to url.URL

type Node

type Node struct {
	// Host is the name of the node. Can be FQDN or short name
	Host string `yaml:"host"`
	// IP is optional and used to connect to nodes directly instead of using DNS to resolve "host"
	IP   *netip.Addr    `yaml:"ip,omitempty"`
	Role NodeRole       `yaml:"role"`
	Data map[string]any `yaml:"data,omitempty"`
}

Node is the struct containing the configuration info for a node

func (*Node) Endpoint

func (n *Node) Endpoint() string

Endpoint returns the IP address if set, otherwise returns the Host. Use this for connections; use Host for display/logging and certificate validation.

func (*Node) UnmarshalYAML

func (n *Node) UnmarshalYAML(yamlNode *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler and performs additional validation

type NodeRole

type NodeRole string

NodeRole represents the role of a node in the cluster

const (
	// RoleWorker is the role for kubenetes worker node
	RoleWorker NodeRole = "worker"

	// RoleControlPlane is the role for kubernetes control plane nodes
	RoleControlPlane NodeRole = "control-plane"
)

func (NodeRole) MarshalText

func (nr NodeRole) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler

func (*NodeRole) UnmarshalText

func (nr *NodeRole) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler

type PatchContext

type PatchContext struct {
	ClusterName       string
	ClusterEndpoint   string
	KubernetesVersion string
	Data              map[string]any
	Node              *Node
	ConfigDir         string
}

PatchContext are the things that can be templated in patches

func (*PatchContext) Load

func (p *PatchContext) Load() (patches []configpatcher.Patch, err error)

Load loads all patches applicable for the node This includes general patches, role (worker/control-plane) specific patches and node specific patches in that order

type TopfConfig

type TopfConfig struct {
	ClusterName       string   `yaml:"clusterName"`
	ClusterEndpoint   Endpoint `yaml:"clusterEndpoint"`
	KubernetesVersion string   `yaml:"kubernetesVersion"`

	// SecretsProvider can be optionally set to the path of a binary which is
	// responsible for storing and retrieving secrets.yaml for a cluster. If not
	// set, will use a local secrest.yaml with optinoal SOPS encryption.
	SecretsProvider string `yaml:"secretsProvider,omitempty"`

	// NodesProvider can be optionally set the path of a binary which will provide additional noddes
	NodesProvider string `yaml:"nodesProvider,omitempty"`

	// ConfigDir is the directory containing patches and node-specific configurations
	// Defaults to "." (current directory) if not specified
	ConfigDir string `yaml:"configDir,omitempty"`

	Nodes []Node `yaml:"nodes"`

	// Data can contain arbitrary data that can be used when templating patches
	Data map[string]any `yaml:"data"`
}

TopfConfig is the main configuration structure for a Topf cluster

func LoadFromFile

func LoadFromFile(path string, nodesRegexFilter string) (config *TopfConfig, err error)

LoadFromFile loads the TopfConfig from a YAML file

func (*TopfConfig) GetSecretsProvider

func (t *TopfConfig) GetSecretsProvider() providers.SecretsProvider

GetSecretsProvider returns the configured secrets provider, or the default filesystem provider

Jump to

Keyboard shortcuts

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