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

nemo

package
v0.3.2 Latest Latest
Warning

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

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

Documentation

Overview

Package nemo is nemo's API. The nemo CLI and the Terraform provider are its clients: they turn their inputs into requests, and render the results. Nothing here prints.

Index

Constants

View Source
const Redacted = "*******"

Redacted replaces the value of a sensitive parameter or output.

Variables

This section is empty.

Functions

func LoadBundle added in v0.3.0

func LoadBundle(ctx context.Context, source string) (cnab.BundleReference, error)

LoadBundle reads a bundle from a bundle.json, or pulls it from where it was pushed.

Types

type ActionRequest

type ActionRequest struct {
	// InstallationSpec names the installation and its stack; its name can
	// be left out when BundleSource is given. Its parameters and
	// credentials override the installation's, and its bundle reference is
	// recorded with it.
	storage.InstallationSpec
	// BundleSource is the bundle to run: a bundle.json, or where it was
	// pushed, docker://REFERENCE or oci:PATH. Install needs it; upgrade and
	// uninstall take the installation's when it is left out.
	BundleSource string
	// Target receives the deployment. Left empty, it is the installation's;
	// it can't change once installed.
	Target target.Target
	// Installer says where the invocation image runs. Left empty, it is the
	// installation's.
	Installer target.Installer
	// Progress receives the events of the action.
	Progress progress.Sink
	// Validate runs the bundle's validate action instead, with what the
	// action would run with: nothing changes, and nothing is recorded.
	Validate bool
}

ActionRequest is an action on one installation of a bundle. What it leaves out comes from the installation, when nemo knows it.

type BundleVersion

type BundleVersion struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

BundleVersion identifies a bundle, by its name and version.

type DownRequest

type DownRequest struct {
	Name string
	// Purge also removes the volumes.
	Purge    bool
	Progress progress.Sink
}

DownRequest removes a stack, by its name.

type InstallationState

type InstallationState struct {
	Name      string         `json:"name"`
	Version   string         `json:"version"`
	Installed bool           `json:"installed"`
	Action    string         `json:"action"`
	Result    string         `json:"result"`
	Modified  time.Time      `json:"modified"`
	Services  []ServiceState `json:"services,omitempty"`
}

InstallationState is where an installation stands: its last action, and its services.

type LogsRequest

type LogsRequest struct {
	Stack string
	// Installation and Service narrow the services; empty, every one.
	Installation string
	Service      string
	Follow       bool
	// Tail is how many lines of each service to start with: a number, or all.
	Tail string
	// Line receives each line with its service, from as many goroutines as
	// there are services.
	Line func(service, line string)
}

LogsRequest follows the logs of the services of a stack.

type Nemo

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

Nemo is the entry point of the API.

func New

func New(opts Options) (*Nemo, error)

New returns the API.

func (*Nemo) Down

func (nemo *Nemo) Down(ctx context.Context, request DownRequest) (StackResult, error)

Down uninstalls every installation of the stack, dependants first. It needs nothing but the stack's name: the rest comes from the installations. A stack with nothing installed is already down.

func (*Nemo) Install

func (nemo *Nemo) Install(ctx context.Context, request ActionRequest) (Run, error)

Install installs the bundle. Installing again an installed bundle applies it again, as an upgrade does.

func (*Nemo) Installation

func (nemo *Nemo) Installation(ctx context.Context, stack, name string) (storage.Installation, error)

Installation returns an installation, as nemo keeps it.

func (*Nemo) Installations

func (nemo *Nemo) Installations(ctx context.Context, stack string) ([]storage.Installation, error)

Installations returns the installations of the stack, as nemo keeps them.

func (*Nemo) Logs

func (nemo *Nemo) Logs(ctx context.Context, request LogsRequest) error

Logs writes the logs of the services until they end, or until the context is done when following them.

func (*Nemo) Runs

func (nemo *Nemo) Runs(ctx context.Context, stack, name string) ([]Run, error)

Runs returns the actions of an installation, oldest first, each as up and the actions return it: its claim, with its result and outputs.

func (*Nemo) Status

func (nemo *Nemo) Status(ctx context.Context, stack string) (StackStatus, error)

Status reads the installations of the stack, then the services they run on their target.

func (*Nemo) Uninstall

func (nemo *Nemo) Uninstall(ctx context.Context, request ActionRequest) (Run, error)

Uninstall removes an installation.

func (*Nemo) Up

func (nemo *Nemo) Up(ctx context.Context, request UpRequest) (StackResult, error)

Up installs the bundles of the stack in the order of their dependencies, or upgrades those installed, then uninstalls the installations of the stack whose bundle it no longer has, dependants first. It checks every bundle that has a validate action first, and stops at the first action that fails.

func (*Nemo) Upgrade

func (nemo *Nemo) Upgrade(ctx context.Context, request ActionRequest) (Run, error)

Upgrade upgrades an installation, to the bundle given or to its own.

type Options

type Options struct {
	// Home is where nemo keeps its files. Empty, it is $NEMO_HOME, or ~/.nemo.
	Home string
}

Options configure nemo.

type Run

type Run struct {
	Installation string            `json:"installation"`
	Revision     string            `json:"revision"`
	Action       string            `json:"action"`
	Bundle       BundleVersion     `json:"bundle"`
	Target       target.Target     `json:"target"`
	Driver       string            `json:"driver"`
	Parameters   map[string]any    `json:"parameters,omitempty"`
	Credentials  []string          `json:"credentials,omitempty"`
	Status       string            `json:"status"`
	Started      time.Time         `json:"started"`
	Ended        time.Time         `json:"ended"`
	Outputs      map[string]string `json:"outputs,omitempty"`
}

Run is the record of an action: what was asked, and what came of it. Values of sensitive parameters and outputs are redacted, and credentials appear by name only.

type ServiceState

type ServiceState struct {
	Name    string `json:"name"`
	Running int    `json:"running"`
	Desired int    `json:"desired"`
	State   string `json:"state"`
}

ServiceState is a service as the target runs it: its tasks or containers running out of those wanted, and the state of the least advanced.

type StackResult

type StackResult struct {
	Runs []Run `json:"runs"`
}

StackResult is the runs of an up or a down, in the order they ran.

type StackStatus

type StackStatus struct {
	Name          string              `json:"name"`
	Target        target.Target       `json:"target"`
	Installations []InstallationState `json:"installations"`
}

StackStatus is where a stack stands: each installation as nemo keeps it, and its services as the target runs them.

type UpRequest

type UpRequest struct {
	Stack stack.Stack
	// Only names the installations to act on, with their dependencies not
	// installed yet; empty, all of the stack's.
	// Up then leaves alone the others, and what the stack no longer has.
	Only []string
	// Purge also removes the volumes of the bundles the stack no longer has.
	Purge bool
	// Progress receives the events of the actions: first each installation
	// pending, then what each action does.
	Progress progress.Sink
}

UpRequest brings a stack to its file.

Jump to

Keyboard shortcuts

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