deploycontext

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package deploycontext holds the pure rules for deploy contexts: which context a deploy runs in and how env and build settings resolve across the branch override, context and app default layers.

Index

Constants

View Source
const (
	Production    = spec.ContextProduction
	DeployPreview = spec.ContextDeployPreview
	BranchDeploy  = spec.ContextBranchDeploy
)

Context names. Production is the app's own settings and has no stored row.

View Source
const (
	SourceApp            = "app"
	SourceLegacyPreview  = "preview-env"
	SourceContext        = "context"
	SourceBranchContext  = "branch-context"
	SourceBranchOverride = "branch-env"
)

Sources reported for each resolved value, lowest to highest precedence.

View Source
const MaskedValue = "********"

MaskedValue replaces a secret's value in every effective view.

Variables

This section is empty.

Functions

func BranchContext

func BranchContext(pattern string) string

BranchContext names the per-branch context for a branch pattern.

func BranchPattern

func BranchPattern(name string) (string, bool)

BranchPattern returns the pattern of a "branch:<pattern>" context.

func For

func For(prNumber int, branch, productionBranch string) string

For picks the context a deploy runs in: a pull request preview is deploy-preview, any other non-production deploy is branch-deploy.

func Match

func Match(branch, pattern string) bool

Match reports whether branch matches a shell-glob pattern.

func Validate

func Validate(name string) error

Validate checks that name is a settable context and its pattern is valid.

Types

type BranchOverride

type BranchOverride struct {
	Pattern string
	Key     string
	Value   string
	Secret  bool
}

BranchOverride is one branch-scoped env override (secrets carry no value).

type Config

type Config = spec.ContextOverrides

Config is the settings one context can override. Empty fields inherit.

type Effective

type Effective struct {
	Context      string             `json:"context"`
	Env          []Entry            `json:"env"`
	BuildCommand Setting            `json:"build_command"`
	Publish      Setting            `json:"publish_dir"`
	BuildArgs    map[string]Setting `json:"build_args,omitempty"`
}

Effective is the resolved config for one deploy. Secret values are masked.

func Resolve

func Resolve(in Inputs) Effective

Resolve applies branch override, then context, then app default.

type Entry

type Entry struct {
	Key    string `json:"key"`
	Value  string `json:"value"`
	Secret bool   `json:"secret"`
	Source string `json:"source"`
}

Entry is one resolved env var with where it came from.

type EnvValue

type EnvValue struct {
	Value  string
	Secret bool
}

EnvValue is one env var as the resolver sees it.

type Inputs

type Inputs struct {
	Context       string
	Branch        string
	AppEnv        map[string]EnvValue
	LegacyPreview map[string]string
	Contexts      map[string]Config
	BranchEnv     []BranchOverride
	AppBuild      Config
}

Inputs are every layer the resolver reads for one deploy.

type Layer

type Layer struct {
	Source string
	Config Config
}

Layer is one context config tagged with its source label.

func Layers

func Layers(contextName, branch string, contexts map[string]Config) []Layer

Layers returns the context configs that apply to a deploy, lowest precedence first: the context itself, then matching branch contexts.

type Setting

type Setting struct {
	Value  string `json:"value"`
	Source string `json:"source"`
}

Setting is one resolved build setting with where it came from.

Jump to

Keyboard shortcuts

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