config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package config loads testfleet runtime configuration from environment variables.

All configuration is sourced from env vars (no YAML file in MVP). This keeps secret handling explicit and CI/skill invocations stateless. Future versions may layer a `~/.testfleet/config.yaml` on top — Load is structured so that addition is a non-breaking change.

Index

Constants

View Source
const (
	EnvOAuthClientID     = "TAILSCALE_OAUTH_CLIENT_ID"
	EnvOAuthClientSecret = "TAILSCALE_OAUTH_CLIENT_SECRET"
	EnvAPIToken          = "TAILSCALE_API_TOKEN"
	EnvTailnet           = "TAILSCALE_TAILNET"
	EnvStateDir          = "TESTFLEET_STATE_DIR"
	EnvSSHKey            = "TESTFLEET_SSH_KEY"
	EnvSSHUser           = "TESTFLEET_SSH_USER"
	EnvTag               = "TESTFLEET_TAG"
)

Env var names. Kept as exported constants so tests and docs can reference them.

View Source
const (
	DefaultTag = "tag:testfleet"
)

Defaults.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	OAuthClientID     string
	OAuthClientSecret string
	APIToken          string // optional shortcut; when set, skips OAuth flow
	Tailnet           string

	SSHKey  string
	SSHUser string
	Tag     string
	// contains filtered or unexported fields
}

Config is the resolved runtime configuration.

func Load

func Load() (*Config, error)

Load reads env vars and returns a populated Config.

Required: OAuth client id, OAuth client secret, tailnet, SSH key path, SSH user. Optional: state dir (defaults to $HOME/.testfleet), tag (defaults to tag:testfleet).

Missing required vars return *ErrMissingEnv listing every missing key. The state dir is resolved but not created here; call StateDir() to ensure it exists on disk (with mode 0700).

func (*Config) RawStateDir

func (c *Config) RawStateDir() string

RawStateDir returns the configured state dir path without touching the filesystem. Use for diagnostics / human output; use StateDir for anything that needs the dir to exist.

func (*Config) StateDir

func (c *Config) StateDir() (string, error)

StateDir returns the resolved state directory path, creating it (mode 0700) if it doesn't exist. The 0700 mode matters because the dir holds runs.json which may contain machine names and run metadata.

type ErrMissingEnv

type ErrMissingEnv struct {
	Vars []string
}

ErrMissingEnv is returned when one or more required env vars are unset. The error message lists every missing var so the user can fix them in one pass.

func (*ErrMissingEnv) Error

func (e *ErrMissingEnv) Error() string

func (*ErrMissingEnv) Is

func (e *ErrMissingEnv) Is(target error) bool

Is so errors.Is(err, &ErrMissingEnv{}) works regardless of which vars are missing.

Jump to

Keyboard shortcuts

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