appexport

package
v0.9.6 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package appexport renders an app as plain Docker Compose plus an env template so leaving Levelrail never needs Levelrail. Secret values are never part of the input type; the caller classifies env before export.

Index

Constants

View Source
const NotesFileName = "NOTES.md"

NotesFileName is the archive entry that carries the app's description and notes.

View Source
const SecretPlaceholder = "CHANGE_ME"

SecretPlaceholder stands in for every value that must not leave the server.

Variables

View Source
var ErrInvalidName = errors.New("appexport: invalid service or variable name")

ErrInvalidName marks a service key or env name that cannot be written to compose or .env without breaking the file structure.

Functions

func ParseNotes

func ParseNotes(doc string) (description, notes string)

ParseNotes reverses RenderNotes so an exported NOTES.md restores both fields.

func RenderNotes

func RenderNotes(description, notes string) string

RenderNotes writes the description as a quoted first line and the notes below it.

func WriteTar

func WriteTar(w io.Writer, files []File) error

WriteTar writes files as a deterministic tar stream (fixed mtime and owner).

Types

type BindMount

type BindMount struct {
	HostPath      string
	ContainerPath string
	ReadOnly      bool
}

BindMount is a host path mount; it is exported as is and flagged in the README.

type File

type File struct {
	Name    string
	Content []byte
}

File is one produced file.

func Render

func Render(in Input) ([]File, error)

Render produces docker-compose.yml, .env.example and README.md, sorted and byte-stable for the same input.

func RenderProject

func RenderProject(in ProjectInput) ([]File, error)

RenderProject composes a project into one docker-compose.yml, .env.example and volumes.json (and a .env only when secrets were explicitly included). Whatever cannot be expressed is listed in the compose header.

type Input

type Input struct {
	AppName  string
	Services []Service
	// Description and Notes are the operator's app notes, written to NOTES.md when either is set.
	Description string
	Notes       string
}

Input is everything one export needs.

type Port

type Port struct {
	HostPort      int
	ContainerPort int
	Protocol      string
}

Port is an extra host-published port.

type Probe

type Probe struct {
	Path     string
	Scheme   string
	TCP      bool
	Exec     []string
	Interval string
	Timeout  string
	Failures int
}

Probe is the readiness probe of a service.

type ProjectInput

type ProjectInput struct {
	Name     string
	Services []Service
	// Databases are managed database names that are not exported as services.
	Databases []string
	// IncludeSecrets also writes a .env holding Service.SecretValues. The
	// default is placeholders only.
	IncludeSecrets bool
}

ProjectInput is a whole project: every app service filed under it, keyed uniquely across apps, plus the databases that this export leaves out.

type Service

type Service struct {
	Key              string
	Image            string
	Command          []string
	Entrypoint       []string
	User             string
	WorkingDir       string
	Runtime          *spec.RuntimeOptions
	Port             int
	Domains          []string
	Env              map[string]string
	SecretEnv        []string
	Refs             map[string]string
	Volumes          []Volume
	BindMounts       []BindMount
	Ports            []Port
	Health           *Probe
	DependsOn        []string
	DependsOnHealthy []string
	Restart          string
	MemoryBytes      int64
	NanoCPUs         int64
	PullPolicy       string
	FilePaths        []string
	// Unsupported lists settings the caller could not express in compose; a
	// project export prints them in its header instead of dropping them.
	Unsupported []string
	// SecretValues holds opt-in plaintext for secret keys, used only by a
	// project export that was explicitly asked to include secrets.
	SecretValues map[string]string
}

Service is one container of the app. Env holds only non-secret values as stored; SecretEnv and Refs hold names and descriptions, never values.

type Volume

type Volume struct {
	Name          string
	ContainerPath string
}

Volume is a named volume mounted into a service.

Jump to

Keyboard shortcuts

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