Documentation
¶
Overview ¶
Package compose provides utilities for interacting with compose files.
Index ¶
- func CheckServiceSecrets(service types.ServiceConfig, availableSecrets map[string]struct{}) []string
- func GetAvailablePodmanSecrets(ctx context.Context) (map[string]struct{}, error)
- func GetServiceSecrets(service types.ServiceConfig) []string
- func IsFileNotFoundError(err error) bool
- func IsInvalidYAMLError(err error) bool
- func IsLoaderError(err error) bool
- func IsPathError(err error) bool
- func IsQuadletCompatibilityError(err error) bool
- func IsValidationError(err error) bool
- func Load(ctx context.Context, path string, opts *LoadOptions) (*types.Project, error)
- func ServiceHasMissingSecrets(ctx context.Context, service types.ServiceConfig) ([]string, error)
- type LoadOptions
- type LoadedProject
- type MissingSecretsResult
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
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
IsFileNotFoundError checks if an error is a fileNotFoundError.
func IsInvalidYAMLError ¶ added in v0.30.0
IsInvalidYAMLError checks if an error is an invalidYAMLError.
func IsLoaderError ¶ added in v0.30.0
IsLoaderError checks if an error is a loaderError.
func IsPathError ¶ added in v0.30.0
IsPathError checks if an error is a pathError.
func IsQuadletCompatibilityError ¶ added in v0.30.0
IsQuadletCompatibilityError checks if an error is a quadletCompatibilityError.
func IsValidationError ¶ added in v0.30.0
IsValidationError checks if an error is a validationError.
func Load ¶ added in v0.30.0
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
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
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
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.