mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-18 17:27:49 +08:00
bump compose-go v2.4.6
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
3e3242cfdd
commit
828c1dbf98
2
go.mod
2
go.mod
@ -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.5
|
github.com/compose-spec/compose-go/v2 v2.4.6
|
||||||
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
4
go.sum
@ -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.5 h1:p4ih4Jb6VgGPLPxh3fSFVKAjFHtZd+7HVLCSFzcFx9Y=
|
github.com/compose-spec/compose-go/v2 v2.4.6 h1:QiqXQ2L/f0OCbAl41bPpeiGAWVRIQ+GEDrYxO+dRPhQ=
|
||||||
github.com/compose-spec/compose-go/v2 v2.4.5/go.mod h1:lFN0DrMxIncJGYAXTfWuajfwj5haBJqrBkarHcnjJKc=
|
github.com/compose-spec/compose-go/v2 v2.4.6/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=
|
||||||
|
10
vendor/github.com/compose-spec/compose-go/v2/loader/example1.label
generated
vendored
Normal file
10
vendor/github.com/compose-spec/compose-go/v2/loader/example1.label
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# passed through
|
||||||
|
FOO=foo_from_label_file
|
||||||
|
LABEL.WITH.DOT=ok
|
||||||
|
LABEL_WITH_UNDERSCORE=ok
|
||||||
|
|
||||||
|
# overridden in example2.label
|
||||||
|
BAR=bar_from_label_file
|
||||||
|
|
||||||
|
# overridden in full-example.yml
|
||||||
|
BAZ=baz_from_label_file
|
4
vendor/github.com/compose-spec/compose-go/v2/loader/example2.label
generated
vendored
Normal file
4
vendor/github.com/compose-spec/compose-go/v2/loader/example2.label
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
BAR=bar_from_label_file_2
|
||||||
|
|
||||||
|
# overridden in configDetails.Labels
|
||||||
|
QUX=quz_from_label_file_2
|
8
vendor/github.com/compose-spec/compose-go/v2/loader/extends.go
generated
vendored
8
vendor/github.com/compose-spec/compose-go/v2/loader/extends.go
generated
vendored
@ -27,6 +27,10 @@ import (
|
|||||||
"github.com/compose-spec/compose-go/v2/types"
|
"github.com/compose-spec/compose-go/v2/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// as we use another service definition by `extends`, we must exclude attributes which creates dependency to another service
|
||||||
|
// see https://github.com/compose-spec/compose-spec/blob/main/05-services.md#restrictions
|
||||||
|
var exclusions = []string{"extends", "depends_on", "volumes_from"}
|
||||||
|
|
||||||
func ApplyExtends(ctx context.Context, dict map[string]any, opts *Options, tracker *cycleTracker, post ...PostProcessor) error {
|
func ApplyExtends(ctx context.Context, dict map[string]any, opts *Options, tracker *cycleTracker, post ...PostProcessor) error {
|
||||||
a, ok := dict["services"]
|
a, ok := dict["services"]
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -123,7 +127,9 @@ func applyServiceExtends(ctx context.Context, name string, services map[string]a
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
delete(merged, "extends")
|
for _, exclusion := range exclusions {
|
||||||
|
delete(merged, exclusion)
|
||||||
|
}
|
||||||
services[name] = merged
|
services[name] = merged
|
||||||
return merged, nil
|
return merged, nil
|
||||||
}
|
}
|
||||||
|
4
vendor/github.com/compose-spec/compose-go/v2/loader/full-example.yml
generated
vendored
4
vendor/github.com/compose-spec/compose-go/v2/loader/full-example.yml
generated
vendored
@ -210,6 +210,10 @@ services:
|
|||||||
# - "com.example.number=42"
|
# - "com.example.number=42"
|
||||||
# - "com.example.empty-label"
|
# - "com.example.empty-label"
|
||||||
|
|
||||||
|
label_file:
|
||||||
|
- ./example1.label
|
||||||
|
- ./example2.label
|
||||||
|
|
||||||
links:
|
links:
|
||||||
- db
|
- db
|
||||||
- db:database
|
- db:database
|
||||||
|
6
vendor/github.com/compose-spec/compose-go/v2/loader/loader.go
generated
vendored
6
vendor/github.com/compose-spec/compose-go/v2/loader/loader.go
generated
vendored
@ -637,6 +637,12 @@ func modelToProject(dict map[string]interface{}, opts *Options, configDetails ty
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
project, err = project.WithServicesLabelsResolved(opts.discardEnvFiles)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return project, nil
|
return project, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
vendor/github.com/compose-spec/compose-go/v2/loader/validate.go
generated
vendored
2
vendor/github.com/compose-spec/compose-go/v2/loader/validate.go
generated
vendored
@ -155,7 +155,7 @@ func checkConsistency(project *types.Project) error {
|
|||||||
|
|
||||||
if s.Develop != nil && s.Develop.Watch != nil {
|
if s.Develop != nil && s.Develop.Watch != nil {
|
||||||
for _, watch := range s.Develop.Watch {
|
for _, watch := range s.Develop.Watch {
|
||||||
if watch.Action != types.WatchActionRebuild && watch.Target == "" {
|
if watch.Target == "" && watch.Action != types.WatchActionRebuild && watch.Action != types.WatchActionRestart {
|
||||||
return fmt.Errorf("services.%s.develop.watch: target is required for non-rebuild actions: %w", s.Name, errdefs.ErrInvalid)
|
return fmt.Errorf("services.%s.develop.watch: target is required for non-rebuild actions: %w", s.Name, errdefs.ErrInvalid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1
vendor/github.com/compose-spec/compose-go/v2/override/merge.go
generated
vendored
1
vendor/github.com/compose-spec/compose-go/v2/override/merge.go
generated
vendored
@ -57,6 +57,7 @@ func init() {
|
|||||||
mergeSpecials["services.*.dns_search"] = mergeToSequence
|
mergeSpecials["services.*.dns_search"] = mergeToSequence
|
||||||
mergeSpecials["services.*.entrypoint"] = override
|
mergeSpecials["services.*.entrypoint"] = override
|
||||||
mergeSpecials["services.*.env_file"] = mergeToSequence
|
mergeSpecials["services.*.env_file"] = mergeToSequence
|
||||||
|
mergeSpecials["services.*.label_file"] = mergeToSequence
|
||||||
mergeSpecials["services.*.environment"] = mergeToSequence
|
mergeSpecials["services.*.environment"] = mergeToSequence
|
||||||
mergeSpecials["services.*.extra_hosts"] = mergeExtraHosts
|
mergeSpecials["services.*.extra_hosts"] = mergeExtraHosts
|
||||||
mergeSpecials["services.*.healthcheck.test"] = override
|
mergeSpecials["services.*.healthcheck.test"] = override
|
||||||
|
1
vendor/github.com/compose-spec/compose-go/v2/paths/resolve.go
generated
vendored
1
vendor/github.com/compose-spec/compose-go/v2/paths/resolve.go
generated
vendored
@ -37,6 +37,7 @@ func ResolveRelativePaths(project map[string]any, base string, remotes []RemoteR
|
|||||||
"services.*.build.context": r.absContextPath,
|
"services.*.build.context": r.absContextPath,
|
||||||
"services.*.build.additional_contexts.*": r.absContextPath,
|
"services.*.build.additional_contexts.*": r.absContextPath,
|
||||||
"services.*.env_file.*.path": r.absPath,
|
"services.*.env_file.*.path": r.absPath,
|
||||||
|
"services.*.label_file.*": r.absPath,
|
||||||
"services.*.extends.file": r.absExtendsPath,
|
"services.*.extends.file": r.absExtendsPath,
|
||||||
"services.*.develop.watch.*.path": r.absSymbolicLink,
|
"services.*.develop.watch.*.path": r.absSymbolicLink,
|
||||||
"services.*.volumes.*": r.absVolumeMount,
|
"services.*.volumes.*": r.absVolumeMount,
|
||||||
|
32
vendor/github.com/compose-spec/compose-go/v2/schema/compose-spec.json
generated
vendored
32
vendor/github.com/compose-spec/compose-go/v2/schema/compose-spec.json
generated
vendored
@ -240,6 +240,7 @@
|
|||||||
"domainname": {"type": "string"},
|
"domainname": {"type": "string"},
|
||||||
"entrypoint": {"$ref": "#/definitions/command"},
|
"entrypoint": {"$ref": "#/definitions/command"},
|
||||||
"env_file": {"$ref": "#/definitions/env_file"},
|
"env_file": {"$ref": "#/definitions/env_file"},
|
||||||
|
"label_file": {"$ref": "#/definitions/label_file"},
|
||||||
"environment": {"$ref": "#/definitions/list_or_dict"},
|
"environment": {"$ref": "#/definitions/list_or_dict"},
|
||||||
|
|
||||||
"expose": {
|
"expose": {
|
||||||
@ -499,8 +500,9 @@
|
|||||||
"properties": {
|
"properties": {
|
||||||
"ignore": {"type": "array", "items": {"type": "string"}},
|
"ignore": {"type": "array", "items": {"type": "string"}},
|
||||||
"path": {"type": "string"},
|
"path": {"type": "string"},
|
||||||
"action": {"type": "string", "enum": ["rebuild", "sync", "sync+restart"]},
|
"action": {"type": "string", "enum": ["rebuild", "sync", "restart", "sync+restart", "sync+exec"]},
|
||||||
"target": {"type": "string"}
|
"target": {"type": "string"},
|
||||||
|
"exec": {"$ref": "#/definitions/service_hook"}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"patternProperties": {"^x-": {}}
|
"patternProperties": {"^x-": {}}
|
||||||
@ -884,6 +886,16 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"label_file": {
|
||||||
|
"oneOf": [
|
||||||
|
{"type": "string"},
|
||||||
|
{
|
||||||
|
"type": "array",
|
||||||
|
"items": {"type": "string"}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
"string_or_list": {
|
"string_or_list": {
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
{"type": "string"},
|
{"type": "string"},
|
||||||
@ -918,9 +930,19 @@
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"patternProperties": {
|
"patternProperties": {
|
||||||
".+": {
|
".+": {
|
||||||
"type": ["string", "array"]
|
"oneOf": [
|
||||||
},
|
{
|
||||||
"uniqueItems": false
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"uniqueItems": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
},
|
},
|
||||||
|
37
vendor/github.com/compose-spec/compose-go/v2/types/derived.gen.go
generated
vendored
37
vendor/github.com/compose-spec/compose-go/v2/types/derived.gen.go
generated
vendored
@ -485,6 +485,24 @@ func deriveDeepCopyService(dst, src *ServiceConfig) {
|
|||||||
} else {
|
} else {
|
||||||
dst.Labels = nil
|
dst.Labels = nil
|
||||||
}
|
}
|
||||||
|
if src.LabelFiles == nil {
|
||||||
|
dst.LabelFiles = nil
|
||||||
|
} else {
|
||||||
|
if dst.LabelFiles != nil {
|
||||||
|
if len(src.LabelFiles) > len(dst.LabelFiles) {
|
||||||
|
if cap(dst.LabelFiles) >= len(src.LabelFiles) {
|
||||||
|
dst.LabelFiles = (dst.LabelFiles)[:len(src.LabelFiles)]
|
||||||
|
} else {
|
||||||
|
dst.LabelFiles = make([]string, len(src.LabelFiles))
|
||||||
|
}
|
||||||
|
} else if len(src.LabelFiles) < len(dst.LabelFiles) {
|
||||||
|
dst.LabelFiles = (dst.LabelFiles)[:len(src.LabelFiles)]
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dst.LabelFiles = make([]string, len(src.LabelFiles))
|
||||||
|
}
|
||||||
|
copy(dst.LabelFiles, src.LabelFiles)
|
||||||
|
}
|
||||||
if src.CustomLabels != nil {
|
if src.CustomLabels != nil {
|
||||||
dst.CustomLabels = make(map[string]string, len(src.CustomLabels))
|
dst.CustomLabels = make(map[string]string, len(src.CustomLabels))
|
||||||
deriveDeepCopy_4(dst.CustomLabels, src.CustomLabels)
|
deriveDeepCopy_4(dst.CustomLabels, src.CustomLabels)
|
||||||
@ -1428,6 +1446,12 @@ func deriveDeepCopy_24(dst, src *NetworkConfig) {
|
|||||||
} else {
|
} else {
|
||||||
dst.Labels = nil
|
dst.Labels = nil
|
||||||
}
|
}
|
||||||
|
if src.CustomLabels != nil {
|
||||||
|
dst.CustomLabels = make(map[string]string, len(src.CustomLabels))
|
||||||
|
deriveDeepCopy_4(dst.CustomLabels, src.CustomLabels)
|
||||||
|
} else {
|
||||||
|
dst.CustomLabels = nil
|
||||||
|
}
|
||||||
if src.EnableIPv6 == nil {
|
if src.EnableIPv6 == nil {
|
||||||
dst.EnableIPv6 = nil
|
dst.EnableIPv6 = nil
|
||||||
} else {
|
} else {
|
||||||
@ -1459,6 +1483,12 @@ func deriveDeepCopy_25(dst, src *VolumeConfig) {
|
|||||||
} else {
|
} else {
|
||||||
dst.Labels = nil
|
dst.Labels = nil
|
||||||
}
|
}
|
||||||
|
if src.CustomLabels != nil {
|
||||||
|
dst.CustomLabels = make(map[string]string, len(src.CustomLabels))
|
||||||
|
deriveDeepCopy_4(dst.CustomLabels, src.CustomLabels)
|
||||||
|
} else {
|
||||||
|
dst.CustomLabels = nil
|
||||||
|
}
|
||||||
if src.Extensions != nil {
|
if src.Extensions != nil {
|
||||||
dst.Extensions = make(map[string]any, len(src.Extensions))
|
dst.Extensions = make(map[string]any, len(src.Extensions))
|
||||||
src.Extensions.DeepCopy(dst.Extensions)
|
src.Extensions.DeepCopy(dst.Extensions)
|
||||||
@ -1473,6 +1503,7 @@ func deriveDeepCopy_26(dst, src *SecretConfig) {
|
|||||||
dst.File = src.File
|
dst.File = src.File
|
||||||
dst.Environment = src.Environment
|
dst.Environment = src.Environment
|
||||||
dst.Content = src.Content
|
dst.Content = src.Content
|
||||||
|
dst.marshallContent = src.marshallContent
|
||||||
dst.External = src.External
|
dst.External = src.External
|
||||||
if src.Labels != nil {
|
if src.Labels != nil {
|
||||||
dst.Labels = make(map[string]string, len(src.Labels))
|
dst.Labels = make(map[string]string, len(src.Labels))
|
||||||
@ -1502,6 +1533,7 @@ func deriveDeepCopy_27(dst, src *ConfigObjConfig) {
|
|||||||
dst.File = src.File
|
dst.File = src.File
|
||||||
dst.Environment = src.Environment
|
dst.Environment = src.Environment
|
||||||
dst.Content = src.Content
|
dst.Content = src.Content
|
||||||
|
dst.marshallContent = src.marshallContent
|
||||||
dst.External = src.External
|
dst.External = src.External
|
||||||
if src.Labels != nil {
|
if src.Labels != nil {
|
||||||
dst.Labels = make(map[string]string, len(src.Labels))
|
dst.Labels = make(map[string]string, len(src.Labels))
|
||||||
@ -1981,6 +2013,11 @@ func deriveDeepCopy_46(dst, src *Trigger) {
|
|||||||
dst.Path = src.Path
|
dst.Path = src.Path
|
||||||
dst.Action = src.Action
|
dst.Action = src.Action
|
||||||
dst.Target = src.Target
|
dst.Target = src.Target
|
||||||
|
func() {
|
||||||
|
field := new(ServiceHook)
|
||||||
|
deriveDeepCopy_44(field, &src.Exec)
|
||||||
|
dst.Exec = *field
|
||||||
|
}()
|
||||||
if src.Ignore == nil {
|
if src.Ignore == nil {
|
||||||
dst.Ignore = nil
|
dst.Ignore = nil
|
||||||
} else {
|
} else {
|
||||||
|
3
vendor/github.com/compose-spec/compose-go/v2/types/develop.go
generated
vendored
3
vendor/github.com/compose-spec/compose-go/v2/types/develop.go
generated
vendored
@ -27,13 +27,16 @@ type WatchAction string
|
|||||||
const (
|
const (
|
||||||
WatchActionSync WatchAction = "sync"
|
WatchActionSync WatchAction = "sync"
|
||||||
WatchActionRebuild WatchAction = "rebuild"
|
WatchActionRebuild WatchAction = "rebuild"
|
||||||
|
WatchActionRestart WatchAction = "restart"
|
||||||
WatchActionSyncRestart WatchAction = "sync+restart"
|
WatchActionSyncRestart WatchAction = "sync+restart"
|
||||||
|
WatchActionSyncExec WatchAction = "sync+exec"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Trigger struct {
|
type Trigger struct {
|
||||||
Path string `yaml:"path" json:"path"`
|
Path string `yaml:"path" json:"path"`
|
||||||
Action WatchAction `yaml:"action" json:"action"`
|
Action WatchAction `yaml:"action" json:"action"`
|
||||||
Target string `yaml:"target,omitempty" json:"target,omitempty"`
|
Target string `yaml:"target,omitempty" json:"target,omitempty"`
|
||||||
|
Exec ServiceHook `yaml:"exec,omitempty" json:"exec,omitempty"`
|
||||||
Ignore []string `yaml:"ignore,omitempty" json:"ignore,omitempty"`
|
Ignore []string `yaml:"ignore,omitempty" json:"ignore,omitempty"`
|
||||||
Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
|
Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
|
||||||
}
|
}
|
||||||
|
19
vendor/github.com/compose-spec/compose-go/v2/types/labels.go
generated
vendored
19
vendor/github.com/compose-spec/compose-go/v2/types/labels.go
generated
vendored
@ -24,6 +24,16 @@ import (
|
|||||||
// Labels is a mapping type for labels
|
// Labels is a mapping type for labels
|
||||||
type Labels map[string]string
|
type Labels map[string]string
|
||||||
|
|
||||||
|
func NewLabelsFromMappingWithEquals(mapping MappingWithEquals) Labels {
|
||||||
|
labels := Labels{}
|
||||||
|
for k, v := range mapping {
|
||||||
|
if v != nil {
|
||||||
|
labels[k] = *v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return labels
|
||||||
|
}
|
||||||
|
|
||||||
func (l Labels) Add(key, value string) Labels {
|
func (l Labels) Add(key, value string) Labels {
|
||||||
if l == nil {
|
if l == nil {
|
||||||
l = Labels{}
|
l = Labels{}
|
||||||
@ -42,6 +52,15 @@ func (l Labels) AsList() []string {
|
|||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (l Labels) ToMappingWithEquals() MappingWithEquals {
|
||||||
|
mapping := MappingWithEquals{}
|
||||||
|
for k, v := range l {
|
||||||
|
v := v
|
||||||
|
mapping[k] = &v
|
||||||
|
}
|
||||||
|
return mapping
|
||||||
|
}
|
||||||
|
|
||||||
// label value can be a string | number | boolean | null (empty)
|
// label value can be a string | number | boolean | null (empty)
|
||||||
func labelValue(e interface{}) string {
|
func labelValue(e interface{}) string {
|
||||||
if e == nil {
|
if e == nil {
|
||||||
|
10
vendor/github.com/compose-spec/compose-go/v2/types/mapping.go
generated
vendored
10
vendor/github.com/compose-spec/compose-go/v2/types/mapping.go
generated
vendored
@ -72,6 +72,16 @@ func (m MappingWithEquals) RemoveEmpty() MappingWithEquals {
|
|||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m MappingWithEquals) ToMapping() Mapping {
|
||||||
|
o := Mapping{}
|
||||||
|
for k, v := range m {
|
||||||
|
if v != nil {
|
||||||
|
o[k] = *v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return o
|
||||||
|
}
|
||||||
|
|
||||||
func (m *MappingWithEquals) DecodeMapstructure(value interface{}) error {
|
func (m *MappingWithEquals) DecodeMapstructure(value interface{}) error {
|
||||||
switch v := value.(type) {
|
switch v := value.(type) {
|
||||||
case map[string]interface{}:
|
case map[string]interface{}:
|
||||||
|
57
vendor/github.com/compose-spec/compose-go/v2/types/project.go
generated
vendored
57
vendor/github.com/compose-spec/compose-go/v2/types/project.go
generated
vendored
@ -663,6 +663,44 @@ func (p Project) WithServicesEnvironmentResolved(discardEnvFiles bool) (*Project
|
|||||||
return newProject, nil
|
return newProject, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithServicesLabelsResolved parses label_files set for services to resolve the actual label map for services
|
||||||
|
// It returns a new Project instance with the changes and keep the original Project unchanged
|
||||||
|
func (p Project) WithServicesLabelsResolved(discardLabelFiles bool) (*Project, error) {
|
||||||
|
newProject := p.deepCopy()
|
||||||
|
for i, service := range newProject.Services {
|
||||||
|
labels := MappingWithEquals{}
|
||||||
|
// resolve variables based on other files we already parsed
|
||||||
|
var resolve dotenv.LookupFn = func(s string) (string, bool) {
|
||||||
|
v, ok := labels[s]
|
||||||
|
if ok && v != nil {
|
||||||
|
return *v, ok
|
||||||
|
}
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, labelFile := range service.LabelFiles {
|
||||||
|
vars, err := loadLabelFile(labelFile, resolve)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
labels.OverrideBy(vars.ToMappingWithEquals())
|
||||||
|
}
|
||||||
|
|
||||||
|
labels = labels.OverrideBy(service.Labels.ToMappingWithEquals())
|
||||||
|
if len(labels) == 0 {
|
||||||
|
labels = nil
|
||||||
|
} else {
|
||||||
|
service.Labels = NewLabelsFromMappingWithEquals(labels)
|
||||||
|
}
|
||||||
|
|
||||||
|
if discardLabelFiles {
|
||||||
|
service.LabelFiles = nil
|
||||||
|
}
|
||||||
|
newProject.Services[i] = service
|
||||||
|
}
|
||||||
|
return newProject, nil
|
||||||
|
}
|
||||||
|
|
||||||
func loadEnvFile(envFile EnvFile, resolve dotenv.LookupFn) (Mapping, error) {
|
func loadEnvFile(envFile EnvFile, resolve dotenv.LookupFn) (Mapping, error) {
|
||||||
if _, err := os.Stat(envFile.Path); os.IsNotExist(err) {
|
if _, err := os.Stat(envFile.Path); os.IsNotExist(err) {
|
||||||
if envFile.Required {
|
if envFile.Required {
|
||||||
@ -670,15 +708,28 @@ func loadEnvFile(envFile EnvFile, resolve dotenv.LookupFn) (Mapping, error) {
|
|||||||
}
|
}
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
file, err := os.Open(envFile.Path)
|
|
||||||
|
return loadMappingFile(envFile.Path, envFile.Format, resolve)
|
||||||
|
}
|
||||||
|
|
||||||
|
func loadLabelFile(labelFile string, resolve dotenv.LookupFn) (Mapping, error) {
|
||||||
|
if _, err := os.Stat(labelFile); os.IsNotExist(err) {
|
||||||
|
return nil, fmt.Errorf("label file %s not found: %w", labelFile, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return loadMappingFile(labelFile, "", resolve)
|
||||||
|
}
|
||||||
|
|
||||||
|
func loadMappingFile(path string, format string, resolve dotenv.LookupFn) (Mapping, error) {
|
||||||
|
file, err := os.Open(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer file.Close() //nolint:errcheck
|
defer file.Close() //nolint:errcheck
|
||||||
|
|
||||||
var fileVars map[string]string
|
var fileVars map[string]string
|
||||||
if envFile.Format != "" {
|
if format != "" {
|
||||||
fileVars, err = dotenv.ParseWithFormat(file, envFile.Path, resolve, envFile.Format)
|
fileVars, err = dotenv.ParseWithFormat(file, path, resolve, format)
|
||||||
} else {
|
} else {
|
||||||
fileVars, err = dotenv.ParseWithLookup(file, resolve)
|
fileVars, err = dotenv.ParseWithLookup(file, resolve)
|
||||||
}
|
}
|
||||||
|
1
vendor/github.com/compose-spec/compose-go/v2/types/types.go
generated
vendored
1
vendor/github.com/compose-spec/compose-go/v2/types/types.go
generated
vendored
@ -89,6 +89,7 @@ type ServiceConfig struct {
|
|||||||
Ipc string `yaml:"ipc,omitempty" json:"ipc,omitempty"`
|
Ipc string `yaml:"ipc,omitempty" json:"ipc,omitempty"`
|
||||||
Isolation string `yaml:"isolation,omitempty" json:"isolation,omitempty"`
|
Isolation string `yaml:"isolation,omitempty" json:"isolation,omitempty"`
|
||||||
Labels Labels `yaml:"labels,omitempty" json:"labels,omitempty"`
|
Labels Labels `yaml:"labels,omitempty" json:"labels,omitempty"`
|
||||||
|
LabelFiles []string `yaml:"label_file,omitempty" json:"label_file,omitempty"`
|
||||||
CustomLabels Labels `yaml:"-" json:"-"`
|
CustomLabels Labels `yaml:"-" json:"-"`
|
||||||
Links []string `yaml:"links,omitempty" json:"links,omitempty"`
|
Links []string `yaml:"links,omitempty" json:"links,omitempty"`
|
||||||
Logging *LoggingConfig `yaml:"logging,omitempty" json:"logging,omitempty"`
|
Logging *LoggingConfig `yaml:"logging,omitempty" json:"logging,omitempty"`
|
||||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -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.5
|
# github.com/compose-spec/compose-go/v2 v2.4.6
|
||||||
## 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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user