Documentation
¶
Overview ¶
Package installer is the invocation image side of nemo: it reads the operation a CNAB runtime hands to the container and applies the bundle's compose project to the target with the Orchestrator the target names. It keeps no state and knows nothing about stacks, storage or the nemo runtime.
Index ¶
- Constants
- Variables
- func Run(ctx context.Context, operation Operation, orchestrators Orchestrators, ...) error
- func VolumeOwner(installation Installation) map[string]string
- type Container
- type InstallOptions
- type Installation
- type NewOrchestratorFunc
- type Operation
- type Options
- type Orchestrator
- type Orchestrators
- type Problem
- type Problems
- func (problem Problems) AddIf(condition bool, message string)
- func (problem Problems) At(parts ...string) Problems
- func (problem Problems) EmitWarnings(events progress.Sink)
- func (problem Problems) Err() error
- func (problem Problems) WarnIf(condition bool, message string)
- func (problem Problems) Warnings() []Problem
- type Project
- type RegistryAuth
- type UninstallOptions
- type VolumeClaim
Constants ¶
const ( BundleFile = "/cnab/bundle.json" EnvAction = "CNAB_ACTION" EnvInstallationName = "CNAB_INSTALLATION_NAME" EnvBundleName = "CNAB_BUNDLE_NAME" EnvRevision = "CNAB_REVISION" )
Locations and variables of the CNAB contract between a runtime and its invocation image (cnab-spec 103-bundle-runtime.md).
const AppDir = "/cnab/app"
AppDir is the bundle's own directory in the invocation image: the compose project resolves its relative paths there.
const DefaultTimeout = 5 * time.Minute
DefaultTimeout bounds an action whose bundle sets no nemo-timeout.
const VolumeExtension = "x-nemo-volume"
VolumeExtension is the compose extension by which a bundle gives a volume a type, that the target makes of a driver and options.
Variables ¶
var ErrUnsupported = errors.New("unsupported")
ErrUnsupported is returned for an action or an orchestrator the installer does not handle.
Functions ¶
func Run ¶
func Run(ctx context.Context, operation Operation, orchestrators Orchestrators, events progress.Sink) error
Run performs the operation with the orchestrator the nemo-orchestrator parameter names. Only that one is built.
func VolumeOwner ¶
func VolumeOwner(installation Installation) map[string]string
VolumeOwner are the labels that make a volume the stack's own. A network or a container is also its orchestrator's, a volume is not: the data an uninstall keeps is for the next install, whichever orchestrator it uses.
Types ¶
type Container ¶
type Container struct {
LookupEnv func(key string) (string, bool)
// FS is the container's filesystem, rooted at "/".
FS fs.FS
}
Container is what the invocation image sees of the operation: its environment variables and its filesystem.
type InstallOptions ¶
InstallOptions are the options of Orchestrator.Install.
type Installation ¶
Installation identifies what an operation installs. Its fields go on every object the orchestrator creates.
type NewOrchestratorFunc ¶
type NewOrchestratorFunc func(ctx context.Context) (Orchestrator, error)
NewOrchestratorFunc connects an orchestrator to the target.
type Operation ¶
type Operation struct {
Installation string
Revision string
Action string
Bundle cnab.ExtendedBundle
// Parameters holds every parameter that applies to the action, typed by
// its definition: the value the runtime delivered, else the default.
Parameters map[string]any
// Credentials holds every credential the runtime delivered for the action.
Credentials map[string]string
// Relocation maps the bundle's image references to where the images are
// on the target. It is empty when the images were not relocated.
Relocation relocation.ImageRelocationMap
// contains filtered or unexported fields
}
Operation is what a CNAB runtime hands to the invocation image, seen from inside the container. It is the counterpart of cnab-go's driver.Operation: cnab-go based runtimes, Porter and nemo among them, build one from a claim and turn it into these variables and files.
func ReadOperation ¶
ReadOperation reads the operation the runtime handed to the container.
type Options ¶
type Options struct {
Orchestrator string
Timeout time.Duration
Purge bool
// VolumeTypes are what the target makes the volumes of each type of.
VolumeTypes map[string]target.VolumeType
// RegistryAuth holds the credentials the images are pulled with.
RegistryAuth RegistryAuth
}
Options are the installer's reading of the nemo-* parameters, all of them: what the runtime tells it about the target.
type Orchestrator ¶
type Orchestrator interface {
// Name is the value of the nemo-orchestrator parameter that selects it.
Name() string
// Validate reports what it can't honour in the project, without touching the target.
Validate(project *Project) error
// Install brings the installation to the project: it creates what is
// missing, updates what changed, removes what the project no longer
// declares, and waits until everything converged. It is also the upgrade.
Install(ctx context.Context, project *Project, opts InstallOptions) error
// Uninstall removes everything the installation created.
Uninstall(ctx context.Context, project *Project, opts UninstallOptions) error
// Close releases the connection to the target.
Close() error
}
Orchestrator applies a compose project to the target: Compose on a single Docker host, or Swarm. It knows nothing about CNAB.
type Orchestrators ¶
type Orchestrators map[string]NewOrchestratorFunc
Orchestrators are the orchestrators an installer knows, by the value of the nemo-orchestrator parameter. Only the one named is built.
type Problem ¶
Problem is something of the compose project an orchestrator can't honour, at its path in the compose file.
type Problems ¶
type Problems struct {
// contains filtered or unexported fields
}
Problems collects the problems of a project: errors, which stop the action, and warnings, about what an orchestrator ignores. Its methods take values, and every Problems derived with At adds to the same lists.
func (Problems) EmitWarnings ¶
EmitWarnings sends each warning to events: what the orchestrator ignores does not stop the action, but is said.
type Project ¶
type Project struct {
Installation Installation
// Compose is the compose project, named after the stack. Its configs and
// secrets hold their content: an orchestrator never reads a file or a
// variable of the installer to get it.
Compose *types.Project
// Levels holds the services in the order of their depends_on: each level
// only depends on the levels before it.
Levels [][]string
// Labels go on every object of the installation.
Labels map[string]string
// Provisions holds, by volume name, the directory to create before the
// volume, as its target's volume type says.
Provisions map[string]target.VolumeProvision
// InvocationImage is the installer's own image, which provisions the
// volumes' directories.
InvocationImage string
// RegistryAuth holds the credentials the images are pulled with.
RegistryAuth RegistryAuth
}
Project is the compose project of an operation, ready for an orchestrator.
func LoadProject ¶
LoadProject builds the compose project of the operation's bundle.
The compose documents are interpolated with the parameters, each under the name of its environment destination, so that ${REGION} reads the same as with docker compose. Credentials are not: they reach the containers only as compose secrets, from their environment variable or their file. For an uninstall, configs and secrets are left without their content.
type RegistryAuth ¶
type RegistryAuth map[string]registry.AuthConfig
RegistryAuth holds the credentials of registries, by domain, as the runtime hands them in nemo-registry-auth.
type UninstallOptions ¶
type UninstallOptions struct {
Events progress.Sink
// RemoveVolumes also removes the volumes, and the data they hold.
RemoveVolumes bool
}
UninstallOptions are the options of Orchestrator.Uninstall.
type VolumeClaim ¶
VolumeClaim is what a bundle says of a volume in its x-nemo-volume.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package compose is the Compose orchestrator: it applies a compose project to one Docker as plain containers, the way docker compose up --wait does, and labels them the way docker compose does, so that docker compose ps and logs still see them.
|
Package compose is the Compose orchestrator: it applies a compose project to one Docker as plain containers, the way docker compose up --wait does, and labels them the way docker compose does, so that docker compose ps and logs still see them. |
|
convert
Package convert turns a compose project into what the Compose orchestrator creates on the Docker Engine: the create options of each container, its networks and volumes, and the state to wait for, the way docker compose does.
|
Package convert turns a compose project into what the Compose orchestrator creates on the Docker Engine: the create options of each container, its networks and volumes, and the state to wait for, the way docker compose does. |
|
Package swarm is the Swarm orchestrator: it applies a compose project to a swarm as services, the way docker stack deploy does, and waits until they converged.
|
Package swarm is the Swarm orchestrator: it applies a compose project to a swarm as services, the way docker stack deploy does, and waits until they converged. |
|
convert
Package convert turns a compose project into the specs of Swarm objects, the way docker stack deploy does (docker/cli, cli/compose/convert).
|
Package convert turns a compose project into the specs of Swarm objects, the way docker stack deploy does (docker/cli, cli/compose/convert). |