Documentation ¶
Index ¶
- Variables
- func ProjectFromOptions(ctx context.Context, options *ProjectOptions) (*types.Project, error)
- func WithConfigFileEnv(o *ProjectOptions) error
- func WithDefaultConfigPath(o *ProjectOptions) error
- func WithDiscardEnvFile(o *ProjectOptions) error
- func WithDotEnv(o *ProjectOptions) error
- func WithOsEnv(o *ProjectOptions) error
- func WithoutEnvironmentResolution(o *ProjectOptions) error
- type ProjectOptions
- func (o *ProjectOptions) GetWorkingDir() (string, error)
- func (o *ProjectOptions) LoadModel(ctx context.Context) (map[string]any, error)
- func (o *ProjectOptions) LoadProject(ctx context.Context) (*types.Project, error)
- func (o *ProjectOptions) ReadConfigFiles(ctx context.Context, workingDir string, options *ProjectOptions) (*types.ConfigDetails, error)
- func (o *ProjectOptions) WithListeners(listeners ...loader.Listener)
- type ProjectOptionsFn
- func WithConsistency(consistency bool) ProjectOptionsFn
- func WithDefaultProfiles(profiles ...string) ProjectOptionsFn
- func WithEnv(env []string) ProjectOptionsFn
- func WithEnvFile(file string) ProjectOptionsFndeprecated
- func WithEnvFiles(file ...string) ProjectOptionsFn
- func WithExtension(name string, typ any) ProjectOptionsFn
- func WithInterpolation(interpolation bool) ProjectOptionsFn
- func WithLoadOptions(loadOptions ...func(*loader.Options)) ProjectOptionsFn
- func WithName(name string) ProjectOptionsFn
- func WithNormalization(normalization bool) ProjectOptionsFn
- func WithProfiles(profiles []string) ProjectOptionsFn
- func WithResolvedPaths(resolve bool) ProjectOptionsFn
- func WithResourceLoader(r loader.ResourceLoader) ProjectOptionsFn
- func WithWorkingDirectory(wd string) ProjectOptionsFn
Constants ¶
This section is empty.
Variables ¶
var DefaultFileNames = []string{"compose.yaml", "compose.yml", "docker-compose.yml", "docker-compose.yaml"}
DefaultFileNames defines the Compose file names for auto-discovery (in order of preference)
var DefaultOverrideFileNames = []string{"compose.override.yml", "compose.override.yaml", "docker-compose.override.yml", "docker-compose.override.yaml"}
DefaultOverrideFileNames defines the Compose override file names for auto-discovery (in order of preference)
Functions ¶
func ProjectFromOptions ¶
ProjectFromOptions load a compose project based on command line options Deprecated: use ProjectOptions.LoadProject or ProjectOptions.LoadModel
func WithConfigFileEnv ¶
func WithConfigFileEnv(o *ProjectOptions) error
WithConfigFileEnv allow to set compose config file paths by COMPOSE_FILE environment variable
func WithDefaultConfigPath ¶
func WithDefaultConfigPath(o *ProjectOptions) error
WithDefaultConfigPath searches for default config files from working directory
func WithDiscardEnvFile ¶
func WithDiscardEnvFile(o *ProjectOptions) error
WithDiscardEnvFile sets discards the `env_file` section after resolving to the `environment` section
func WithDotEnv ¶
func WithDotEnv(o *ProjectOptions) error
WithDotEnv imports environment variables from .env file
func WithOsEnv ¶
func WithOsEnv(o *ProjectOptions) error
WithOsEnv imports environment variables from OS
func WithoutEnvironmentResolution ¶
func WithoutEnvironmentResolution(o *ProjectOptions) error
WithoutEnvironmentResolution disable environment resolution
Types ¶
type ProjectOptions ¶
type ProjectOptions struct { // Name is a valid Compose project name to be used or empty. // // If empty, the project loader will automatically infer a reasonable // project name if possible. Name string // WorkingDir is a file path to use as the project directory or empty. // // If empty, the project loader will automatically infer a reasonable // working directory if possible. WorkingDir string // ConfigPaths are file paths to one or more Compose files. // // These are applied in order by the loader following the override logic // as described in the spec. // // The first entry is required and is the primary Compose file. // For convenience, WithConfigFileEnv and WithDefaultConfigPath // are provided to populate this in a predictable manner. ConfigPaths []string // Environment are additional environment variables to make available // for interpolation. // // NOTE: For security, the loader does not automatically expose any // process environment variables. For convenience, WithOsEnv can be // used if appropriate. Environment types.Mapping // EnvFiles are file paths to ".env" files with additional environment // variable data. // // These are loaded in-order, so it is possible to override variables or // in subsequent files. // // This field is optional, but any file paths that are included here must // exist or an error will be returned during load. EnvFiles []string // Callbacks to retrieve metadata information during parse defined before // creating the project Listeners []loader.Listener // contains filtered or unexported fields }
ProjectOptions provides common configuration for loading a project.
func NewProjectOptions ¶
func NewProjectOptions(configs []string, opts ...ProjectOptionsFn) (*ProjectOptions, error)
NewProjectOptions creates ProjectOptions
func (*ProjectOptions) GetWorkingDir ¶
func (o *ProjectOptions) GetWorkingDir() (string, error)
func (*ProjectOptions) LoadModel ¶
LoadModel loads compose file according to options and returns a raw (yaml tree) model
func (*ProjectOptions) LoadProject ¶
LoadProject loads compose file according to options and bind to types.Project go structs
func (*ProjectOptions) ReadConfigFiles ¶ added in v2.4.0
func (o *ProjectOptions) ReadConfigFiles(ctx context.Context, workingDir string, options *ProjectOptions) (*types.ConfigDetails, error)
ReadConfigFiles reads ConfigFiles and populates the content field
func (*ProjectOptions) WithListeners ¶
func (o *ProjectOptions) WithListeners(listeners ...loader.Listener)
Append listener to event
type ProjectOptionsFn ¶
type ProjectOptionsFn func(*ProjectOptions) error
func WithConsistency ¶
func WithConsistency(consistency bool) ProjectOptionsFn
WithConsistency set ProjectOptions to enable/skip consistency
func WithDefaultProfiles ¶
func WithDefaultProfiles(profiles ...string) ProjectOptionsFn
WithDefaultProfiles uses the provided profiles (if any), and falls back to profiles specified via the COMPOSE_PROFILES environment variable otherwise.
func WithEnv ¶
func WithEnv(env []string) ProjectOptionsFn
WithEnv defines a key=value set of variables used for compose file interpolation
func WithEnvFile
deprecated
func WithEnvFile(file string) ProjectOptionsFn
WithEnvFile sets an alternate env file.
Deprecated: use WithEnvFiles instead.
func WithEnvFiles ¶
func WithEnvFiles(file ...string) ProjectOptionsFn
WithEnvFiles set env file(s) to be loaded to set project environment. defaults to local .env file if no explicit file is selected, until COMPOSE_DISABLE_ENV_FILE is set
func WithExtension ¶
func WithExtension(name string, typ any) ProjectOptionsFn
WithExtension register a know extension `x-*` with the go struct type to decode into
func WithInterpolation ¶
func WithInterpolation(interpolation bool) ProjectOptionsFn
WithInterpolation set ProjectOptions to enable/skip interpolation
func WithLoadOptions ¶
func WithLoadOptions(loadOptions ...func(*loader.Options)) ProjectOptionsFn
WithLoadOptions provides a hook to control how compose files are loaded
func WithNormalization ¶
func WithNormalization(normalization bool) ProjectOptionsFn
WithNormalization set ProjectOptions to enable/skip normalization
func WithProfiles ¶
func WithProfiles(profiles []string) ProjectOptionsFn
WithProfiles sets profiles to be activated
func WithResolvedPaths ¶
func WithResolvedPaths(resolve bool) ProjectOptionsFn
WithResolvedPaths set ProjectOptions to enable paths resolution
func WithResourceLoader ¶
func WithResourceLoader(r loader.ResourceLoader) ProjectOptionsFn
WithResourceLoader register support for ResourceLoader to manage remote resources
func WithWorkingDirectory ¶
func WithWorkingDirectory(wd string) ProjectOptionsFn
WithWorkingDirectory defines ProjectOptions' working directory