Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge yaml files as plain map[string]interface trees #464

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions loader/include.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"github.com/compose-spec/compose-go/dotenv"
interp "github.com/compose-spec/compose-go/interpolation"
"github.com/compose-spec/compose-go/types"
"github.com/pkg/errors"
)

// LoadIncludeConfig parse the require config from raw yaml
Expand All @@ -34,17 +33,6 @@ func LoadIncludeConfig(source []interface{}) ([]types.IncludeConfig, error) {
return requires, err
}

var transformIncludeConfig TransformerFunc = func(data interface{}) (interface{}, error) {
switch value := data.(type) {
case string:
return map[string]interface{}{"path": value}, nil
case map[string]interface{}:
return value, nil
default:
return data, errors.Errorf("invalid type %T for `include` configuration", value)
}
}

func loadInclude(ctx context.Context, filename string, configDetails types.ConfigDetails, model *types.Config, options *Options, loaded []string) (*types.Config, map[string][]types.IncludeConfig, error) {
included := make(map[string][]types.IncludeConfig)
for _, r := range model.Include {
Expand Down
8 changes: 2 additions & 6 deletions loader/interpolate.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

interp "github.com/compose-spec/compose-go/interpolation"
"github.com/compose-spec/compose-go/tree"
"github.com/docker/go-units"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
Expand Down Expand Up @@ -60,7 +61,6 @@ var interpolateTypeCastMapping = map[tree.Path]interp.Cast{
servicePath("secrets", tree.PathMatchList, "mode"): toInt,
servicePath("shm_size"): toUnitBytes,
servicePath("stdin_open"): toBoolean,
servicePath("stop_grace_period"): toDuration,
servicePath("tty"): toBoolean,
servicePath("ulimits", tree.PathMatchAll): toInt,
servicePath("ulimits", tree.PathMatchAll, "hard"): toInt,
Expand Down Expand Up @@ -94,11 +94,7 @@ func toInt64(value string) (interface{}, error) {
}

func toUnitBytes(value string) (interface{}, error) {
return transformSize(value)
}

func toDuration(value string) (interface{}, error) {
return transformStringToDuration(value)
return units.RAMInBytes(value)
}

func toFloat(value string) (interface{}, error) {
Expand Down
Loading