mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-10 05:27:07 +08:00
update github.com/compose-spec/compose-go to v1.2.4
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
7
vendor/github.com/compose-spec/compose-go/loader/full-example.yml
generated
vendored
7
vendor/github.com/compose-spec/compose-go/loader/full-example.yml
generated
vendored
@ -15,6 +15,13 @@ services:
|
||||
- foo
|
||||
- bar
|
||||
labels: [FOO=BAR]
|
||||
secrets:
|
||||
- secret1
|
||||
- source: secret2
|
||||
target: my_secret
|
||||
uid: '103'
|
||||
gid: '103'
|
||||
mode: 0440
|
||||
|
||||
|
||||
cap_add:
|
||||
|
42
vendor/github.com/compose-spec/compose-go/loader/loader.go
generated
vendored
42
vendor/github.com/compose-spec/compose-go/loader/loader.go
generated
vendored
@ -53,6 +53,8 @@ type Options struct {
|
||||
SkipNormalization bool
|
||||
// Resolve paths
|
||||
ResolvePaths bool
|
||||
// Convert Windows paths
|
||||
ConvertWindowsPaths bool
|
||||
// Skip consistency check
|
||||
SkipConsistencyCheck bool
|
||||
// Skip extends
|
||||
@ -489,7 +491,7 @@ func loadServiceWithExtends(filename, name string, servicesDict map[string]inter
|
||||
return nil, fmt.Errorf("cannot extend service %q in %s: service not found", name, filename)
|
||||
}
|
||||
|
||||
serviceConfig, err := LoadService(name, target.(map[string]interface{}), workingDir, lookupEnv, opts.ResolvePaths)
|
||||
serviceConfig, err := LoadService(name, target.(map[string]interface{}), workingDir, lookupEnv, opts.ResolvePaths, opts.ConvertWindowsPaths)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -552,7 +554,7 @@ func loadServiceWithExtends(filename, name string, servicesDict map[string]inter
|
||||
|
||||
// LoadService produces a single ServiceConfig from a compose file Dict
|
||||
// the serviceDict is not validated if directly used. Use Load() to enable validation
|
||||
func LoadService(name string, serviceDict map[string]interface{}, workingDir string, lookupEnv template.Mapping, resolvePaths bool) (*types.ServiceConfig, error) {
|
||||
func LoadService(name string, serviceDict map[string]interface{}, workingDir string, lookupEnv template.Mapping, resolvePaths bool, convertPaths bool) (*types.ServiceConfig, error) {
|
||||
serviceConfig := &types.ServiceConfig{
|
||||
Scale: 1,
|
||||
}
|
||||
@ -577,11 +579,30 @@ func LoadService(name string, serviceDict map[string]interface{}, workingDir str
|
||||
if resolvePaths {
|
||||
serviceConfig.Volumes[i] = resolveVolumePath(volume, workingDir, lookupEnv)
|
||||
}
|
||||
|
||||
if convertPaths {
|
||||
serviceConfig.Volumes[i] = convertVolumePath(volume)
|
||||
}
|
||||
}
|
||||
|
||||
return serviceConfig, nil
|
||||
}
|
||||
|
||||
// Windows paths, c:\\my\\path\\shiny, need to be changed to be compatible with
|
||||
// the Engine. Volume paths are expected to be linux style /c/my/path/shiny/
|
||||
func convertVolumePath(volume types.ServiceVolumeConfig) types.ServiceVolumeConfig {
|
||||
volumeName := strings.ToLower(filepath.VolumeName(volume.Source))
|
||||
if len(volumeName) != 2 {
|
||||
return volume
|
||||
}
|
||||
|
||||
convertedSource := fmt.Sprintf("/%c%s", volumeName[0], volume.Source[len(volumeName):])
|
||||
convertedSource = strings.ReplaceAll(convertedSource, "\\", "/")
|
||||
|
||||
volume.Source = convertedSource
|
||||
return volume
|
||||
}
|
||||
|
||||
func resolveEnvironment(serviceConfig *types.ServiceConfig, workingDir string, lookupEnv template.Mapping) error {
|
||||
environment := types.MappingWithEquals{}
|
||||
|
||||
@ -998,16 +1019,21 @@ var transformSSHConfig TransformerFunc = func(data interface{}) (interface{}, er
|
||||
}
|
||||
return result, nil
|
||||
case string:
|
||||
if value == "" {
|
||||
value = "default"
|
||||
}
|
||||
key, val := transformValueToMapEntry(value, "=", false)
|
||||
result := []types.SSHKey{{ID: key, Path: val.(string)}}
|
||||
return result, nil
|
||||
return ParseShortSSHSyntax(value)
|
||||
}
|
||||
return nil, errors.Errorf("expected a sting, map or a list, got %T: %#v", data, data)
|
||||
}
|
||||
|
||||
// ParseShortSSHSyntax parse short syntax for SSH authentications
|
||||
func ParseShortSSHSyntax(value string) ([]types.SSHKey, error) {
|
||||
if value == "" {
|
||||
value = "default"
|
||||
}
|
||||
key, val := transformValueToMapEntry(value, "=", false)
|
||||
result := []types.SSHKey{{ID: key, Path: val.(string)}}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
var transformStringOrNumberList TransformerFunc = func(value interface{}) (interface{}, error) {
|
||||
list := value.([]interface{})
|
||||
result := make([]string, len(list))
|
||||
|
8
vendor/github.com/compose-spec/compose-go/loader/validate.go
generated
vendored
8
vendor/github.com/compose-spec/compose-go/loader/validate.go
generated
vendored
@ -55,9 +55,11 @@ func checkConsistency(project *types.Project) error {
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, secret := range s.Secrets {
|
||||
if _, ok := project.Secrets[secret.Source]; !ok {
|
||||
return errors.Wrap(errdefs.ErrInvalid, fmt.Sprintf("service %q refers to undefined secret %s", s.Name, secret.Source))
|
||||
if s.Build != nil {
|
||||
for _, secret := range s.Build.Secrets {
|
||||
if _, ok := project.Secrets[secret.Source]; !ok {
|
||||
return errors.Wrap(errdefs.ErrInvalid, fmt.Sprintf("service %q refers to undefined build secret %s", s.Name, secret.Source))
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, config := range s.Configs {
|
||||
|
Reference in New Issue
Block a user