2022-10-30 18:13:57 +01:00
|
|
|
package container
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"log"
|
|
|
|
|
|
|
|
"dagger.io/dagger"
|
|
|
|
)
|
|
|
|
|
|
|
|
func MountCurrent(ctx context.Context, client *dagger.Client, container *dagger.Container, into string) (*dagger.Container, error) {
|
|
|
|
log.Printf("mounting current working directory into path: %s", into)
|
|
|
|
src, err := client.
|
|
|
|
Host().
|
|
|
|
Workdir().
|
|
|
|
Read().
|
|
|
|
ID(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return container.WithMountedDirectory(into, src), nil
|
|
|
|
}
|
|
|
|
|
2022-10-30 22:37:30 +01:00
|
|
|
func MountFileFromLoaded(ctx context.Context, container *dagger.Container, bin dagger.FileID, path string) (*dagger.Container, error) {
|
2022-10-30 18:13:57 +01:00
|
|
|
log.Printf("mounting binary into container: into (path=%s)", path)
|
2022-10-30 22:37:30 +01:00
|
|
|
newFs, err := container.FS().WithCopiedFile(path, bin).ID(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return container.WithFS(newFs), nil
|
2022-10-30 18:13:57 +01:00
|
|
|
}
|