stackfile

package
v0.0.6-alpha Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const MaxStackfileSize = 1 << 20 // 1MB
View Source
const (
	PostgresAddonType = "postgres"
)

Variables

View Source
var SchemaJSON []byte

SchemaJSON is the JSON Schema (draft-07) for stackfile documents.

Functions

func ResolveStack

func ResolveStack(ctx context.Context, stack *openapi.Stack, resolver Resolver) error

func Validate

func Validate(sf *Stackfile) error

Types

type AddonConnectionConfig

type AddonConnectionConfig struct {
	Type string `yaml:"type"`
	// Env vars templated from the addon's outputs. Output names are bare —
	// no addon prefix (the block already names the addon):
	// env:
	//   POSTGRES_HOST: "{{ host }}"
	//   POSTGRES_URI: "postgres://{{ username }}:{{ password }}@{{ host }}:{{ port }}/{{ database }}"
	Env      map[string]string    `yaml:"env"`
	Postgres *PostgresAddonConfig `yaml:"-"`
	// contains filtered or unexported fields
}

func (*AddonConnectionConfig) UnmarshalYAML

func (a *AddonConnectionConfig) UnmarshalYAML(node *yaml.Node) error

type BuildConfig

type BuildConfig struct {
	Repo       string `yaml:"repo,omitempty"`
	Branch     string `yaml:"branch,omitempty"`
	Tag        string `yaml:"tag,omitempty"`
	Commit     string `yaml:"commit,omitempty"`
	Dockerfile string `yaml:"dockerfile,omitempty"`
	Context    string `yaml:"context,omitempty"`
	GitSecret  string `yaml:"git_secret,omitempty"`
}

type PortDef

type PortDef struct {
	Name      string `yaml:"name"`
	Port      int32  `yaml:"port"`
	Protocol  string `yaml:"protocol,omitempty"`
	Public    bool   `yaml:"public,omitempty"`
	Subdomain string `yaml:"subdomain,omitempty"`
}

type PostgresAddonConfig

type PostgresAddonConfig struct {
	Database  string `yaml:"database,omitempty"`
	Superuser bool   `yaml:"superuser,omitempty"`
}

type Resolver

type Resolver interface {
	ResolveSecretByName(ctx context.Context, name string) (string, error)
	ResolveAddonByName(ctx context.Context, addonType, name string) (string, error)
}

type Resource

type Resource struct {
	Image   string            `yaml:"image,omitempty"`
	Build   *BuildConfig      `yaml:"build,omitempty"`
	Command []string          `yaml:"command,omitempty"`
	Args    []string          `yaml:"args,omitempty"`
	Ports   []PortDef         `yaml:"ports,omitempty"`
	Env     map[string]string `yaml:"env,omitempty"`
	// Secret Name -> Mapping of secret keys to env var names
	Secrets map[string]SecretMapping `yaml:"secrets,omitempty"`
	// Addon Name -> Connection Config
	Addons       map[string]AddonConnectionConfig `yaml:"addons,omitempty"`
	Volumes      []VolumeMountDef                 `yaml:"volumes,omitempty"`
	DependsOn    []string                         `yaml:"depends_on,omitempty"`
	WorkloadType string                           `yaml:"workload_type,omitempty"`
	Schedule     string                           `yaml:"schedule,omitempty"`
	Replicas     *int32                           `yaml:"replicas,omitempty"`
}

type SecretMapping

type SecretMapping map[string]string

SecretMapping maps secret keys to env var names. Key = env var name, Value = secret key

type Stackfile

type Stackfile struct {
	Name      string               `yaml:"name"`
	Resources map[string]Resource  `yaml:"resources"`
	Volumes   map[string]VolumeDef `yaml:"volumes,omitempty"`
}

func FromStack

func FromStack(stack *openapi.Stack) (*Stackfile, error)

FromStack converts an API Stack document back into a Stackfile.

It covers exactly the subset a stackfile can express. Constructs outside that subset (init containers, file targets, build-artifact connections, volume sources, registry credentials, ...) fail with an error naming the construct — never silently dropped. Connections must carry name-based node refs; id-only refs (a stack fetched after secret/addon resolution) need the names restored first.

func Load

func Load(content []byte) (*Stackfile, error)

Load parses raw YAML bytes into a Stackfile and validates it.

func (*Stackfile) ToStack

func (sf *Stackfile) ToStack() (openapi.Stack, error)

ToStack converts a validated Stackfile into an API Stack document, ready for the stack apply endpoint. Output is deterministic: resources, volumes, connections, and mappings are emitted in sorted order.

type VolumeDef

type VolumeDef struct {
	Size       string `yaml:"size"`
	AccessMode string `yaml:"access_mode,omitempty"`
}

type VolumeMountDef

type VolumeMountDef struct {
	Name string `yaml:"name"`
	Path string `yaml:"path"`
}

Jump to

Keyboard shortcuts

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