Skip to content

Commit

Permalink
fix: drop DEPRECATED
Browse files Browse the repository at this point in the history
  • Loading branch information
morlay committed Mar 1, 2024
1 parent 828415b commit e38ab8e
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 66 deletions.
4 changes: 1 addition & 3 deletions pkg/engine/plan/task/container_dockerfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ type Dockerfile struct {

func (input *Dockerfile) Do(ctx context.Context) error {
return daggerutil.Do(ctx, func(c *dagger.Client) error {
dir := c.Directory(dagger.DirectoryOpts{
ID: input.Source.DirectoryID(),
})
dir := input.Source.Directory(c)

dockerfilePath := input.Dockerfile.Path

Expand Down
4 changes: 1 addition & 3 deletions pkg/engine/plan/task/container_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ type Exec struct {

func (e *Exec) Do(ctx context.Context) error {
return daggerutil.Do(ctx, func(c *dagger.Client) error {
ct := c.Container().WithRootfs(c.Directory(dagger.DirectoryOpts{
ID: e.Input.DirectoryID(),
}))
ct := c.Container().WithRootfs(e.Input.Directory(c))

if workdir := e.Workdir; workdir != "" {
ct = ct.WithWorkdir(workdir)
Expand Down
8 changes: 2 additions & 6 deletions pkg/engine/plan/task/container_push.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ func (input *PushImage) Do(ctx context.Context) error {
return errors.Errorf("missing fs")
}

dir := c.Directory(dagger.DirectoryOpts{
ID: id,
})
dir := c.LoadDirectoryFromID(id)

ctr := input.Config.ApplyTo(c.Container(dagger.ContainerOpts{
Platform: dagger.Platform(input.Platform),
Expand Down Expand Up @@ -142,9 +140,7 @@ func (input *PushManifests) Do(ctx context.Context) error {
return errors.Errorf("missing fs for %s", platform)
}

dir := c.Directory(dagger.DirectoryOpts{
ID: id,
})
dir := c.LoadDirectoryFromID(id)

ctr := img.Config.ApplyTo(c.Container(dagger.ContainerOpts{Platform: dagger.Platform(platform)}).WithRootfs(dir))

Expand Down
4 changes: 1 addition & 3 deletions pkg/engine/plan/task/container_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ type Run struct {
func (e *Run) Do(ctx context.Context) error {
return daggerutil.Do(ctx, func(c *dagger.Client) error {
ct := c.Container().
WithRootfs(c.Directory(dagger.DirectoryOpts{
ID: e.Input.DirectoryID(),
}))
WithRootfs(e.Input.Directory(c))

ct = e.Config.ApplyTo(ct)

Expand Down
12 changes: 8 additions & 4 deletions pkg/engine/plan/task/core/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ func (fs *FS) DirectoryID() dagger.DirectoryID {
return ""
}

func (fs *FS) Directory(c *dagger.Client) *dagger.Directory {
if id := fs.DirectoryID(); id != "" {
return c.LoadDirectoryFromID(id)
}
return c.Directory()
}

func (f *FS) Type() string {
return "fs"
}
Expand All @@ -60,10 +67,7 @@ func (f *FS) CanExport() bool {

func (f *FS) ExportTo(ctx context.Context, localPath string) error {
return daggerutil.Do(ctx, func(c *dagger.Client) error {
rootfs := c.Directory(dagger.DirectoryOpts{
ID: f.DirectoryID(),
})
_, err := rootfs.Export(ctx, localPath)
_, err := f.Directory(c).Export(ctx, localPath)
return err
})
}
4 changes: 1 addition & 3 deletions pkg/engine/plan/task/core/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ func (img *Image) CanExport() bool {

func (img *Image) ExportTo(ctx context.Context, localPath string) error {
return daggerutil.Do(ctx, func(c *dagger.Client) error {
rootfs := c.Directory(dagger.DirectoryOpts{
ID: img.Rootfs.DirectoryID(),
})
rootfs := img.Rootfs.Directory(c)

ct := c.Container(dagger.ContainerOpts{
Platform: DefaultPlatform(img.Platform),
Expand Down
6 changes: 2 additions & 4 deletions pkg/engine/plan/task/core/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,8 @@ type MountFs struct {
ReadOnly bool `json:"ro,omitempty" wagon:"deprecated"`
}

func (f MountFs) MountTo(client *dagger.Client, container *dagger.Container) *dagger.Container {
dir := client.Directory(dagger.DirectoryOpts{
ID: f.Contents.DirectoryID(),
})
func (f MountFs) MountTo(c *dagger.Client, container *dagger.Container) *dagger.Container {
dir := f.Contents.Directory(c)

if source := f.Source; source != nil {
src := *source
Expand Down
14 changes: 3 additions & 11 deletions pkg/engine/plan/task/fs_copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,12 @@ type Copy struct {

func (cp *Copy) Do(ctx context.Context) error {
return daggerutil.Do(ctx, func(c *dagger.Client) error {
contents := c.Directory(dagger.DirectoryOpts{
ID: cp.Contents.DirectoryID(),
})
contents := cp.Contents.Directory(c)

if source := cp.Source; source != "/" {
// When file exists
if f, err := contents.File(source).Sync(ctx); err == nil {
out := c.
Directory(dagger.DirectoryOpts{
ID: cp.Input.DirectoryID(),
}).
out := cp.Input.Directory(c).
WithFile(cp.Dest, f)

return cp.Output.SetDirectoryIDBy(ctx, out)
Expand All @@ -45,10 +40,7 @@ func (cp *Copy) Do(ctx context.Context) error {
contents = contents.Directory(source)
}

ct := c.
Directory(dagger.DirectoryOpts{
ID: cp.Input.DirectoryID(),
}).
ct := cp.Input.Directory(c).
WithDirectory(cp.Dest, contents, dagger.DirectoryWithDirectoryOpts{
Include: cp.Include,
Exclude: cp.Exclude,
Expand Down
8 changes: 2 additions & 6 deletions pkg/engine/plan/task/fs_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,8 @@ type Diff struct {

func (e *Diff) Do(ctx context.Context) error {
return daggerutil.Do(ctx, func(c *dagger.Client) error {
upper := c.Directory(dagger.DirectoryOpts{
ID: e.Upper.DirectoryID(),
})
lower := c.Directory(dagger.DirectoryOpts{
ID: e.Lower.DirectoryID(),
})
upper := e.Upper.Directory(c)
lower := e.Lower.Directory(c)
return e.Output.SetDirectoryIDBy(ctx, lower.Diff(upper))
})
}
4 changes: 1 addition & 3 deletions pkg/engine/plan/task/fs_entries.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ type Entries struct {
func (e *Entries) Do(ctx context.Context) error {
return daggerutil.Do(ctx, func(c *dagger.Client) error {
fw := &entriesWalker{
d: c.Directory(dagger.DirectoryOpts{
ID: e.Input.DirectoryID(),
}),
d: e.Input.Directory(c),
maxDepth: e.Depth,
}

Expand Down
8 changes: 2 additions & 6 deletions pkg/engine/plan/task/fs_merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,8 @@ func (e *Merge) Do(ctx context.Context) error {
return daggerutil.Do(ctx, func(c *dagger.Client) error {
d := c.Directory()

for i := range e.Inputs {
x := e.Inputs[i]

d = d.WithDirectory("/", c.Directory(dagger.DirectoryOpts{
ID: x.DirectoryID(),
}))
for _, input := range e.Inputs {
d = d.WithDirectory("/", input.Directory(c))
}

return e.Output.SetDirectoryIDBy(ctx, d)
Expand Down
4 changes: 1 addition & 3 deletions pkg/engine/plan/task/fs_mkdir.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ type Mkdir struct {

func (e *Mkdir) Do(ctx context.Context) error {
return daggerutil.Do(ctx, func(c *dagger.Client) error {
dir := c.Directory(dagger.DirectoryOpts{
ID: e.Input.DirectoryID(),
})
dir := e.Input.Directory(c)

for _, p := range e.Path.Values {
dir = dir.WithNewDirectory(
Expand Down
4 changes: 1 addition & 3 deletions pkg/engine/plan/task/fs_readfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ type ReadFile struct {

func (e *ReadFile) Do(ctx context.Context) error {
return daggerutil.Do(ctx, func(c *dagger.Client) error {
dir := c.Directory(dagger.DirectoryOpts{
ID: e.Input.DirectoryID(),
})
dir := e.Input.Directory(c)

f := dir.File(e.Path)

Expand Down
4 changes: 1 addition & 3 deletions pkg/engine/plan/task/fs_rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ type Rm struct {

func (e *Rm) Do(ctx context.Context) error {
return daggerutil.Do(ctx, func(c *dagger.Client) error {
dir := c.Directory(dagger.DirectoryOpts{
ID: e.Input.DirectoryID(),
})
dir := e.Input.Directory(c)

newDir := dir.WithoutDirectory(e.Path)

Expand Down
8 changes: 3 additions & 5 deletions pkg/engine/plan/task/fs_writefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ type WriteFile struct {

func (e *WriteFile) Do(ctx context.Context) error {
return daggerutil.Do(ctx, func(c *dagger.Client) error {
dir := c.
Directory(dagger.DirectoryOpts{ID: e.Input.DirectoryID()}).
WithNewFile(e.Path, e.Contents, dagger.DirectoryWithNewFileOpts{
Permissions: e.Permissions,
})
dir := e.Input.Directory(c).WithNewFile(e.Path, e.Contents, dagger.DirectoryWithNewFileOpts{
Permissions: e.Permissions,
})
return e.Output.SetDirectoryIDBy(ctx, dir)
})
}

0 comments on commit e38ab8e

Please sign in to comment.