mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-10 05:27:07 +08:00
Set ConfigFile
to parse compose files with bake
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
23
vendor/github.com/compose-spec/compose-go/loader/loader.go
generated
vendored
23
vendor/github.com/compose-spec/compose-go/loader/loader.go
generated
vendored
@ -217,16 +217,35 @@ func Load(configDetails types.ConfigDetails, options ...func(*Options)) (*types.
|
||||
|
||||
func parseConfig(b []byte, opts *Options) (map[string]interface{}, error) {
|
||||
if !opts.SkipInterpolation {
|
||||
substitute, err := opts.Interpolate.Substitute(string(b), template.Mapping(opts.Interpolate.LookupValue))
|
||||
withoutComments, err := removeYamlComments(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b = []byte(substitute)
|
||||
|
||||
substituted, err := opts.Interpolate.Substitute(string(withoutComments), template.Mapping(opts.Interpolate.LookupValue))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b = []byte(substituted)
|
||||
}
|
||||
|
||||
return ParseYAML(b)
|
||||
}
|
||||
|
||||
// removeYamlComments drop all comments from the yaml file, so we don't try to apply string substitutions on irrelevant places
|
||||
func removeYamlComments(b []byte) ([]byte, error) {
|
||||
var cfg interface{}
|
||||
err := yaml.Unmarshal(b, &cfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b, err = yaml.Marshal(cfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b, nil
|
||||
}
|
||||
|
||||
func groupXFieldsIntoExtensions(dict map[string]interface{}) map[string]interface{} {
|
||||
extras := map[string]interface{}{}
|
||||
for key, value := range dict {
|
||||
|
Reference in New Issue
Block a user