MCPcopy Create free account
hub / github.com/docker/cli / Transform

Function Transform

cli/compose/loader/loader.go:297–311  ·  view source on GitHub ↗

Transform converts the source into the target struct with compose types transformer and the specified transformers if any.

(source any, target any, additionalTransformers ...Transformer)

Source from the content-addressed store, hash-verified

295// Transform converts the source into the target struct with compose types transformer
296// and the specified transformers if any.
297func Transform(source any, target any, additionalTransformers ...Transformer) error {
298 data := mapstructure.Metadata{}
299 config := &mapstructure.DecoderConfig{
300 DecodeHook: mapstructure.ComposeDecodeHookFunc(
301 createTransformHook(additionalTransformers...),
302 mapstructure.StringToTimeDurationHookFunc()),
303 Result: target,
304 Metadata: &data,
305 }
306 decoder, err := mapstructure.NewDecoder(config)
307 if err != nil {
308 return err
309 }
310 return decoder.Decode(source)
311}
312
313// TransformerFunc defines a function to perform the actual transformation
314type TransformerFunc func(any) (any, error)

Callers 6

TestTransformFunction · 0.85
LoadServiceFunction · 0.85
LoadNetworksFunction · 0.85
LoadVolumesFunction · 0.85
LoadSecretsFunction · 0.85
LoadConfigObjsFunction · 0.85

Calls 1

createTransformHookFunction · 0.85

Tested by 1

TestTransformFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…