MCPcopy Index your code
hub / github.com/docker/cli / convertFileObject

Function convertFileObject

cli/compose/convert/service.go:372–414  ·  view source on GitHub ↗
(
	namespace Namespace,
	config composetypes.FileReferenceConfig,
	lookup func(key string) (composetypes.FileObjectConfig, error),
)

Source from the content-addressed store, hash-verified

370}
371
372func convertFileObject(
373 namespace Namespace,
374 config composetypes.FileReferenceConfig,
375 lookup func(key string) (composetypes.FileObjectConfig, error),
376) (swarmReferenceObject, error) {
377 obj, err := lookup(config.Source)
378 if err != nil {
379 return swarmReferenceObject{}, err
380 }
381
382 source := namespace.Scope(config.Source)
383 if obj.Name != "" {
384 source = obj.Name
385 }
386
387 target := config.Target
388 if target == "" {
389 target = config.Source
390 }
391
392 uid := config.UID
393 gid := config.GID
394 if uid == "" {
395 uid = "0"
396 }
397 if gid == "" {
398 gid = "0"
399 }
400 mode := config.Mode
401 if mode == nil {
402 mode = uint32Ptr(0o444)
403 }
404
405 return swarmReferenceObject{
406 File: swarmReferenceTarget{
407 Name: target,
408 UID: uid,
409 GID: gid,
410 Mode: os.FileMode(*mode),
411 },
412 Name: source,
413 }, nil
414}
415
416func uint32Ptr(value uint32) *uint32 {
417 return &value

Callers 4

TestConvertFileObjectFunction · 0.85
convertServiceSecretsFunction · 0.85
convertServiceConfigObjsFunction · 0.85

Calls 2

uint32PtrFunction · 0.70
ScopeMethod · 0.45

Tested by 2

TestConvertFileObjectFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…