Repository navigation
Support for directory arg filtering via views - #6857
Conversation
|
👋 looks very nice, just checking if |
|
How do you feel about using And instead of a flag for The examples in Adding an exclude is shown in the description: But that adds it to an Finally, I suggest adding a |
|
Moving this to |
yep exactly, it will create it if it doesn't exist and overwrite it if it does exist |
Yeah SGTM I like those names more
Sure yeah I like that it's less verbose, there is a little ambiguity in the
Good catch, will fix
Yeah I think that I'm going to avoid a separate
Also SGTM, adding! |
|
@helderco Been updating based on your suggestions, the one thing I'm backing out on is switching
So I'm going back to the flag, I think the shorthand flag |
|
Updated from feedback so far, just need to add a bunch of tests now. Updated PR description with latest examples cc @shykes |
|
EDIT: nevermind, just going to mark the commands as hidden for now and skip docs so we can merge it as is (pending approval) and modify the CLI UX in a follow-up. |
dagger config views and directory arg filteringThere was a problem hiding this comment.
Add the experimental annotation so it's not included when generating the cli reference.
There was a problem hiding this comment.
It looks like the cli reference didn't include the hidden subcommands already actually, but added the experimental annotation anyways in case I'm missing something
There was a problem hiding this comment.
Ah, right. Some of the hidden ones we wanted on the reference, but not others. So we removed the hidden flag and added the experimental in those. In this case, it should be just hidden, sorry about that.
EDIT: Still useful to have the experimental flag in case someone stumbles in the command, it'll show in the --help that it's in development.
|
By default every file is included right? Doesn't it make more sense to unify under an "exclude" key, and use "!" for things that shouldn't be excluded? It's also more consistent with .gitgignore and .dockerignore. Before: "include": [
"!**/.direnv",
"!**/.envrc",
"!**/.venv",
"!**/sdk"
],After: "exclude": [
"**/.direnv",
"**/.envrc",
"**/.venv",
"**/sdk"
], |
|
I think that even though the include patterns for loading the module are usually to exclude files, I find that for the views it's the opposite. The views I'm creating are primarily to include specific files, and exclude a few from those. I much prefer the shift to "exclude", in line with git excludes for example, but even though the views are under "patterns", it can be confusing to use the opposite meaning from the ones for loading the module. |
helderco
left a comment
There was a problem hiding this comment.
Works as advertised 🎉
Now I wish I could re-use the views from a dependency! Maybe another : value specifying the dependency, like PATH[:VIEW_NAME[:VIEW_ORIGIN]].
For example, sdk/python module has a few views. And our ci module depends on the python sdk's. Assuming the dependency is called "python":
dagger call python lint --src=docs:lint:python
Otherwise, we'll need to duplicate the patterns.
Could also be called with:
dagger call -m python lint --src=docs:lint
Not sure if that can replace everything since we may want to join everything together at the root (with an SDK interface).
There was a problem hiding this comment.
Are you not using require.JSONEq to validate the contents?
There was a problem hiding this comment.
Yeah I felt like doing the unmarshal and require this way was a bit more readable since the json blob string in this case would be more complicated than in our other uses of JSONEq
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
…compatibly Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Totally agree, but as I was updating this I went down a rabbit hole and realized there's a ton of pre-existing problems with the way this global include/exclude is implemented. Details here #6902. The consolidation of the global include/exclude was just an extra-credit thing that seemed simple enough to just clean up while I was here, but there's too many deeper issues intertwined so I ended up just backing out of that part of all this (including the
Agree with the general sentiment here, but just to clarify you are all good with the current approach? I think the name
Totally, that makes sense. I'd need to think about the syntax a bit more but agree we should find a way to add something like this. |
|
@helderco gonna merge as is, but let me know if there's any concerns, can fixup before the release next week |
Yep, all good. I agree, on their own, "views"+"patterns" and "exclude" make sense, it's just the discrepancy when they're together (same file), but I don't have a better suggestion. Good decision to keep split "include"+"exclude" for module load |
Fixes #6155
Adds support for
viewsas described in the linked issue to support filtering individual directory args.This PR also includes new CLI subcommands under
dagger configfor configuring views and more generally anything described in #6606.dagger.jsonin the meantime.Assuming hand-edits of
dagger.jsonto something like this:{ "name": "example", "sdk": "go", "views": [ { "name": "cool-view", "patterns": [ "foo", "**/*.go", "!bin" ] } ] }Then any function in the module can be invoked with the view applied to the directory like:
dagger call some-func --some-dir-arg some/path:cool-viewDetails on CLI interface for configuring these
The
set/add/removecommands are implemented such that we can easily re-use the pattern for any other config values. I also added support fordagger config includefor configuring the pre-existing global include settings indagger.jsonso far.Examples
The
-nflag used below is valid on the top levelviewscommand and any subcommands, have a mix of examples.The output has terminal formatting to bold+underline headers that's not carried over through the md below, so it looks a little nicer when you actually run it.
Create a new view named cool-view
Use the view
dagger call fn --dir-arg /some/path:cool-viewSee the view(s)
Add more patterns to cool-view
Remove some existing patterns from cool-view
Remove cool-view entirely