Add output values to plan#1486
Add output values to plan#1486helderco wants to merge 1 commit intodagger:mainfrom helderco:output-values
Conversation
|
@aluzzardi There's still a FIXME about writing to stdout when using the tty logger, which comes from pre-europa: Lines 106 to 111 in a6330f8 How should this be properly fixed? |
|
Thanks a lot @helderco, this is great! I'll do a proper review tomorrow, I have a couple of suggestions on how to handle output printing |
|
Hey @helderco, I have an overall architecture suggestion regarding this feature. This is up for debate, I can be convinced otherwise:
Doing it this make makes it so that:
Happy to hear your thoughts about this, either here or live on Discord. |
|
Hey @aluzzardi, I'm totally on board with all of this. Thanks for the tip about plancontext, I like that. I just rather not have tasks write to values automatically because to me, the best about this is to have full control (as a user) over what gets output. See #566 about intermediary outputs, which I've always found annoying. So I'd rather reference something I need from About viper, that makes total sense, I wasn't entirely sure where to put that code, just that I wanted to keep it separate. I wanted to make this a task initially, but as far as I'm aware, tasks are matched by the dagger.#Plan & {
outputs: values: {
value1: contents: "value1"
value1: contents: "value2"
}
}Instead of dagger.#Plan & {
outputs: values: {
value1: "value1"
value1: "value2"
}
}That's the whole reason I implemented it like this. If you look at how #1351 was originally, it had a contents, but @shykes suggested (hidden comment):
Still, I do think the task approach is much better. I can migrate to a task anyway, adding the contents convention, and we can track a possible simplification down the line, that benefits not only this task but others. The downside is changing config for users if we do remove contents. WDYT? 🙂 |
Yep, makes sense to me!
Yes indeed. There's two options, either moving that code into p, err := plan.Load(ctx, plan.Config{
Args: args,
With: viper.GetStringSlice("with"),
Target: viper.GetString("target"),
})Here for instance
You're right, I missed that! Indeed it's not possible with the current DX. @shykes Thoughts on this? For context, it's about the 2 options you cited (mentioned in #1486 (comment)). The TL;DR: is: if we were to use |
I’m fine with it. A few notes though:
|
That's what I keep thinking.
I think this can be done without relying on path, but it needs to be done with a definition instead: _#outputValue: {
#dagger: _task: name: "OutputValue"
_
}
outputs: values: [string]: _#outputValue
outputs: values: foo: "bar"Pros:
Cons:
I'm good with this. |
You're right -- that's definitely an option we could consider instead. It's quite some work but we could go ahead with this PR as is (without
Yeah, It boils down to this -- is having
Indeed, but since it requires changing |
Argh, this is a difficult decision. Not so much whether to change
I can think of potentially exciting ways to use extra fields - for example to specify how to render a web component for a given parameter or value :) But is it worth the extra verbosity? I can’t tell right now. Can someone try this in a real or realistic configuration? @gerhard @jlongtine @talentedmrjones in changelog.com for example? How does it feel it we make this change? |
I don't think the consistency principle necessarily applies quite in this way. Consistency says that I look for the |
Those fields do exist, though. You do have to reference Input Params/ output values are different from secrets and directories, because the contents consumed and produced in the DAG are directly exposed to the user. Because of that difference, we can justify skipping the |
|
✔️ Deploy Preview for devel-docs-dagger-io ready! 🔨 Explore the source changes: d3e9c10 🔍 Inspect the deploy log: https://app.netlify.com/sites/devel-docs-dagger-io/deploys/6213d43fb455160008bacffc 😎 Browse the preview: https://deploy-preview-1486--devel-docs-dagger-io.netlify.app |
|
Ping on this one We have found ways to support either approach (with or without It's a matter of picking the right DX -- I've no opinion on the matter, anyone with a strong opinion either way, @shykes @helderco @talentedmrjones? |
This is outside of my top 3 items currently, but I've taken a mental note to circle back if it's still relevant by the time my cache clears. |
|
Picking this up. As a reminder, we must choose between two options:
At this point I think we should go with option 1.
This would be my preference. Benefits:
|
|
SGTM, let's go ahead with this PR then |
|
I meant to reply, but I've been really busy as you can imagine 🙂 @shykes summed up my thoughts fully. There's still the issue with the logger that needs to be fixed. @aluzzardi, do you have an ideia how it should be fixed? Do you want to merge this and track the logging issue in another PR? I can look into it some more on monday. |
I think that it would be best to leave this one for Monday, no rush. I am keen to test it in the context of https://github.com/dagger/dagger/blob/main/pkg/universe.dagger.io/examples/changelog.com/main.cue, as @shykes was suggesting. Looking forward to it 👍🏻 |
|
@helderco Either we print the table using the logger (I believe we can use the logger as a |
|
Yes, I already had this working yesterday. I'm just logging to Info(), which works well in all cases as far as I'm aware. I'll add a doc page later. |
|
@aluzzardi @shykes, as I said, it's easier to just log to info instead of writing directly to stdout. It works fine for my use case, but it breaks the use case of piping into So this doesn't work: $ dagger up --output-format json | jq '.build'But you can still save into a file: $ dagger up --output-format json --output state.json
$ jq '.build' state.jsonTo support piping outputs:
Is the convenience of piping worth the added complexity?
|
Signed-off-by: Helder Correia <[email protected]>
|
I defer to @aluzzardi on this one. No strong opinion. |
|
This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
|
I came across this via GitHub notifications. What are your latest thoughts on this @helderco? |
|
With Client API (#1668), we have yet to discuss the future of this feature. I asked about this and @shykes replied:
Originally posted in #1597 (comment) Also discussed in the counterpart params. |
|
This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
|
This no longer applies with
Thank you @helderco for carrying this alongside #1668 , even though it didn't get merged, it helped us get to a solution. |
Closes #1351
Signed-off-by: Helder Correia
/cc @aluzzardi
Why
Sometimes you want to show a few generated values at the end of the execution. This isn't available in Europa yet, and before that, there's probably outputs you didn't care about.
What
Added
outputs: valuesto the plan to present referenced values at the end, or save them into a file.How
If you're building an image, you may want to to get the new pushed reference, with digest:
Which outputs:
Or you can save to a file and work with that:
$ dagger up --output-format json --output state.json $ jq '.build' state.json registry.example.net/repo:build@sha256:1b2bd4200d734dd3fb819faf21b9352f973f67c55cc8d59addeafc602835461a