( namespace Namespace, config composetypes.FileReferenceConfig, lookup func(key string) (composetypes.FileObjectConfig, error), )
| 370 | } |
| 371 | |
| 372 | func 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 | |
| 416 | func uint32Ptr(value uint32) *uint32 { |
| 417 | return &value |
searching dependent graphs…