Documentation
¶
Overview ¶
Package config loads ynf's own config.yaml (ADR-009): found in the home factory folder by the same lookup as lanes, validated against the published schema, with defaults applied.
Index ¶
- Constants
- func Find(home string) (path string, shadowed []string, err error)
- func ParseSize(s string) (int64, error)
- type Config
- func (c *Config) Author() (name, email string)
- func (c *Config) Dir() string
- func (c *Config) Durations() (ttl, heartbeat, ci, review time.Duration, err error)
- func (c *Config) MemorySettings() (enabled *bool, namespace, cwd string)
- func (c *Config) MemoryTransport() (transport, endpoint, tokenEnv, level string)
- func (c *Config) SQLitePath() (string, error)
- func (c *Config) StoreKind() string
- func (c *Config) TelemetrySettings(getenv func(string) string) (TelemetrySettings, error)
- func (c *Config) Token() (string, error)
- func (c *Config) WorkPath() string
- type TelemetrySettings
Constants ¶
const File = "config.yaml"
File is the config file name in a factory folder.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
Version int `yaml:"version"`
Repos []string `yaml:"repos"`
// Factory names the configuration repository, which enrols repositories instead of Repos.
Factory *struct {
Repo string `yaml:"repo"`
} `yaml:"factory"`
Store string `yaml:"store"`
WorkDir string `yaml:"work_dir"`
Owner string `yaml:"owner"`
GitHub struct {
TokenEnv string `yaml:"token_env"`
Author *struct {
Name string `yaml:"name"`
Email string `yaml:"email"`
} `yaml:"author"`
} `yaml:"github"`
Lease struct {
TTL string `yaml:"ttl"`
Heartbeat string `yaml:"heartbeat"`
} `yaml:"lease"`
Poll struct {
CI string `yaml:"ci"`
Review string `yaml:"review"`
} `yaml:"poll"`
// Executor inline declares this instance runs inside containment the operator provides, such
// as the factory image as a job (ADR-007): every run is inline, as InlineUser.
Executor string `yaml:"executor"`
InlineUser string `yaml:"inline_user"`
Images struct {
Build *bool `yaml:"build"`
} `yaml:"images"`
Memory *struct {
Provider string `yaml:"provider"`
Namespace string `yaml:"namespace"`
Cwd string `yaml:"cwd"`
// Transport is cli (the ynm CLI, a store chosen by cwd) or http (a hosted ynm at
// Endpoint, with the bearer token in TokenEnv): the shared store for a pool or CI.
Transport string `yaml:"transport"`
Endpoint string `yaml:"endpoint"`
TokenEnv string `yaml:"token_env"`
// Level is personal or distributed; over http it defaults to distributed, since a hosted
// store keeps nothing at the personal level.
Level string `yaml:"level"`
} `yaml:"memory"`
// Telemetry is where ynf and its runs write OpenTelemetry, and whether ynf starts ynr serve for
// a factory job (ADR-009, ADR-011). Without it, ynf writes where the environment says.
Telemetry *struct {
// Spool is the spool root: factory/ for ynf, runs/<run id>/ for each run, and
// manifests/<run id>.json.
Spool string `yaml:"spool"`
// RunQuota is how large a run's folder may grow, such as 64MiB.
RunQuota string `yaml:"run_quota"`
Collector *struct {
Enabled bool `yaml:"enabled"`
ID string `yaml:"id"`
Instance string `yaml:"instance"`
Upstream string `yaml:"upstream"`
// Archive is how long ynr serve has at a job's end to ship what is left.
Archive string `yaml:"archive"`
} `yaml:"collector"`
} `yaml:"telemetry"`
Path string `yaml:"-"` // the file it was loaded from
Shadowed []string `yaml:"-"` // other candidates found at the same level
}
Config is a loaded config.
func (*Config) Dir ¶
Dir is the folder the config was loaded from; relative paths in it resolve against this.
func (*Config) MemorySettings ¶
MemorySettings returns whether memory is wanted (nil means detect), the namespace template ({repo} is host/owner/name), and the folder ynm runs from, which picks its store.
func (*Config) MemoryTransport ¶
MemoryTransport returns how ynf reaches ynm (cli or http), the endpoint and token variable for http, and the level it writes at.
func (*Config) SQLitePath ¶
SQLitePath returns the database path for a sqlite:// store.
func (*Config) TelemetrySettings ¶
func (c *Config) TelemetrySettings(getenv func(string) string) (TelemetrySettings, error)
TelemetrySettings is the telemetry block, resolved: the spool root as an absolute path, the run quota, and the collector with its upstream filled from the operator's OpenTelemetry environment when the block names none. getenv reads that environment. It is an error for the collector to be enabled with no upstream: ynr serve has nowhere to ship until it has an object store of its own.