@@ -28,15 +28,12 @@ import (
2828 "regexp"
2929 "strconv"
3030 "strings"
31- "time"
3231
3332 "github.com/compose-spec/compose-go/consts"
3433 interp "github.com/compose-spec/compose-go/interpolation"
3534 "github.com/compose-spec/compose-go/schema"
3635 "github.com/compose-spec/compose-go/template"
3736 "github.com/compose-spec/compose-go/types"
38- "github.com/docker/go-units"
39- "github.com/mattn/go-shellwords"
4037 "github.com/mitchellh/mapstructure"
4138 "github.com/pkg/errors"
4239 "github.com/sirupsen/logrus"
@@ -586,7 +583,7 @@ func Transform(source interface{}, target interface{}, additionalTransformers ..
586583 config := & mapstructure.DecoderConfig {
587584 DecodeHook : mapstructure .ComposeDecodeHookFunc (
588585 createTransformHook (additionalTransformers ... ),
589- mapstructure . StringToTimeDurationHookFunc () ),
586+ decoderHook ),
590587 Result : target ,
591588 TagName : "yaml" ,
592589 Metadata : & data ,
@@ -611,11 +608,9 @@ func createTransformHook(additionalTransformers ...Transformer) mapstructure.Dec
611608 transforms := map [reflect.Type ]func (interface {}) (interface {}, error ){
612609 reflect .TypeOf (types.External {}): transformExternal ,
613610 reflect .TypeOf (types.HealthCheckTest {}): transformHealthCheckTest ,
614- reflect .TypeOf (types.ShellCommand {}): transformShellCommand ,
615611 reflect .TypeOf (types.StringList {}): transformStringList ,
616612 reflect .TypeOf (types.Options {}): transformMapStringString ,
617613 reflect .TypeOf (types.UlimitsConfig {}): transformUlimits ,
618- reflect .TypeOf (types .UnitBytes (0 )): transformSize ,
619614 reflect .TypeOf ([]types.ServicePortConfig {}): transformServicePort ,
620615 reflect .TypeOf (types.ServiceSecretConfig {}): transformFileReferenceConfig ,
621616 reflect .TypeOf (types.ServiceConfigObjConfig {}): transformFileReferenceConfig ,
@@ -628,7 +623,6 @@ func createTransformHook(additionalTransformers ...Transformer) mapstructure.Dec
628623 reflect .TypeOf (types.HostsList {}): transformMappingOrListFunc (":" , false ),
629624 reflect .TypeOf (types.ServiceVolumeConfig {}): transformServiceVolumeConfig ,
630625 reflect .TypeOf (types.BuildConfig {}): transformBuildConfig ,
631- reflect .TypeOf (types .Duration (0 )): transformStringToDuration ,
632626 reflect .TypeOf (types.DependsOnConfig {}): transformDependsOnConfig ,
633627 reflect .TypeOf (types.ExtendsConfig {}): transformExtendsConfig ,
634628 reflect .TypeOf (types.DeviceRequest {}): transformServiceDeviceRequest ,
@@ -1312,13 +1306,6 @@ func transformValueToMapEntry(value string, separator string, allowNil bool) (st
13121306 }
13131307}
13141308
1315- var transformShellCommand TransformerFunc = func (value interface {}) (interface {}, error ) {
1316- if str , ok := value .(string ); ok {
1317- return shellwords .Parse (str )
1318- }
1319- return value , nil
1320- }
1321-
13221309var transformHealthCheckTest TransformerFunc = func (data interface {}) (interface {}, error ) {
13231310 switch value := data .(type ) {
13241311 case string :
@@ -1330,34 +1317,6 @@ var transformHealthCheckTest TransformerFunc = func(data interface{}) (interface
13301317 }
13311318}
13321319
1333- var transformSize TransformerFunc = func (value interface {}) (interface {}, error ) {
1334- switch value := value .(type ) {
1335- case int :
1336- return int64 (value ), nil
1337- case int64 , types.UnitBytes :
1338- return value , nil
1339- case string :
1340- return units .RAMInBytes (value )
1341- default :
1342- return value , errors .Errorf ("invalid type for size %T" , value )
1343- }
1344- }
1345-
1346- var transformStringToDuration TransformerFunc = func (value interface {}) (interface {}, error ) {
1347- switch value := value .(type ) {
1348- case string :
1349- d , err := time .ParseDuration (value )
1350- if err != nil {
1351- return value , err
1352- }
1353- return types .Duration (d ), nil
1354- case types.Duration :
1355- return value , nil
1356- default :
1357- return value , errors .Errorf ("invalid type %T for duration" , value )
1358- }
1359- }
1360-
13611320func toMapStringString (value map [string ]interface {}, allowNil bool ) map [string ]interface {} {
13621321 output := make (map [string ]interface {})
13631322 for key , value := range value {
0 commit comments