#The `+ignore` pragma is not always respected with context directories

1 messages · Page 1 of 1 (latest)

uncut kelp
#

I have the following setup for a context directory within a Chef module:

    // +defaultPath="/"
    // +ignore=[
    //   "**",
    //   "!.chef/knife-local.rb",
    //   "!.chef/knife.rb",
    //   "!lib",
    //   "!plugins",
    //   "!site-cookbooks"
    // ]
    source *dagger.Directory,

When I call using the default args, the source is registered as a context directory and the expected files/dirs are filtered out:

$ cd ~/git/chef
$ dagger call -E shell
...
● ✔ chef(
    ┆ source: context /Users/cbochs/git/chef (
    ┆ ┆ exclude: ["**", "!.chef/knife-local.rb", "!.chef/knife.rb", "!lib", "!plugins", "!site-cookbooks"]
    ┆ )
...

dagger ~ $ ls
lib  plugins  site-cookbooks

However, when I call the same module, overriding the source explicitly, the directory is no longer considered a "context" directory and all all files/dirs are uploaded:

$ dagger call -E shell --source ~/git/chef
...
...
├╴✔ address(value: "/Users/cbochs/git/chef"): Address! = xxh3:382e3f919e7e378a 0.0s
╰╴✔ .directory: Directory! = xxh3:a255ebbf0650aeda 16.3s
  ╰╴✔ Host.directory(path: "/Users/cbochs/git/chef"): Directory! = xxh3:1525476f2171ef54 16.3s
    ╰╴✔ filesync 16.3s
      ├╴✔ .chef 0.0s ◆ Written Bytes: 1.9 kB
      ├╴✔ .dagger 0.1s ◆ Written Bytes: 349 kB
      ├╴✔ .git 14.1s ◆ Written Bytes: 1.5 GB
      ├╴✔ .github 1.9s ◆ Written Bytes: 24 B
      ...
✔ chef(
│ ┆ source: Address.directory: Directory! = xxh3:682c87b9aed296a5
...

dagger ~ $ ls
Gemfile    Rakefile  chefignore  dagger.json  docs  plugins  site-cookbooks
README.md  bin       cookstyle   data_bags    lib   script

This is unexpected to me. I had two thoughts when this occurred

  1. Why is the explicit --source not marked as a "context" directory?
  2. Why is the +ignore pragma not respected when passing --source?
hallow dirge
# uncut kelp I have the following setup for a context directory within a Chef module: ```go ...

hey there! are you using the latest version of Dagger? I can't seem to be able to repro this.

Here's what I've tried

mkdir testignore
cd testignore
dagger init --sdk go #brand new module

Replaced Ignoretest module with this code:

func (m *Ignoretest) Test(
    // +defaultPath="."
    // +ignore=["**", "!dagger.json"]
    src *dagger.Directory,
) *dagger.Directory {
    return src
}

then calling both dagger call test entries or dagger call test --src . entries will only return dagger.json

130|marcos:tmp/ignoretest (⎈ |N/A)$ dagger call test --src /tmp/ignoretest entries
✔ connect 0.3s
✔ load module: . 0.3s
✔ parsing command line arguments 0.0s

✔ ignoretest: Ignoretest! 0.0s
✔ .test(
  ┆ src: Address.directory(exclude: ["**", "!dagger.json"]): Directory!
  ): Directory! 0.0s

✔ Directory.entries: [String!]! 0.0s

dagger.json


Full trace at https://dagger.cloud/dagger/traces/06d7265e2cc8a931c0959d3efd27bffb
marcos:tmp/ignoretest (⎈ |N/A)$ dagger call test  entries
✔ connect 0.2s
✔ load module: . 0.3s
✔ parsing command line arguments 0.0s

✔ ignoretest: Ignoretest! 0.0s
✔ .test(
  ┆ src: context /tmp/ignoretest (exclude: ["**", "!dagger.json"])
  ): Directory! 0.0s

✔ Directory.entries: [String!]! 0.0s

dagger.json


Full trace at https://dagger.cloud/dagger/traces/af042a7c877d0fab25c56762bb23a4f2
marcos:tmp/ignoretest (⎈ |N/A)$
#

It'd really help us if you can find a way to send a consistent repro 🙏

uncut kelp
#

Thanks!

I should clarify: I did try this using the path . found the context directory worked just fine.

It was only when I provided an absolute/qualified path (~/git/chef) where I hit the issue.

#

Also, I am running dagger v0.19.8

hallow dirge
hallow dirge
uncut kelp
#

I tried after upgrading to 0.19.10, still seeing the same issue where the filesync uploads everything:

├╴✔ address(value: "/Users/cbochs/git/chef"): Address! = xxh3:382e3f919e7e378a 0.0s
╰╴✔ .directory: Directory! = xxh3:04588d3d6490a5bc 16.0s
  ╰╴✔ Host.directory(path: "/Users/cbochs/git/chef"): Directory! = xxh3:ff3abf8e9d1c22d3 16.0s
    ╰╴✔ filesync 16.0s
      ├╴✔ .chef 0.0s ◆ Written Bytes: 1.9 kB
      ├╴✔ .dagger 0.1s ◆ Written Bytes: 349 kB
      ├╴✔ .git 14.3s ◆ Written Bytes: 1.5 GB
      ├╴✔ .github 0.6s ◆ Written Bytes: 24 B
...
✔ chef(
│ ┆ source: Address.directory: Directory! = xxh3:04588d3d6490a5bc

As far as I can tell, there's nothing special about this module. However, since I am not able to share a trace/code, I will try to create a minimal reproduction of this to share 🙂

#

Ah, okay. I have a reproduction. I had swapped things around a bit by accident, but here it is:

package main

import (
    "context"
    "dagger/filesync/internal/dagger"
)

type Filesync struct {
    Source *dagger.Directory // +private
}

func New(
    // +defaultPath="/"
    // +ignore=["**","!dagger.json"]
    source *dagger.Directory,
) *Filesync {
    return &Filesync{Source: source}
}

// Returns a container that echoes whatever string argument is provided
func (m *Filesync) Test(ctx context.Context) ([]string, error) {
    return m.Source.Entries(ctx)
}

Called with

dagger call --source /tmp/dagger-filesync test

.gitattributes
.gitignore
dagger.gen.go
dagger.json
go.mod
go.sum
internal/
main.go
#

It only seems to happen when the context directory is in the New constructor

hallow dirge
hallow dirge
#

@uncut kelp seems like an issue indeed. Would you mind opening an issue please? 🙏