mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-12 06:27:07 +08:00
vendor: github.com/compose-spec/compose-go v1.18.3
- Parse service device count to int if possible - introduce ResourceResolver to accept remote resources - use include.env_file to resolve variables in included compose.yaml file - remove potential dependencies to disabled services in ForServices - ability to convert a mapping (back) to KEY=VALUE strings - load: include details about included files on Project - include disabled services - local environment to override included .env - load: move env var profile detection to option - add support for multi-document yaml full diff: https://github.com/compose-spec/compose-go/compare/v1.17.0...v1.18.3 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
52
vendor/github.com/compose-spec/compose-go/cli/options.go
generated
vendored
52
vendor/github.com/compose-spec/compose-go/cli/options.go
generated
vendored
@ -17,6 +17,7 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@ -35,6 +36,8 @@ import (
|
||||
|
||||
// ProjectOptions provides common configuration for loading a project.
|
||||
type ProjectOptions struct {
|
||||
ctx context.Context
|
||||
|
||||
// Name is a valid Compose project name to be used or empty.
|
||||
//
|
||||
// If empty, the project loader will automatically infer a reasonable
|
||||
@ -63,7 +66,7 @@ type ProjectOptions struct {
|
||||
// NOTE: For security, the loader does not automatically expose any
|
||||
// process environment variables. For convenience, WithOsEnv can be
|
||||
// used if appropriate.
|
||||
Environment map[string]string
|
||||
Environment types.Mapping
|
||||
|
||||
// EnvFiles are file paths to ".env" files with additional environment
|
||||
// variable data.
|
||||
@ -191,7 +194,7 @@ func WithEnv(env []string) ProjectOptionsFn {
|
||||
}
|
||||
}
|
||||
|
||||
// WithDiscardEnvFiles sets discards the `env_file` section after resolving to
|
||||
// WithDiscardEnvFile sets discards the `env_file` section after resolving to
|
||||
// the `environment` section
|
||||
func WithDiscardEnvFile(o *ProjectOptions) error {
|
||||
o.loadOptions = append(o.loadOptions, loader.WithDiscardEnvFiles)
|
||||
@ -206,6 +209,15 @@ func WithLoadOptions(loadOptions ...func(*loader.Options)) ProjectOptionsFn {
|
||||
}
|
||||
}
|
||||
|
||||
// WithDefaultProfiles uses the provided profiles (if any), and falls back to
|
||||
// profiles specified via the COMPOSE_PROFILES environment variable otherwise.
|
||||
func WithDefaultProfiles(profile ...string) ProjectOptionsFn {
|
||||
if len(profile) == 0 {
|
||||
profile = strings.Split(os.Getenv(consts.ComposeProfiles), ",")
|
||||
}
|
||||
return WithProfiles(profile)
|
||||
}
|
||||
|
||||
// WithProfiles sets profiles to be activated
|
||||
func WithProfiles(profiles []string) ProjectOptionsFn {
|
||||
return func(o *ProjectOptions) error {
|
||||
@ -225,8 +237,9 @@ func WithOsEnv(o *ProjectOptions) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// WithEnvFile set an alternate env file
|
||||
// deprecated - use WithEnvFiles
|
||||
// WithEnvFile sets an alternate env file.
|
||||
//
|
||||
// Deprecated: use WithEnvFiles instead.
|
||||
func WithEnvFile(file string) ProjectOptionsFn {
|
||||
var files []string
|
||||
if file != "" {
|
||||
@ -253,11 +266,7 @@ func WithDotEnv(o *ProjectOptions) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for k, v := range envMap {
|
||||
if _, set := o.Environment[k]; !set {
|
||||
o.Environment[k] = v
|
||||
}
|
||||
}
|
||||
o.Environment.Merge(envMap)
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -301,6 +310,24 @@ func WithResolvedPaths(resolve bool) ProjectOptionsFn {
|
||||
}
|
||||
}
|
||||
|
||||
// WithContext sets the context used to load model and resources
|
||||
func WithContext(ctx context.Context) ProjectOptionsFn {
|
||||
return func(o *ProjectOptions) error {
|
||||
o.ctx = ctx
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// WithResourceLoader register support for ResourceLoader to manage remote resources
|
||||
func WithResourceLoader(r loader.ResourceLoader) ProjectOptionsFn {
|
||||
return func(o *ProjectOptions) error {
|
||||
o.loadOptions = append(o.loadOptions, func(options *loader.Options) {
|
||||
options.ResourceLoaders = append(options.ResourceLoaders, r)
|
||||
})
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// DefaultFileNames defines the Compose file names for auto-discovery (in order of preference)
|
||||
var DefaultFileNames = []string{"compose.yaml", "compose.yml", "docker-compose.yml", "docker-compose.yaml"}
|
||||
|
||||
@ -367,7 +394,12 @@ func ProjectFromOptions(options *ProjectOptions) (*types.Project, error) {
|
||||
withNamePrecedenceLoad(absWorkingDir, options),
|
||||
withConvertWindowsPaths(options))
|
||||
|
||||
project, err := loader.Load(types.ConfigDetails{
|
||||
ctx := options.ctx
|
||||
if ctx == nil {
|
||||
ctx = context.Background()
|
||||
}
|
||||
|
||||
project, err := loader.LoadWithContext(ctx, types.ConfigDetails{
|
||||
ConfigFiles: configs,
|
||||
WorkingDir: workingDir,
|
||||
Environment: options.Environment,
|
||||
|
Reference in New Issue
Block a user