mutates container caller must have handled cloning or creating a new child. nolint:dupl // symmetric with WithMountedDirectory; sharing would hide type specifics
( ctx context.Context, parent dagql.ObjectResult[*Container], target string, file dagql.ObjectResult[*File], owner string, readonly bool, )
| 5587 | // |
| 5588 | //nolint:dupl // symmetric with WithMountedDirectory; sharing would hide type specifics |
| 5589 | func (container *Container) WithMountedFile( |
| 5590 | ctx context.Context, |
| 5591 | parent dagql.ObjectResult[*Container], |
| 5592 | target string, |
| 5593 | file dagql.ObjectResult[*File], |
| 5594 | owner string, |
| 5595 | readonly bool, |
| 5596 | ) (*Container, error) { |
| 5597 | target = absPath(container.Config.WorkingDir, target) |
| 5598 | |
| 5599 | var err error |
| 5600 | if owner != "" { |
| 5601 | file, err = container.chownFile(ctx, parent, file, owner) |
| 5602 | if err != nil { |
| 5603 | return nil, err |
| 5604 | } |
| 5605 | } |
| 5606 | |
| 5607 | cache, err := dagql.EngineCache(ctx) |
| 5608 | if err != nil { |
| 5609 | return nil, err |
| 5610 | } |
| 5611 | if err := cache.Evaluate(ctx, file); err != nil { |
| 5612 | return nil, err |
| 5613 | } |
| 5614 | detached, err := cloneDetachedFileForContainerResult(ctx, file.Self()) |
| 5615 | if err != nil { |
| 5616 | return nil, err |
| 5617 | } |
| 5618 | source := new(LazyAccessor[*File, *Container]) |
| 5619 | source.setValue(detached) |
| 5620 | |
| 5621 | container.Mounts = container.Mounts.With(ContainerMount{ |
| 5622 | FileSource: source, |
| 5623 | Target: target, |
| 5624 | Readonly: readonly, |
| 5625 | }) |
| 5626 | |
| 5627 | // set image ref to empty string |
| 5628 | container.ImageRef = "" |
| 5629 | |
| 5630 | return container, nil |
| 5631 | } |
| 5632 | |
| 5633 | // mutates container caller must have handled cloning or creating a new child. |
| 5634 | func (container *Container) WithMountedPathDockerfileCompat( |
no test coverage detected