project

package
v1.0.0-beta.19 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package project loads Docker Compose files and configures client resources.

This package is not a passive loader. It actively drives resource creation by calling into the client package. The typical flow is:

  1. CLI creates a client.Client
  2. project.Load() parses the compose file
  3. project.ToStack() configures resources on the client and builds a Stack
  4. CLI runs the Stack to execute operations on Incus

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadModel

func LoadModel(ctx context.Context, opts ...LoadOption) (map[string]any, error)

LoadModel loads the raw compose model without interpolation. Useful for extracting variable definitions before resolution.

func ServiceGraph

func ServiceGraph(serviceConfigs types.Services, reverse bool) ([]string, error)

ServiceGraph returns services in dependency order using topological sort. If reverse is true, returns reverse order (useful for shutdown).

Types

type LoadOption

type LoadOption func(*LoadOptions)

LoadOption is a functional option for LoadProject.

func LoadEnvFiles

func LoadEnvFiles(files []string) LoadOption

LoadEnvFiles sets alternative environment files.

func LoadFiles

func LoadFiles(files []string) LoadOption

LoadFiles sets the compose configuration file paths.

func LoadName

func LoadName(name string) LoadOption

LoadName sets the project name.

func LoadOsEnv

func LoadOsEnv() LoadOption

LoadOsEnv includes OS environment variables in the project environment. Without this, only .env files and compose file env vars are used (more portable).

func LoadProfiles

func LoadProfiles(profiles []string) LoadOption

LoadProfiles sets the profiles to enable.

func LoadWorkingDir

func LoadWorkingDir(dir string) LoadOption

LoadWorkingDir sets the working directory.

type LoadOptions

type LoadOptions struct {
	// Project name
	Name string

	// Compose configuration file paths
	Files []string

	// Working directory (if empty, uses current directory or path of first file)
	WorkingDir string

	// Alternative environment files
	EnvFiles []string

	// Profiles to enable
	Profiles []string

	// OsEnv includes OS environment variables in project env (default: false for portability)
	OsEnv bool
}

LoadOptions holds configuration for Load and LoadModel.

func NewLoadOptions

func NewLoadOptions(opts ...LoadOption) LoadOptions

NewLoadOptions creates LoadOptions with the given options applied.

type Project

type Project struct {
	*types.Project
	// contains filtered or unexported fields
}

Project wraps a Docker Compose project with Incus client integration.

func New

func New() *Project

New creates a new Project.

func (*Project) HealthdConfig

func (p *Project) HealthdConfig() (incusURL, network string)

HealthdConfig reads the top-level x-incus-compose.healthd extension. Returns empty strings when the key is absent.

func (*Project) InstanceNames

func (p *Project) InstanceNames() []string

InstanceNames returns the Incus instance names for all services.

func (*Project) Load

func (p *Project) Load(ctx context.Context, opts ...LoadOption) (*Project, error)

Load loads a compose project with full interpolation and validation.

func (*Project) ProjectConfig

func (p *Project) ProjectConfig() map[string]string

ProjectConfig reads `x-incus` extensions from the project and returns that.

func (*Project) ToStack

func (p *Project) ToStack(c *client.Client, stack *client.Stack, opts ...ToStackOption) error

ToStack converts the compose project services to Incus stack operations.

type ToStackOption

type ToStackOption func(o *ToStackOptions)

ToStackOption is a functional option for ToStack.

func ToStackFull

func ToStackFull() ToStackOption

ToStackFull fetches complete instance state including image alias and full instance details.

func ToStackImagesOnly

func ToStackImagesOnly() ToStackOption

ToStackImagesOnly configures ToStack to only add images to the the stack.

func ToStackInstancesOnly

func ToStackInstancesOnly() ToStackOption

ToStackInstancesOnly configures ToStack to only add instances to the stack.

func ToStackNoImages

func ToStackNoImages() ToStackOption

ToStackNoImages doesn't add images to the stack.

func ToStackOnlyServices

func ToStackOnlyServices(services []string) ToStackOption

ToStackOnlyServices limits the stack to the specified services.

func ToStackReverse

func ToStackReverse() ToStackOption

ToStackReverse reverses the service dependency graph order. Use for teardown so dependants are stopped before their dependencies. Note: cross-kind priority ordering (e.g. instances vs networks) is handled automatically by Stack.ForAction and does not require this option.

func ToStackScale

func ToStackScale(scale map[string]int) ToStackOption

ToStackScale sets replica count overrides for services.

func ToStackStorageVolumes

func ToStackStorageVolumes() ToStackOption

ToStackStorageVolumes adds storage volumes to the stack.

func ToStackWithDeps

func ToStackWithDeps() ToStackOption

ToStackWithDeps expands the OnlyServices selection to include linked services: in start direction the services a selected one depends on, and in reverse (stop) direction the services that depend on a selected one. Without it the stack is limited to exactly the selected services.

type ToStackOptions

type ToStackOptions struct {
	OnlyServices   []string
	Reverse        bool
	Full           bool
	NoImages       bool
	StorageVolumes bool
	InstancesOnly  bool
	ImagesOnly     bool
	Deps           bool
	Scale          map[string]int // service name -> replica count override
}

ToStackOptions configures how services are converted to stack operations.

Jump to

Keyboard shortcuts

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