vendor: update compose-go to v1.19.0

Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
This commit is contained in:
David Karlsson 2023-09-29 20:52:04 +02:00
parent e6756d951a
commit c8002e58a4
10 changed files with 131 additions and 42 deletions

2
go.mod
View File

@ -5,7 +5,7 @@ go 1.20
require ( require (
github.com/Masterminds/semver/v3 v3.2.1 github.com/Masterminds/semver/v3 v3.2.1
github.com/aws/aws-sdk-go-v2/config v1.18.16 github.com/aws/aws-sdk-go-v2/config v1.18.16
github.com/compose-spec/compose-go v1.18.4 github.com/compose-spec/compose-go v1.19.0
github.com/containerd/console v1.0.3 github.com/containerd/console v1.0.3
github.com/containerd/containerd v1.7.2 github.com/containerd/containerd v1.7.2
github.com/containerd/continuity v0.4.1 github.com/containerd/continuity v0.4.1

4
go.sum
View File

@ -127,8 +127,8 @@ github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWH
github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/codahale/rfc6979 v0.0.0-20141003034818-6a90f24967eb h1:EDmT6Q9Zs+SbUoc7Ik9EfrFqcylYqgPZ9ANSbTAntnE= github.com/codahale/rfc6979 v0.0.0-20141003034818-6a90f24967eb h1:EDmT6Q9Zs+SbUoc7Ik9EfrFqcylYqgPZ9ANSbTAntnE=
github.com/compose-spec/compose-go v1.18.4 h1:yLYfsc3ATAYZVAJcXyx/V847/JVBmf3pfKfR13mXU4s= github.com/compose-spec/compose-go v1.19.0 h1:t68gAcwStDg0hy2kFvqHJIksf6xkqRnlSKfL45/ETqo=
github.com/compose-spec/compose-go v1.18.4/go.mod h1:+MdqXV4RA7wdFsahh/Kb8U0pAJqkg7mr4PM9tFKU8RM= github.com/compose-spec/compose-go v1.19.0/go.mod h1:+MdqXV4RA7wdFsahh/Kb8U0pAJqkg7mr4PM9tFKU8RM=
github.com/containerd/cgroups v1.1.0 h1:v8rEWFl6EoqHB+swVNjVoCJE8o3jX7e8nqBGPLaDFBM= github.com/containerd/cgroups v1.1.0 h1:v8rEWFl6EoqHB+swVNjVoCJE8o3jX7e8nqBGPLaDFBM=
github.com/containerd/console v1.0.3 h1:lIr7SlA5PxZyMV30bDW0MGbiOPXwc63yRuCP0ARubLw= github.com/containerd/console v1.0.3 h1:lIr7SlA5PxZyMV30bDW0MGbiOPXwc63yRuCP0ARubLw=
github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U= github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U=

View File

@ -328,6 +328,14 @@ func WithResourceLoader(r loader.ResourceLoader) ProjectOptionsFn {
} }
} }
// WithoutEnvironmentResolution disable environment resolution
func WithoutEnvironmentResolution(o *ProjectOptions) error {
o.loadOptions = append(o.loadOptions, func(options *loader.Options) {
options.SkipResolveEnvironment = true
})
return nil
}
// DefaultFileNames defines the Compose file names for auto-discovery (in order of preference) // 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"} var DefaultFileNames = []string{"compose.yaml", "compose.yml", "docker-compose.yml", "docker-compose.yaml"}

View File

@ -61,6 +61,8 @@ type Options struct {
SkipExtends bool SkipExtends bool
// SkipInclude will ignore `include` and only load model from file(s) set by ConfigDetails // SkipInclude will ignore `include` and only load model from file(s) set by ConfigDetails
SkipInclude bool SkipInclude bool
// SkipResolveEnvironment will ignore computing `environment` for services
SkipResolveEnvironment bool
// Interpolation options // Interpolation options
Interpolate *interp.Options Interpolate *interp.Options
// Discard 'env_file' entries after resolving to 'environment' section // Discard 'env_file' entries after resolving to 'environment' section
@ -255,7 +257,6 @@ func load(ctx context.Context, configDetails types.ConfigDetails, opts *Options,
loaded = append(loaded, mainFile) loaded = append(loaded, mainFile)
includeRefs := make(map[string][]types.IncludeConfig) includeRefs := make(map[string][]types.IncludeConfig)
first := true
for _, file := range configDetails.ConfigFiles { for _, file := range configDetails.ConfigFiles {
var postProcessor PostProcessor var postProcessor PostProcessor
configDict := file.Config configDict := file.Config
@ -285,22 +286,21 @@ func load(ctx context.Context, configDetails types.ConfigDetails, opts *Options,
} }
} }
if first { if model == nil {
first = false
model = cfg model = cfg
return nil } else {
}
merged, err := merge([]*types.Config{model, cfg}) merged, err := merge([]*types.Config{model, cfg})
if err != nil { if err != nil {
return err return err
} }
model = merged
}
if postProcessor != nil { if postProcessor != nil {
err = postProcessor.Apply(merged) err = postProcessor.Apply(model)
if err != nil { if err != nil {
return err return err
} }
} }
model = merged
return nil return nil
} }
@ -337,6 +337,10 @@ func load(ctx context.Context, configDetails types.ConfigDetails, opts *Options,
} }
} }
if model == nil {
return nil, errors.New("empty compose file")
}
project := &types.Project{ project := &types.Project{
Name: opts.projectName, Name: opts.projectName,
WorkingDir: configDetails.WorkingDir, WorkingDir: configDetails.WorkingDir,
@ -385,9 +389,14 @@ func load(ctx context.Context, configDetails types.ConfigDetails, opts *Options,
project.ApplyProfiles(opts.Profiles) project.ApplyProfiles(opts.Profiles)
if !opts.SkipResolveEnvironment {
err := project.ResolveServicesEnvironment(opts.discardEnvFiles) err := project.ResolveServicesEnvironment(opts.discardEnvFiles)
if err != nil {
return nil, err
}
}
return project, err return project, nil
} }
func InvalidProjectNameErr(v string) error { func InvalidProjectNameErr(v string) error {

View File

@ -115,6 +115,13 @@ func ResolveServiceRelativePaths(workingDir string, s *types.ServiceConfig) {
} }
s.Volumes[i].Source = resolveMaybeUnixPath(workingDir, vol.Source) s.Volumes[i].Source = resolveMaybeUnixPath(workingDir, vol.Source)
} }
if s.Develop != nil {
for i, w := range s.Develop.Watch {
w.Path = absPath(workingDir, w.Path)
s.Develop.Watch[i] = w
}
}
} }
func absPath(workingDir string, filePath string) string { func absPath(workingDir string, filePath string) string {

View File

@ -91,6 +91,7 @@
"type": "object", "type": "object",
"properties": { "properties": {
"develop": {"$ref": "#/definitions/development"},
"deploy": {"$ref": "#/definitions/deployment"}, "deploy": {"$ref": "#/definitions/deployment"},
"annotations": {"$ref": "#/definitions/list_or_dict"}, "annotations": {"$ref": "#/definitions/list_or_dict"},
"attach": {"type": "boolean"}, "attach": {"type": "boolean"},
@ -463,6 +464,26 @@
"additionalProperties": false, "additionalProperties": false,
"patternProperties": {"^x-": {}} "patternProperties": {"^x-": {}}
}, },
"development": {
"id": "#/definitions/development",
"type": ["object", "null"],
"properties": {
"watch": {
"type": "array",
"items": {
"type": "object",
"properties": {
"ignore": {"type": "array", "items": {"type": "string"}},
"path": {"type": "string"},
"action": {"type": "string", "enum": ["rebuild", "sync"]},
"target": {"type": "string"}
}
},
"additionalProperties": false,
"patternProperties": {"^x-": {}}
}
}
},
"deployment": { "deployment": {
"id": "#/definitions/deployment", "id": "#/definitions/deployment",
"type": ["object", "null"], "type": ["object", "null"],

View File

@ -28,12 +28,20 @@ import (
var delimiter = "\\$" var delimiter = "\\$"
var substitutionNamed = "[_a-z][_a-z0-9]*" var substitutionNamed = "[_a-z][_a-z0-9]*"
var substitutionBraced = "[_a-z][_a-z0-9]*(?::?[-+?](.*))?" var substitutionBraced = "[_a-z][_a-z0-9]*(?::?[-+?](.*))?"
var groupEscaped = "escaped"
var groupNamed = "named"
var groupBraced = "braced"
var groupInvalid = "invalid"
var patternString = fmt.Sprintf( var patternString = fmt.Sprintf(
"%s(?i:(?P<escaped>%s)|(?P<named>%s)|{(?:(?P<braced>%s)}|(?P<invalid>)))", "%s(?i:(?P<%s>%s)|(?P<%s>%s)|{(?:(?P<%s>%s)}|(?P<%s>)))",
delimiter, delimiter, substitutionNamed, substitutionBraced, delimiter,
groupEscaped, delimiter,
groupNamed, substitutionNamed,
groupBraced, substitutionBraced,
groupInvalid,
) )
var defaultPattern = regexp.MustCompile(patternString) var defaultPattern = regexp.MustCompile(patternString)
@ -164,14 +172,14 @@ func DefaultReplacementAppliedFunc(substring string, mapping Mapping, cfg *Confi
matches := pattern.FindStringSubmatch(substring) matches := pattern.FindStringSubmatch(substring)
groups := matchGroups(matches, pattern) groups := matchGroups(matches, pattern)
if escaped := groups["escaped"]; escaped != "" { if escaped := groups[groupEscaped]; escaped != "" {
return escaped, true, nil return escaped, true, nil
} }
braced := false braced := false
substitution := groups["named"] substitution := groups[groupNamed]
if substitution == "" { if substitution == "" {
substitution = groups["braced"] substitution = groups[groupBraced]
braced = true braced = true
} }
@ -322,12 +330,12 @@ func extractVariable(value interface{}, pattern *regexp.Regexp) ([]Variable, boo
values := []Variable{} values := []Variable{}
for _, match := range matches { for _, match := range matches {
groups := matchGroups(match, pattern) groups := matchGroups(match, pattern)
if escaped := groups["escaped"]; escaped != "" { if escaped := groups[groupEscaped]; escaped != "" {
continue continue
} }
val := groups["named"] val := groups[groupNamed]
if val == "" { if val == "" {
val = groups["braced"] val = groups[groupBraced]
} }
name := val name := val
var defaultValue string var defaultValue string

View File

@ -0,0 +1,35 @@
/*
Copyright 2020 The Compose Specification Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package types
type DevelopConfig struct {
Watch []Trigger `json:"watch,omitempty"`
}
type WatchAction string
const (
WatchActionSync WatchAction = "sync"
WatchActionRebuild WatchAction = "rebuild"
)
type Trigger struct {
Path string `json:"path,omitempty"`
Action WatchAction `json:"action,omitempty"`
Target string `json:"target,omitempty"`
Ignore []string `json:"ignore,omitempty"`
}

View File

@ -91,6 +91,7 @@ type ServiceConfig struct {
Annotations Mapping `yaml:"annotations,omitempty" json:"annotations,omitempty"` Annotations Mapping `yaml:"annotations,omitempty" json:"annotations,omitempty"`
Attach *bool `yaml:"attach,omitempty" json:"attach,omitempty"` Attach *bool `yaml:"attach,omitempty" json:"attach,omitempty"`
Build *BuildConfig `yaml:"build,omitempty" json:"build,omitempty"` Build *BuildConfig `yaml:"build,omitempty" json:"build,omitempty"`
Develop *DevelopConfig `yaml:"develop,omitempty" json:"develop,omitempty"`
BlkioConfig *BlkioConfig `yaml:"blkio_config,omitempty" json:"blkio_config,omitempty"` BlkioConfig *BlkioConfig `yaml:"blkio_config,omitempty" json:"blkio_config,omitempty"`
CapAdd []string `yaml:"cap_add,omitempty" json:"cap_add,omitempty"` CapAdd []string `yaml:"cap_add,omitempty" json:"cap_add,omitempty"`
CapDrop []string `yaml:"cap_drop,omitempty" json:"cap_drop,omitempty"` CapDrop []string `yaml:"cap_drop,omitempty" json:"cap_drop,omitempty"`

2
vendor/modules.txt vendored
View File

@ -121,7 +121,7 @@ github.com/cenkalti/backoff/v4
# github.com/cespare/xxhash/v2 v2.2.0 # github.com/cespare/xxhash/v2 v2.2.0
## explicit; go 1.11 ## explicit; go 1.11
github.com/cespare/xxhash/v2 github.com/cespare/xxhash/v2
# github.com/compose-spec/compose-go v1.18.4 # github.com/compose-spec/compose-go v1.19.0
## explicit; go 1.19 ## explicit; go 1.19
github.com/compose-spec/compose-go/cli github.com/compose-spec/compose-go/cli
github.com/compose-spec/compose-go/consts github.com/compose-spec/compose-go/consts