#@Miguel Martinez Trivino love the demo
1 messages ยท Page 1 of 1 (latest)
I need to understand a little bit better returned custom types. Especially because I am not sure how I could use it when there is no chained commands in place
I mean that attestation add , which needs the ID, might happen after some time, in another bash stanza.
For my demo pipeline in go though, I can definitely see the value of the returned custom object
on another hand, yes, download/upload could be a great addition ๐
I'll create an issue for it. Thanks for the feedback!
Here's an example, where I added a custom type while daggerizing our markdown linter:
dagger call -m github.com/dagger/dagger/linters/markdown@pull/6816/head \
lint --source=https://github.com/chainloop-dev/chainloop \
checks \
--help
This will:
- Call our markdown linter against another repo (in this case yours :). Returns a
Reportcustom object - Call
Report.checks()which returns an array ofCheckcustom objects --helpto list available functions inCheck
One available function is format to produce a custom text from the check info:
dagger call -m github.com/dagger/dagger/linters/markdown@pull/6816/head \
lint --source=https://github.com/chainloop-dev/chainloop \
checks \
format --text='The file {{.FileName}} has a markdown lint error at line {{.LineNumber}}'
Another function at the report level, is to get a directory with only the files affected. This will downloads them to your local filesystem:
dagger call -m github.com/dagger/dagger/linters/markdown@pull/6816/head \
lint --source=https://github.com/chainloop-dev/chainloop \
files \
export --path=./linted-markdown-files
Thanks, I'll dig into those examples,
but from top of my head, what if I don't want/can't chain commands (or the commands happen in completely different context). For example, you do dagger call chainloop init, then do some stuff, then dagger call chainloop add,more stuff, another add, and finally push, how can I transfer such custom object, strings are easy to expose but can I still use custom returned objects?
For using it in actual programmable SDKs I can see customObjects being great, but I am wondering what would be interoperability with the CLI, Meaning that I might require chaining commands in that case to make sure state is passed?
but definitely I think push should return a custom object, so people can decide what to do with it, i.e upload it, parse it, conftest it, anything
A common pattern for this, is to have functions in your custom object, that return a new version of the same object. Then you can chain pretty easily. So for example:
dagger call -m chainloop \
init \
add \
add \
push
The CLI supports this out of the box
Often this pattern comes with function names like "withX" but that's just an optional convention
dagger call -m chainloop \
attestation \
with-artifact \
with-artifact \
with-artifact \
push
The CLI does have a gap around "stitching". If you need to make several chains, then pass the output of one chain as argument to another, that works great in code, but not (yet) in the CLI
I see, yeah, my problem is using the CLI without chaining, for example, this is one of the pipelines we are dogfooding (and yes, we could write a go pipeline, but we wanted to check how seamless is to replace the chainloop CLI, the way people use it today, with the dagger module)
as you can see in this example, we have multiple dagger calls, sprawl at different places of the pipeline. and exposing ATTESTATION_ID as string is convenient
Yes, I would still expose the ID, and allow loading from it, so that way you get the best of both
I think it's possible to have your cake and eat it too ๐ Need to go on a call, but will try sending a PR today
In any case your module is already great - any improvement on top of it is a bonus IMO
Oh nice!