Merge pull request #2829 from glours/bump-compose-go-v2.4.5

bump compose-go to v2.4.5
This commit is contained in:
CrazyMax 2024-11-28 18:05:11 +01:00 committed by GitHub
commit f148976e6e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 88 additions and 47 deletions

2
go.mod
View File

@ -6,7 +6,7 @@ require (
github.com/Masterminds/semver/v3 v3.2.1 github.com/Masterminds/semver/v3 v3.2.1
github.com/Microsoft/go-winio v0.6.2 github.com/Microsoft/go-winio v0.6.2
github.com/aws/aws-sdk-go-v2/config v1.26.6 github.com/aws/aws-sdk-go-v2/config v1.26.6
github.com/compose-spec/compose-go/v2 v2.4.4 github.com/compose-spec/compose-go/v2 v2.4.5
github.com/containerd/console v1.0.4 github.com/containerd/console v1.0.4
github.com/containerd/containerd v1.7.24 github.com/containerd/containerd v1.7.24
github.com/containerd/continuity v0.4.5 github.com/containerd/continuity v0.4.5

4
go.sum
View File

@ -83,8 +83,8 @@ github.com/cncf/xds/go v0.0.0-20240423153145-555b57ec207b h1:ga8SEFjZ60pxLcmhnTh
github.com/cncf/xds/go v0.0.0-20240423153145-555b57ec207b/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8= github.com/cncf/xds/go v0.0.0-20240423153145-555b57ec207b/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8=
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/codahale/rfc6979 v0.0.0-20141003034818-6a90f24967eb/go.mod h1:ZjrT6AXHbDs86ZSdt/osfBi5qfexBrKUdONk989Wnk4= github.com/codahale/rfc6979 v0.0.0-20141003034818-6a90f24967eb/go.mod h1:ZjrT6AXHbDs86ZSdt/osfBi5qfexBrKUdONk989Wnk4=
github.com/compose-spec/compose-go/v2 v2.4.4 h1:cvHBl5Jf1iNBmRrZCICmHvaoskYc1etTPEMLKVwokAY= github.com/compose-spec/compose-go/v2 v2.4.5 h1:p4ih4Jb6VgGPLPxh3fSFVKAjFHtZd+7HVLCSFzcFx9Y=
github.com/compose-spec/compose-go/v2 v2.4.4/go.mod h1:lFN0DrMxIncJGYAXTfWuajfwj5haBJqrBkarHcnjJKc= github.com/compose-spec/compose-go/v2 v2.4.5/go.mod h1:lFN0DrMxIncJGYAXTfWuajfwj5haBJqrBkarHcnjJKc=
github.com/containerd/cgroups v1.1.0 h1:v8rEWFl6EoqHB+swVNjVoCJE8o3jX7e8nqBGPLaDFBM= github.com/containerd/cgroups v1.1.0 h1:v8rEWFl6EoqHB+swVNjVoCJE8o3jX7e8nqBGPLaDFBM=
github.com/containerd/cgroups/v3 v3.0.3 h1:S5ByHZ/h9PMe5IOQoN7E+nMc2UcLEM/V48DGDJ9kip0= github.com/containerd/cgroups/v3 v3.0.3 h1:S5ByHZ/h9PMe5IOQoN7E+nMc2UcLEM/V48DGDJ9kip0=
github.com/containerd/cgroups/v3 v3.0.3/go.mod h1:8HBe7V3aWGLFPd/k03swSIsGjZhHI2WzJmticMgVuz0= github.com/containerd/cgroups/v3 v3.0.3/go.mod h1:8HBe7V3aWGLFPd/k03swSIsGjZhHI2WzJmticMgVuz0=

View File

@ -108,6 +108,9 @@ func extractVariable(value interface{}, pattern *regexp.Regexp) ([]Variable, boo
if r >= 'A' && r <= 'Z' { if r >= 'A' && r <= 'Z' {
return false return false
} }
if r >= '0' && r <= '9' {
return false
}
if r == '_' { if r == '_' {
return false return false
} }

View File

@ -560,39 +560,69 @@ func (p *Project) WithImagesResolved(resolver func(named reference.Named) (godig
}) })
} }
type marshallOptions struct {
secretsContent bool
}
func WithSecretContent(o *marshallOptions) {
o.secretsContent = true
}
func (opt *marshallOptions) apply(p *Project) *Project {
if opt.secretsContent {
p = p.deepCopy()
for name, config := range p.Secrets {
config.marshallContent = true
p.Secrets[name] = config
}
}
return p
}
func applyMarshallOptions(p *Project, options ...func(*marshallOptions)) *Project {
opts := &marshallOptions{}
for _, option := range options {
option(opts)
}
p = opts.apply(p)
return p
}
// MarshalYAML marshal Project into a yaml tree // MarshalYAML marshal Project into a yaml tree
func (p *Project) MarshalYAML() ([]byte, error) { func (p *Project) MarshalYAML(options ...func(*marshallOptions)) ([]byte, error) {
buf := bytes.NewBuffer([]byte{}) buf := bytes.NewBuffer([]byte{})
encoder := yaml.NewEncoder(buf) encoder := yaml.NewEncoder(buf)
encoder.SetIndent(2) encoder.SetIndent(2)
// encoder.CompactSeqIndent() FIXME https://github.com/go-yaml/yaml/pull/753 // encoder.CompactSeqIndent() FIXME https://github.com/go-yaml/yaml/pull/753
err := encoder.Encode(p) src := applyMarshallOptions(p, options...)
err := encoder.Encode(src)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return buf.Bytes(), nil return buf.Bytes(), nil
} }
// MarshalJSON makes Config implement json.Marshaler // MarshalJSON marshal Project into a json document
func (p *Project) MarshalJSON() ([]byte, error) { func (p *Project) MarshalJSON(options ...func(*marshallOptions)) ([]byte, error) {
src := applyMarshallOptions(p, options...)
m := map[string]interface{}{ m := map[string]interface{}{
"name": p.Name, "name": src.Name,
"services": p.Services, "services": src.Services,
} }
if len(p.Networks) > 0 { if len(src.Networks) > 0 {
m["networks"] = p.Networks m["networks"] = src.Networks
} }
if len(p.Volumes) > 0 { if len(src.Volumes) > 0 {
m["volumes"] = p.Volumes m["volumes"] = src.Volumes
} }
if len(p.Secrets) > 0 { if len(src.Secrets) > 0 {
m["secrets"] = p.Secrets m["secrets"] = src.Secrets
} }
if len(p.Configs) > 0 { if len(src.Configs) > 0 {
m["configs"] = p.Configs m["configs"] = src.Configs
} }
for k, v := range p.Extensions { for k, v := range src.Extensions {
m[k] = v m[k] = v
} }
return json.MarshalIndent(m, "", " ") return json.MarshalIndent(m, "", " ")

View File

@ -686,6 +686,7 @@ type NetworkConfig struct {
Internal bool `yaml:"internal,omitempty" json:"internal,omitempty"` Internal bool `yaml:"internal,omitempty" json:"internal,omitempty"`
Attachable bool `yaml:"attachable,omitempty" json:"attachable,omitempty"` Attachable bool `yaml:"attachable,omitempty" json:"attachable,omitempty"`
Labels Labels `yaml:"labels,omitempty" json:"labels,omitempty"` Labels Labels `yaml:"labels,omitempty" json:"labels,omitempty"`
CustomLabels Labels `yaml:"-" json:"-"`
EnableIPv6 *bool `yaml:"enable_ipv6,omitempty" json:"enable_ipv6,omitempty"` EnableIPv6 *bool `yaml:"enable_ipv6,omitempty" json:"enable_ipv6,omitempty"`
Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"` Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
} }
@ -713,6 +714,7 @@ type VolumeConfig struct {
DriverOpts Options `yaml:"driver_opts,omitempty" json:"driver_opts,omitempty"` DriverOpts Options `yaml:"driver_opts,omitempty" json:"driver_opts,omitempty"`
External External `yaml:"external,omitempty" json:"external,omitempty"` External External `yaml:"external,omitempty" json:"external,omitempty"`
Labels Labels `yaml:"labels,omitempty" json:"labels,omitempty"` Labels Labels `yaml:"labels,omitempty" json:"labels,omitempty"`
CustomLabels Labels `yaml:"-" json:"-"`
Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"` Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
} }
@ -734,6 +736,8 @@ type FileObjectConfig struct {
File string `yaml:"file,omitempty" json:"file,omitempty"` File string `yaml:"file,omitempty" json:"file,omitempty"`
Environment string `yaml:"environment,omitempty" json:"environment,omitempty"` Environment string `yaml:"environment,omitempty" json:"environment,omitempty"`
Content string `yaml:"content,omitempty" json:"content,omitempty"` Content string `yaml:"content,omitempty" json:"content,omitempty"`
// configure marshalling to include Content - excluded by default to prevent sensitive data leaks
marshallContent bool
External External `yaml:"external,omitempty" json:"external,omitempty"` External External `yaml:"external,omitempty" json:"external,omitempty"`
Labels Labels `yaml:"labels,omitempty" json:"labels,omitempty"` Labels Labels `yaml:"labels,omitempty" json:"labels,omitempty"`
Driver string `yaml:"driver,omitempty" json:"driver,omitempty"` Driver string `yaml:"driver,omitempty" json:"driver,omitempty"`
@ -773,14 +777,18 @@ type SecretConfig FileObjectConfig
// MarshalYAML makes SecretConfig implement yaml.Marshaller // MarshalYAML makes SecretConfig implement yaml.Marshaller
func (s SecretConfig) MarshalYAML() (interface{}, error) { func (s SecretConfig) MarshalYAML() (interface{}, error) {
// secret content is set while loading model. Never marshall it // secret content is set while loading model. Never marshall it
if !s.marshallContent {
s.Content = "" s.Content = ""
}
return FileObjectConfig(s), nil return FileObjectConfig(s), nil
} }
// MarshalJSON makes SecretConfig implement json.Marshaller // MarshalJSON makes SecretConfig implement json.Marshaller
func (s SecretConfig) MarshalJSON() ([]byte, error) { func (s SecretConfig) MarshalJSON() ([]byte, error) {
// secret content is set while loading model. Never marshall it // secret content is set while loading model. Never marshall it
if !s.marshallContent {
s.Content = "" s.Content = ""
}
return json.Marshal(FileObjectConfig(s)) return json.Marshal(FileObjectConfig(s))
} }

2
vendor/modules.txt vendored
View File

@ -128,7 +128,7 @@ github.com/cenkalti/backoff/v4
# github.com/cespare/xxhash/v2 v2.3.0 # github.com/cespare/xxhash/v2 v2.3.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/v2 v2.4.4 # github.com/compose-spec/compose-go/v2 v2.4.5
## explicit; go 1.21 ## explicit; go 1.21
github.com/compose-spec/compose-go/v2/cli github.com/compose-spec/compose-go/v2/cli
github.com/compose-spec/compose-go/v2/consts github.com/compose-spec/compose-go/v2/consts