Skip to content

Improve "dagger functions" - #6317

Merged
sipsma merged 2 commits into
dagger:mainfrom
shykes:2023-12-improve-dagger-functions
Jan 15, 2024
Merged

sipsma merged 2 commits into
dagger:mainfrom
shykes:2023-12-improve-dagger-functions

Conversation

@shykes

@shykes shykes commented Dec 22, 2023

Copy link
Copy Markdown
Contributor

Before

dagger functions dumps all functions available in all types for a given module, regardless of arguments. So I can't see what functions are available at a given stage of the pipeline.

Example:

$ dagger -s -m github.com/shykes/daggerverse/wolfi functions
object name                                                         function name   description                                    return type
*Wolfi                                                              base            Initialize a Wolfi base configuration          WolfiConfig!
WolfiConfig                                                         packages                                                       [String!]!
WolfiConfig                                                         overlays                                                       [Container!]!
WolfiConfig                                                         withPackage     At a package to this configuration             WolfiConfig!
WolfiConfig                                                         withPackages    Add a list of packages to this configuration   WolfiConfig!
WolfiConfig                                                         withOverlay     Add an overlay to the current configuration.
See https://twitter.com/ibuildthecloud/status/1721306361999597884   WolfiConfig!
WolfiConfig                                                         container   The container for this configuration   Container!
$ dagger -s -m github.com/shykes/daggerverse/wolfi functions base
object name                                                         function name   description                                    return type
*Wolfi                                                              base            Initialize a Wolfi base configuration          WolfiConfig!
WolfiConfig                                                         packages                                                       [String!]!
WolfiConfig                                                         overlays                                                       [Container!]!
WolfiConfig                                                         withPackage     At a package to this configuration             WolfiConfig!
WolfiConfig                                                         withPackages    Add a list of packages to this configuration   WolfiConfig!
WolfiConfig                                                         withOverlay     Add an overlay to the current configuration.
See https://twitter.com/ibuildthecloud/status/1721306361999597884   WolfiConfig!
WolfiConfig                                                         container   The container for this configuration   Container!

After

dagger functions [PIPELINE] shows only available functions at the given stage of a pipeline of functions. I can use the arguments to see what functions are available at a given stage of the pipeline.

For example:

$ dagger functions -s -m github.com/shykes/daggerverse/wolfi
Name   Description
base   Initialize a Wolfi base configuration
$ dagger functions -s -m github.com/shykes/daggerverse/wolfi base
Name           Description
container      The container for this configuration
overlays       -
packages       -
withOverlay    Add an overlay to the current configuration.
withPackage    At a package to this configuration
withPackages   Add a list of packages to this configuration

@shykes
shykes force-pushed the 2023-12-improve-dagger-functions branch from 1a17947 to 7dd2b50 Compare December 22, 2023 23:32
@shykes
shykes requested review from helderco, jedevc and sipsma December 22, 2023 23:42
@TomChv

TomChv commented Jan 4, 2024

Copy link
Copy Markdown
Member

Tested on my own daggerverse project, works like a charm.

➜  ci git:(main) ✗ dagger functions
✔ dagger functions [0.00s]
┃ Name              Description                                                                                                                       
┃ integrationTest   -                                                                                                                                 
┃ lint              -                                                                                                                                 
┃ publish           -                                                                                                                                 

➜  ci git:(main) ✗ dagger functions integrationTest 
✔ dagger functions [0.00s]
┃ Name       Description                                                                                                                              
┃ minio      -                                                                                                                                        
┃ node       -                                                                                                                                        
┃ postgres   -                                                                                                                                        
┃ redis      -                                                                                                                                        
┃ run        -                                                                                                                                        

However, I noticed that I need to give the exact sub field and not the command field.
Example:

➜  ci git:(main) ✗ dagger functions integration-test
✘ dagger functions ERROR [0.00s]
┃ Error: no function 'integration-test' in object type 'Ci'                                                                                           

However, if I want to call my pipeline, I actually need to provide integration-test node for example.
I think we should be consistent between functions and call and fix that.

@sipsma

sipsma commented Jan 5, 2024

Copy link
Copy Markdown
Contributor

Gonna push some integ test coverage for dagger functions as separate commits here, will fix and add coverage for that issue you found @TomChv

@sipsma
sipsma force-pushed the 2023-12-improve-dagger-functions branch from 7dd2b50 to 696e27e Compare January 5, 2024 07:59
@sipsma
sipsma requested review from helderco and removed request for helderco January 5, 2024 07:59
@shykes

shykes commented Jan 12, 2024

Copy link
Copy Markdown
Contributor Author

Hello! I'm back from break. Anything I should do to get this merged?

@shykes

shykes commented Jan 12, 2024 •

Copy link
Copy Markdown
Contributor Author

However, I noticed that I need to give the exact sub field and not the command field.
[...]
I think we should be consistent between functions and call and fix that.

I agree @TomChv, but this problem is already present in the current version dagger functions, so I propose keeping that improvement for a separate follow-up PR :)

@shykes

shykes commented Jan 13, 2024 •

Copy link
Copy Markdown
Contributor Author

I am trying to rebase this, but getting merge conflicts from #6254 . Trying my best to resolve them...

EDIT: fixed :)

@shykes
shykes force-pushed the 2023-12-improve-dagger-functions branch from 696e27e to 3252438 Compare January 13, 2024 15:08
@shykes
shykes requested review from TomChv and sipsma January 13, 2024 15:09
Signed-off-by: Solomon Hykes <[email protected]>
@shykes
shykes force-pushed the 2023-12-improve-dagger-functions branch from 3252438 to a69e71f Compare January 15, 2024 18:16

@helderco helderco left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's definitely an improvement 👍 but I'm questioning the purpose of dagger functions now.

The initial intent was to:

  • give an overview of all functions provided by a module;
  • add a column to show which verbs are available for each function;

The second one is no longer needed as we're converging back into a single command.

The first one however, I meant to group the functions by object instead of repeating the value in the same column. That would still give an overview without having to hunt via chaining in dagger call xxx --help.

So with chaining here as well, apart from having no hint for the user that it works like this, and after --help gets cleaned up, dagger functions just becomes a piece of --help (just the subcommands section).

I think we should either return it to a single call with an overview (grouped by objects) or remove it in favor of --help, or just dagger call with no args which defaults to --help.

@shykes

shykes commented Jan 15, 2024 •

Copy link
Copy Markdown
Contributor Author

@helderco personally this version of dagger functions is what I was hoping for from the beginning. Basically a more stable, straightforward, unixy version of call —help. It does what’s on the label, no more no less. You can use it in a shell script, etc.

Nothing world-changing, but a good basic command I expect to be there.

@shykes

shykes commented Jan 15, 2024

Copy link
Copy Markdown
Contributor Author

Note, I think we should consider a dagger doc in the style of go doc for more thorough documentation of the module API, its types, etc. That would be a bigger task than this PR, but would complement functions nicely.

@sipsma

sipsma commented Jan 15, 2024

Copy link
Copy Markdown
Contributor

@shykes while you were on vacation I had rebased this on main and added an integration test as a separate commit, but I think it got wiped out with a force push. I'll repush the integ test. Just FYI so we don't overwrite it again 😄

@shykes

shykes commented Jan 15, 2024

Copy link
Copy Markdown
Contributor Author

@shykes while you were on vacation I had rebased this on main and added an integration test as a separate commit, but I think it got wiped out with a force push. I'll repush the integ test. Just FYI so we don't overwrite it again 😄

Sorry about that. I didn’t even think to pull 3d party changes on my PR, just picked up where I left off.

@sipsma

sipsma commented Jan 15, 2024

Copy link
Copy Markdown
Contributor

@shykes while you were on vacation I had rebased this on main and added an integration test as a separate commit, but I think it got wiped out with a force push. I'll repush the integ test. Just FYI so we don't overwrite it again 😄

Sorry about that. I didn’t even think to pull 3d party changes on my PR, just picked up where I left off.

No worries at all, it was an exceptional case while trying to move it forward during holidays so very understandable and everything was in my git history so no harm done 🙂

Pushed that along with fixes needed for the tests to pass (mainly that interface return values were erroring out).

@sipsma
sipsma merged commit 8fb3d16 into dagger:main Jan 15, 2024
zeroware pushed a commit to zeroware/dagger that referenced this pull request Jan 18, 2024
* Improve "dagger functions"

Signed-off-by: Solomon Hykes <[email protected]>

* add integ test coverage and associated fixes to handle interfaces

Signed-off-by: Erik Sipsma <[email protected]>

---------

Signed-off-by: Solomon Hykes <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Co-authored-by: Erik Sipsma <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants