compose

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package compose provides utilities for interacting with compose files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckServiceSecrets added in v0.30.0

func CheckServiceSecrets(service types.ServiceConfig, availableSecrets map[string]struct{}) []string

CheckServiceSecrets checks a single service for missing secrets against the provided available secrets map. Returns the list of missing secret names, or nil if all secrets are available.

func GetAvailablePodmanSecrets added in v0.30.0

func GetAvailablePodmanSecrets(ctx context.Context) (map[string]struct{}, error)

GetAvailablePodmanSecrets queries podman for the list of available secrets.

func GetServiceSecrets added in v0.30.0

func GetServiceSecrets(service types.ServiceConfig) []string

GetServiceSecrets returns the list of secret names used by a service. It reads from the x-quad-ops-env-secrets extension.

func IsFileNotFoundError added in v0.30.0

func IsFileNotFoundError(err error) bool

IsFileNotFoundError checks if an error is a fileNotFoundError.

func IsInvalidYAMLError added in v0.30.0

func IsInvalidYAMLError(err error) bool

IsInvalidYAMLError checks if an error is an invalidYAMLError.

func IsLoaderError added in v0.30.0

func IsLoaderError(err error) bool

IsLoaderError checks if an error is a loaderError.

func IsPathError added in v0.30.0

func IsPathError(err error) bool

IsPathError checks if an error is a pathError.

func IsQuadletCompatibilityError added in v0.30.0

func IsQuadletCompatibilityError(err error) bool

IsQuadletCompatibilityError checks if an error is a quadletCompatibilityError.

func IsValidationError added in v0.30.0

func IsValidationError(err error) bool

IsValidationError checks if an error is a validationError.

func Load added in v0.30.0

func Load(ctx context.Context, path string, opts *LoadOptions) (*types.Project, error)

Load loads a single compose project from the filesystem and returns a validated Project.

The path argument can be:

  • A file path: loads that specific compose file
  • A directory: looks for compose.yaml, compose.yml, docker-compose.yaml, or docker-compose.yml in the root directory only (not recursive)

For recursive directory scanning, use LoadAll instead.

opts can be nil for default behavior.

Load returns an error if the file cannot be found, contains invalid YAML, or fails validation against the compose specification.

func ServiceHasMissingSecrets added in v0.30.0

func ServiceHasMissingSecrets(ctx context.Context, service types.ServiceConfig) ([]string, error)

ServiceHasMissingSecrets checks if a specific service has any missing secrets. Returns the list of missing secret names.

Types

type LoadOptions added in v0.30.0

type LoadOptions struct {
	// Workdir sets the base directory for resolving relative paths.
	// If not specified, the directory containing the compose file is used.
	Workdir string

	// Environment sets environment variables that will be used for
	// variable interpolation in the compose file.
	Environment map[string]string

	// EnvFiles specifies .env files to load before parsing the compose file.
	// Variables from these files will be available for interpolation.
	EnvFiles []string
}

LoadOptions contains optional configuration for Load.

type LoadedProject added in v0.30.0

type LoadedProject struct {
	FilePath string
	Project  *types.Project
	Error    error
}

LoadedProject represents a loaded compose project with its file path and any error.

func LoadAll added in v0.30.0

func LoadAll(ctx context.Context, path string, opts *LoadOptions) ([]LoadedProject, error)

LoadAll recursively discovers and loads all compose projects in a directory.

The path argument should be a directory. LoadAll will recursively find all compose.yaml, compose.yml, docker-compose.yaml, and docker-compose.yml files and load each as a separate project.

Returns a slice of loaded projects and their file paths, or an error if the path is invalid. Individual project load errors are collected and returned along with successfully loaded projects.

type MissingSecretsResult added in v0.30.0

type MissingSecretsResult struct {
	ServiceName    string
	MissingSecrets []string
}

MissingSecretsResult contains the result of checking for missing secrets.

func CheckMissingSecrets added in v0.30.0

func CheckMissingSecrets(ctx context.Context, project *types.Project) ([]MissingSecretsResult, error)

CheckMissingSecrets checks if all secrets required by services in a project exist in podman. Returns a slice of MissingSecretsResult for services that have missing secrets.

func FilterServicesWithMissingSecrets added in v0.30.0

func FilterServicesWithMissingSecrets(ctx context.Context, project *types.Project, availableSecrets map[string]struct{}) ([]MissingSecretsResult, error)

FilterServicesWithMissingSecrets removes services with missing secrets from the project. It modifies project.Services in place and returns info about skipped services. If availableSecrets is nil, it queries podman for the list of available secrets.

Jump to

Keyboard shortcuts

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