Documentation
¶
Overview ¶
Package settings holds the cascading defaults: server -> organization -> stack -> environment -> tile. A tile's explicit value always wins; zero/empty means "inherit from the level above"; the chain bottoms out in built-ins.
Index ¶
- type Level
- type Resolved
- func ForOrg(ctx context.Context, store repo.Store, orgID string) Resolved
- func ForServer(ctx context.Context, store repo.Store) Resolved
- func ForStack(ctx context.Context, store repo.Store, stackID string) Resolved
- func ForTile(ctx context.Context, store repo.Store, t *repo.Tile) Resolved
- func Resolve(levels ...Settings) Resolved
- type Settings
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Level ¶
Level is one rung of the cascade, named so a settings page can say where an inherited value came from.
type Resolved ¶
type Resolved struct {
CronTimeoutMin int
CPULimit float64
MemLimitMB int
RunRetentionDays int
MetricRetentionHours int
// ProtectAutoDomains puts a Traefik forwardAuth in front of the generated
// per-environment hostnames, so a preview URL needs a stackr session.
// Hand-attached domains are never touched, those are the real ones.
ProtectAutoDomains bool
// NodeGroup is the resolved placement group, "" = anywhere.
NodeGroup string
// BuildNode is the node id builds run on, "" = the manager.
BuildNode string
}
Resolved is the fully-cascaded result, every field concrete.
func Resolve ¶
Resolve applies override levels in order (server, org, stack, env); later levels win where set.
func (Resolved) EffectiveGroup ¶
EffectiveGroup applies the cascade to a tile's own node_group: empty inherits the level above, which bottoms out in "anywhere".
func (Resolved) EffectiveLimits ¶
EffectiveLimits applies the cascade to a resource's explicit limits: zero means inherit the resolved default.
func (Resolved) EffectiveTimeout ¶
EffectiveTimeout applies the cascade to a cron timeout: <=0 inherits.
type Settings ¶
type Settings struct {
CronTimeoutMin *int `json:"cron_timeout_min,omitempty"`
CPULimit *float64 `json:"cpu_limit,omitempty"`
MemLimitMB *int `json:"mem_limit_mb,omitempty"`
RunRetentionDays *int `json:"run_retention_days,omitempty"`
MetricRetentionHours *int `json:"metric_retention_hours,omitempty"`
ProtectAutoDomains *bool `json:"protect_auto_domains,omitempty"`
// NodeGroup constrains where tiles at this level may run, by the
// stackr.group node label. Empty string is an explicit "anywhere" that
// overrides a group set above (docs/plans/31-node-agent-open-questions.md,
// node groups).
NodeGroup *string `json:"node_group,omitempty"`
// BuildNode is the swarm node id image builds run on, instance-wide and
// only read at the server level. Empty means the manager, in a capped
// builder per org (docs/plans/37-builds.md).
BuildNode *string `json:"build_node,omitempty"`
}
Settings is one level's overrides. Nil field = inherit.
func Merge ¶
Merge folds submitted form values into an existing level's overrides. A key the form never submitted is left untouched, settings forms show a subset of the fields, and a partial form must not wipe the rest. A key submitted empty clears the override back to "inherit".
CPULimit and MemLimitMB accept an explicit 0, which means "unlimited" and is how a lower level overrides a limit set above it. The timeout and retention fields have no meaningful zero, so a non-positive value clears them instead.