fleet

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package fleet finds the fleet repo and loads one environment from it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Available

func Available(root string) string

Available lists the environments under root for an error's why line.

func Environments

func Environments(root string) ([]string, error)

Environments returns the environment name under the root, sorted.

func FindRoot

func FindRoot(cwd string, getenv func(string) string) (string, error)

FindRoot returns the fleet root: $TOPS_ROOT if set, else the nearest directory from cwd upwards that contains environments.

func Init

func Init(root, name string) ([]string, error)

Init creates environment name under root: its cluster.yaml, overrides.yaml and secrets.env, and any base/ file that is missing. It never overwrites a file, and returns what it created, relative to root.

func InitRoot

func InitRoot(cwd string, getenv func(string) string) (string, error)

InitRoot returns where init creates an environment: the fleet root, or cwd when there is none, which starts a new fleet repo there. A $TOPS_ROOT without environments/ is still refused: it is more likely a typo than a place for a new fleet.

Types

type Difference

type Difference struct {
	Path string `json:"path"`
	From any    `json:"from"`
	To   any    `json:"to"`
}

Difference is one path whose value differs. A nil From or To is a path the environment does not have: a namespace it does not keep, a key its overrides do not set.

type Env

type Env struct {
	Name    string
	Root    string // the fleet root
	Dir     string // the environment directory under the fleet root
	File    string // cluster.yaml, relative to the fleet root, for messages
	Cluster *spec.Cluster
}

Env is one environment loaded from the fleet root.

func Load

func Load(root, name string) (*Env, error)

Load reads environments/<name>/cluster.yaml under root, applies the defaults and resolves ssh.key and ssh.knownHosts against the environment directory.

func (*Env) Catalog

func (e *Env) Catalog() (*catalog.Catalog, error)

Catalog is the settings catalog of the spec's Temporal minor: 1.31 for 1.31.3.

func (*Env) ReadSecrets

func (e *Env) ReadSecrets() (Secrets, error)

ReadSecrets reads secrets.env next to cluster.yaml: it must be a regular file with mode 0600 owned by the current user, parse, and set every key the spec needs.

func (*Env) SecretsNotIgnored

func (e *Env) SecretsNotIgnored(ctx context.Context) (spec.Problem, bool)

SecretsNotIgnored returns a warning when git would commit the environment's secrets.env: the fleet repo's .gitignore must cover it. Outside a git repository, or without git, there is nothing to check. git check-ignore exits 1 for a path that is not ignored or is already tracked, so a secret committed once still warns.

func (*Env) Settings

func (e *Env) Settings(c *catalog.Catalog) (settings.Layers, []spec.Problem, error)

Settings reads the environments dynamic-config files and checks each against c: base/common.yaml, base/<role>.yaml for every role, then its overrides.yaml. A file that does not exist sets nothing. The problems caome in that order of files.

type EnvDiff

type EnvDiff struct {
	Promotable []Difference `json:"promotable"`
	ByDesign   []Difference `json:"byDesign"`
}

EnvDiff is what differs between two environments, by group (TRD "Diff and promote"). Promotable differences are what tops promote would write; by-design ones are each environment's own, such as its cluster name and nodes.

func Diff

func Diff(from, to *Env) (EnvDiff, error)

Diff compares the resolved values of from and to: defaults applied, and each environment's overrides checked against its own catalog. base/ is shared, so the overrides are the only settings that can differ.

type Secrets

type Secrets map[string]secret.Value

Secrets are the values in secrets.env, by key.

Jump to

Keyboard shortcuts

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