Help us shape the future of Go! Take the 2026 Go Developer Survey

stack

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package stack is the desired state of a stack: the target, the installer, and the installations to make there, by their spec: a bundle, its parameters and the sources of its credentials. nemo up brings the target to it.

Index

Constants

View Source
const (
	YAML = "yaml"
	JSON = "json"
)

Formats of a manifest, which are also its extension.

Variables

This section is empty.

Functions

func CheckDependencies

func CheckDependencies(bundles []cnab.ExtendedBundle) error

CheckDependencies reports each dependency the set does not satisfy: one whose reference is not REGISTRY/NAME, a bundle the set does not have, or one whose version is outside the dependency's ranges.

func DependencyNames

func DependencyNames(bundle cnab.ExtendedBundle) []string

DependencyNames are the names of the bundles the bundle depends on.

func Encode

func Encode(stack Stack, format string) ([]byte, error)

Encode writes the stack as a manifest in format. Its installations give no stack: they are the manifest's.

func Order

func Order(bundles []cnab.ExtendedBundle) ([]cnab.ExtendedBundle, error)

Order sorts the bundles so that each comes after the bundles of the set it depends on, with io.cnab.dependencies; otherwise their order is kept. A dependency on a bundle outside the set does not order anything: CheckDependencies reports it.

Types

type Requirement

type Requirement struct {
	Dependant  cnab.ExtendedBundle
	Dependency cnab.Dependency
}

Requirement is a dependency of a bundle, its dependant.

func Missing

func Missing(bundles []cnab.ExtendedBundle) []Requirement

Missing returns the dependencies no bundle of the set satisfies by name, each once, with the first bundle that requires it: the stack does not list them.

type Stack

type Stack struct {
	Name      string           `json:"name"`
	Target    target.Target    `json:"target"`
	Installer target.Installer `json:"installer,omitzero"`
	// Remote says where an installation's bundle is when its reference has
	// a version alone: the template of a location of the
	// installation's name and its version,
	// docker://ghcr.io/sntns/{{ .Component }}:{{ .Version }}, or
	// oci:.artifacts/prod/{{ .Component }}.oci, relative to the stack file.
	Remote string `json:"remote,omitempty"`
	// Parameters go to every installation whose bundle declares a parameter
	// of their name. An installation's own parameters override them.
	Parameters map[string]string `json:"parameters,omitempty"`
	// Credentials are a CNAB credential set for the whole stack: each goes
	// to every installation whose bundle declares it. An installation's own
	// credentials override them.
	Credentials   []valuesource.Strategy     `json:"credentials,omitempty"`
	Installations []storage.InstallationSpec `json:"installations"`
}

Stack is a stack file, the desired state of a stack, Porter's namespace: its target, its installer, and its installations.

func Load

func Load(path string) (Stack, error)

Load reads a stack file, as Read does, and validates it.

func Read

func Read(path string) (Stack, error)

Read reads a stack file without validating it, to complete it first. Its paths, of bundle files and of credentials, are made absolute from the stack file's directory, and its installations are given its name as their stack.

func (Stack) Source

func (stack Stack) Source(installation storage.InstallationSpec) (string, error)

Source is where the installation's bundle is: its file, its repository at its version, or the remote's location of its name and version.

func (Stack) Validate

func (stack Stack) Validate() error

Validate checks the stack: its installations are its own, and one whose bundle has a version alone needs the remote to locate it.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store keeps the stacks of a home by their name, each its manifest in a directory of its own, <name>/manifest.yaml or manifest.json, where its installations are kept too, and which one is current. A directory of the home without a manifest is no stack: the home can hold other files, those of a tool built on nemo.

func NewStore

func NewStore(root string) *Store

NewStore returns the store of the home root.

func (*Store) Current

func (store *Store) Current() (string, error)

Current returns the name of the current stack, empty when there is none.

func (*Store) List

func (store *Store) List() ([]string, error)

List returns the names of the stacks.

func (*Store) Load

func (store *Store) Load(name string) (Stack, error)

Load reads the stack of that name.

func (*Store) Path

func (store *Store) Path(name string) (string, error)

Path is the stack's manifest, in the format it was written in.

func (*Store) Remove

func (store *Store) Remove(name string) error

Remove removes the stack's directory, its manifest and the records of its installations, and makes no stack current if it was.

func (*Store) Save

func (store *Store) Save(stack Stack, format string) error

Save writes the stack's manifest in format, or else in the one it has already, YAML for a new stack.

func (*Store) Use

func (store *Store) Use(name string) error

Use makes the stack the current one.

Jump to

Keyboard shortcuts

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