mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
update github.com/compose-spec/compose-go to v1.2.7
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
9
vendor/github.com/compose-spec/compose-go/dotenv/parser.go
generated
vendored
9
vendor/github.com/compose-spec/compose-go/dotenv/parser.go
generated
vendored
@ -18,6 +18,9 @@ const (
|
||||
|
||||
func parseBytes(src []byte, out map[string]string, lookupFn LookupFn) error {
|
||||
cutset := src
|
||||
if lookupFn == nil {
|
||||
lookupFn = noLookupFn
|
||||
}
|
||||
for {
|
||||
cutset = getStatementStart(cutset)
|
||||
if cutset == nil {
|
||||
@ -34,9 +37,6 @@ func parseBytes(src []byte, out map[string]string, lookupFn LookupFn) error {
|
||||
}
|
||||
|
||||
if inherited {
|
||||
if lookupFn == nil {
|
||||
lookupFn = noLookupFn
|
||||
}
|
||||
|
||||
value, ok := lookupFn(key)
|
||||
if ok {
|
||||
@ -50,6 +50,9 @@ func parseBytes(src []byte, out map[string]string, lookupFn LookupFn) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if lookUpValue, ok := lookupFn(key); ok {
|
||||
value = lookUpValue
|
||||
}
|
||||
|
||||
out[key] = value
|
||||
cutset = left
|
||||
|
5
vendor/github.com/compose-spec/compose-go/loader/full-example.yml
generated
vendored
5
vendor/github.com/compose-spec/compose-go/loader/full-example.yml
generated
vendored
@ -22,6 +22,9 @@ services:
|
||||
uid: '103'
|
||||
gid: '103'
|
||||
mode: 0440
|
||||
tags:
|
||||
- foo:v1.0.0
|
||||
- docker.io/username/foo:my-other-tag
|
||||
|
||||
|
||||
cap_add:
|
||||
@ -402,6 +405,7 @@ configs:
|
||||
external: true
|
||||
config4:
|
||||
name: foo
|
||||
file: ~/config_data
|
||||
x-bar: baz
|
||||
x-foo: bar
|
||||
|
||||
@ -417,6 +421,7 @@ secrets:
|
||||
external: true
|
||||
secret4:
|
||||
name: bar
|
||||
environment: BAR
|
||||
x-bar: baz
|
||||
x-foo: bar
|
||||
x-bar: baz
|
||||
|
47
vendor/github.com/compose-spec/compose-go/loader/loader.go
generated
vendored
47
vendor/github.com/compose-spec/compose-go/loader/loader.go
generated
vendored
@ -24,7 +24,6 @@ import (
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@ -70,7 +69,7 @@ type Options struct {
|
||||
}
|
||||
|
||||
func (o *Options) SetProjectName(name string, imperativelySet bool) {
|
||||
o.projectName = normalizeProjectName(name)
|
||||
o.projectName = NormalizeProjectName(name)
|
||||
o.projectNameImperativelySet = imperativelySet
|
||||
}
|
||||
|
||||
@ -209,7 +208,7 @@ func Load(configDetails types.ConfigDetails, options ...func(*Options)) (*types.
|
||||
}
|
||||
|
||||
projectName, projectNameImperativelySet := opts.GetProjectName()
|
||||
model.Name = normalizeProjectName(model.Name)
|
||||
model.Name = NormalizeProjectName(model.Name)
|
||||
if !projectNameImperativelySet && model.Name != "" {
|
||||
projectName = model.Name
|
||||
}
|
||||
@ -246,7 +245,7 @@ func Load(configDetails types.ConfigDetails, options ...func(*Options)) (*types.
|
||||
return project, nil
|
||||
}
|
||||
|
||||
func normalizeProjectName(s string) string {
|
||||
func NormalizeProjectName(s string) string {
|
||||
r := regexp.MustCompile("[a-z0-9_-]")
|
||||
s = strings.ToLower(s)
|
||||
s = strings.Join(r.FindAllString(s, -1), "")
|
||||
@ -385,7 +384,7 @@ func createTransformHook(additionalTransformers ...Transformer) mapstructure.Dec
|
||||
reflect.TypeOf(types.MappingWithEquals{}): transformMappingOrListFunc("=", true),
|
||||
reflect.TypeOf(types.Labels{}): transformMappingOrListFunc("=", false),
|
||||
reflect.TypeOf(types.MappingWithColon{}): transformMappingOrListFunc(":", false),
|
||||
reflect.TypeOf(types.HostsList{}): transformListOrMappingFunc(":", false),
|
||||
reflect.TypeOf(types.HostsList{}): transformMappingOrListFunc(":", false),
|
||||
reflect.TypeOf(types.ServiceVolumeConfig{}): transformServiceVolumeConfig,
|
||||
reflect.TypeOf(types.BuildConfig{}): transformBuildConfig,
|
||||
reflect.TypeOf(types.Duration(0)): transformStringToDuration,
|
||||
@ -571,18 +570,18 @@ func LoadService(name string, serviceDict map[string]interface{}, workingDir str
|
||||
if volume.Type != types.VolumeTypeBind {
|
||||
continue
|
||||
}
|
||||
|
||||
if volume.Source == "" {
|
||||
return nil, errors.New(`invalid mount config for type "bind": field Source must not be empty`)
|
||||
}
|
||||
|
||||
if resolvePaths {
|
||||
serviceConfig.Volumes[i] = resolveVolumePath(volume, workingDir, lookupEnv)
|
||||
if resolvePaths || convertPaths {
|
||||
volume = resolveVolumePath(volume, workingDir, lookupEnv)
|
||||
}
|
||||
|
||||
if convertPaths {
|
||||
serviceConfig.Volumes[i] = convertVolumePath(volume)
|
||||
volume = convertVolumePath(volume)
|
||||
}
|
||||
serviceConfig.Volumes[i] = volume
|
||||
}
|
||||
|
||||
return serviceConfig, nil
|
||||
@ -805,7 +804,7 @@ func loadFileObjectConfig(name string, objType string, obj types.FileObjectConfi
|
||||
return obj, errors.Errorf("%[1]s %[2]s: %[1]s.driver and %[1]s.file conflict; only use %[1]s.driver", objType, name)
|
||||
}
|
||||
default:
|
||||
if resolvePaths {
|
||||
if obj.File != "" && resolvePaths {
|
||||
obj.File = absPath(details.WorkingDir, obj.File)
|
||||
}
|
||||
}
|
||||
@ -1060,22 +1059,6 @@ func transformMappingOrListFunc(sep string, allowNil bool) TransformerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func transformListOrMappingFunc(sep string, allowNil bool) TransformerFunc {
|
||||
return func(data interface{}) (interface{}, error) {
|
||||
return transformListOrMapping(data, sep, allowNil)
|
||||
}
|
||||
}
|
||||
|
||||
func transformListOrMapping(listOrMapping interface{}, sep string, allowNil bool) (interface{}, error) {
|
||||
switch value := listOrMapping.(type) {
|
||||
case map[string]interface{}:
|
||||
return toStringList(value, sep, allowNil), nil
|
||||
case []interface{}:
|
||||
return listOrMapping, nil
|
||||
}
|
||||
return nil, errors.Errorf("expected a map or a list, got %T: %#v", listOrMapping, listOrMapping)
|
||||
}
|
||||
|
||||
func transformMappingOrList(mappingOrList interface{}, sep string, allowNil bool) (interface{}, error) {
|
||||
switch value := mappingOrList.(type) {
|
||||
case map[string]interface{}:
|
||||
@ -1168,15 +1151,3 @@ func toString(value interface{}, allowNil bool) interface{} {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
func toStringList(value map[string]interface{}, separator string, allowNil bool) []string {
|
||||
var output []string
|
||||
for key, value := range value {
|
||||
if value == nil && !allowNil {
|
||||
continue
|
||||
}
|
||||
output = append(output, fmt.Sprintf("%s%s%s", key, separator, value))
|
||||
}
|
||||
sort.Strings(output)
|
||||
return output
|
||||
}
|
||||
|
10
vendor/github.com/compose-spec/compose-go/loader/validate.go
generated
vendored
10
vendor/github.com/compose-spec/compose-go/loader/validate.go
generated
vendored
@ -68,5 +68,15 @@ func checkConsistency(project *types.Project) error {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for name, secret := range project.Secrets {
|
||||
if secret.External.External {
|
||||
continue
|
||||
}
|
||||
if secret.File == "" && secret.Environment == "" {
|
||||
return errors.Wrap(errdefs.ErrInvalid, fmt.Sprintf("secret %q must declare either `file` or `environment`", name))
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
4
vendor/github.com/compose-spec/compose-go/schema/compose-spec.json
generated
vendored
4
vendor/github.com/compose-spec/compose-go/schema/compose-spec.json
generated
vendored
@ -102,7 +102,8 @@
|
||||
"shm_size": {"type": ["integer", "string"]},
|
||||
"extra_hosts": {"$ref": "#/definitions/list_or_dict"},
|
||||
"isolation": {"type": "string"},
|
||||
"secrets": {"$ref": "#/definitions/service_config_or_secret"}
|
||||
"secrets": {"$ref": "#/definitions/service_config_or_secret"},
|
||||
"tags": {"type": "array", "items": {"type": "string"}}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"patternProperties": {"^x-": {}}
|
||||
@ -684,6 +685,7 @@
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {"type": "string"},
|
||||
"environment": {"type": "string"},
|
||||
"file": {"type": "string"},
|
||||
"external": {
|
||||
"type": ["boolean", "object"],
|
||||
|
23
vendor/github.com/compose-spec/compose-go/types/config.go
generated
vendored
23
vendor/github.com/compose-spec/compose-go/types/config.go
generated
vendored
@ -18,10 +18,17 @@ package types
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/mitchellh/mapstructure"
|
||||
)
|
||||
|
||||
var (
|
||||
// isCaseInsensitiveEnvVars is true on platforms where environment variable names are treated case-insensitively.
|
||||
isCaseInsensitiveEnvVars = (runtime.GOOS == "windows")
|
||||
)
|
||||
|
||||
// ConfigDetails are the details about a group of ConfigFiles
|
||||
type ConfigDetails struct {
|
||||
Version string
|
||||
@ -33,7 +40,21 @@ type ConfigDetails struct {
|
||||
// LookupEnv provides a lookup function for environment variables
|
||||
func (cd ConfigDetails) LookupEnv(key string) (string, bool) {
|
||||
v, ok := cd.Environment[key]
|
||||
return v, ok
|
||||
if !isCaseInsensitiveEnvVars || ok {
|
||||
return v, ok
|
||||
}
|
||||
// variable names must be treated case-insensitively on some platforms (that is, Windows).
|
||||
// Resolves in this way:
|
||||
// * Return the value if its name matches with the passed name case-sensitively.
|
||||
// * Otherwise, return the value if its lower-cased name matches lower-cased passed name.
|
||||
// * The value is indefinite if multiple variables match.
|
||||
lowerKey := strings.ToLower(key)
|
||||
for k, v := range cd.Environment {
|
||||
if strings.ToLower(k) == lowerKey {
|
||||
return v, true
|
||||
}
|
||||
}
|
||||
return "", false
|
||||
}
|
||||
|
||||
// ConfigFile is a filename and the contents of the file as a Dict
|
||||
|
13
vendor/github.com/compose-spec/compose-go/types/types.go
generated
vendored
13
vendor/github.com/compose-spec/compose-go/types/types.go
generated
vendored
@ -305,6 +305,7 @@ type BuildConfig struct {
|
||||
Network string `yaml:",omitempty" json:"network,omitempty"`
|
||||
Target string `yaml:",omitempty" json:"target,omitempty"`
|
||||
Secrets []ServiceSecretConfig `yaml:",omitempty" json:"secrets,omitempty"`
|
||||
Tags StringList `mapstructure:"tags" yaml:"tags,omitempty" json:"tags,omitempty"`
|
||||
|
||||
Extensions map[string]interface{} `yaml:",inline" json:"-"`
|
||||
}
|
||||
@ -468,7 +469,16 @@ func (s SSHKey) MarshalJSON() ([]byte, error) {
|
||||
type MappingWithColon map[string]string
|
||||
|
||||
// HostsList is a list of colon-separated host-ip mappings
|
||||
type HostsList []string
|
||||
type HostsList map[string]string
|
||||
|
||||
// AsList return host-ip mappings as a list of colon-separated strings
|
||||
func (h HostsList) AsList() []string {
|
||||
l := make([]string, 0, len(h))
|
||||
for k, v := range h {
|
||||
l = append(l, fmt.Sprintf("%s:%s", k, v))
|
||||
}
|
||||
return l
|
||||
}
|
||||
|
||||
// LoggingConfig the logging configuration for a service
|
||||
type LoggingConfig struct {
|
||||
@ -881,6 +891,7 @@ type CredentialSpecConfig struct {
|
||||
type FileObjectConfig struct {
|
||||
Name string `yaml:",omitempty" json:"name,omitempty"`
|
||||
File string `yaml:",omitempty" json:"file,omitempty"`
|
||||
Environment string `yaml:",omitempty" json:"environment,omitempty"`
|
||||
External External `yaml:",omitempty" json:"external,omitempty"`
|
||||
Labels Labels `yaml:",omitempty" json:"labels,omitempty"`
|
||||
Driver string `yaml:",omitempty" json:"driver,omitempty"`
|
||||
|
Reference in New Issue
Block a user