#How to add examples to modules on Daggerverse
1 messages · Page 1 of 1 (latest)
Not sure if we have docs for this (@midnight rain). A good example is in this module: https://github.com/marcosnils/daggerverse/tree/main/k3s (https://github.com/marcosnils/daggerverse/tree/main/k3s/examples/go).
Within examples folder you create a module with the name of the language you want to target. And within there you create functions whose name has the name of the object + name of the function. If your module is named K3S and you function is named Kubectl then the function name in the example is K3SKubectl
I think there's a recent issue where examples are not being populated correctly. cc @brazen dust @feral hare. We'll check it out this week @sterile snow
Yes, I'd like to present bash examples too. Thanks for patience on the examples system. Still experimental, but hopefully we can get it well-stabilized and documented soon 🙏
Thanks for your help!
I also wrote a function to help bootstrap examples for a module in my mdk module https://daggerverse.dev/mod/github.com/kpenfound/dagger-modules/mdk@602849d50004c90fccc05b7f9e7d3d87c6f4126e but it looks like that's broken at the moment too 🧨 checking it out
hey @sterile snow I thought we had an issue with the example parsing but it seems to be running ok. Can you share which examples / module are giving you a hard time to check it out?
@midnight rain thanks for checking. It is this module: https://daggerverse.dev/mod/github.com/puzzle/dagger-module-helm/helm@484f7b65de88ec8f801df74711d5e0c48448438f
I do not see my go examples. The examples on main are combined with tests. Therefore i made the examples branch, where we split examples and tests.
hey @sterile snow can you check if publishing a new version of the module fixes this issue? Found out that we had a bug which was preventing your examples from being correctly parsed 🙏
@midnight rain Thanks for your fix. Unfortunately it did work for my module.
v1.0.5 does not show my examples: https://daggerverse.dev/mod/github.com/puzzle/dagger-module-helm/helm@484f7b65de88ec8f801df74711d5e0c48448438f
I generated a new Dagger module with dagger init. This new structure does not have a special directory for the source.
Here, the examples show up again: https://daggerverse.dev/mod/github.com/puzzle/dagger-module-helm/helm@97290e37e1a03393d51aea01a86c8d57f0db214d#Helm.version
See the changes in the pull request: https://github.com/puzzle/dagger-module-helm/pull/41
I assume that the examples parsing had problems because of the module source not lying beside the dagger.json file.
👋 checking this now
@sterile snow just re-published your module and seems to be working now: https://daggerverse.dev/mod/github.com/puzzle/dagger-module-helm/helm@484f7b65de88ec8f801df74711d5e0c48448438f
LMK if that works 🙏
Thanks @midnight rain ! The examples are shown now.
I'll add other sdk examples.
How can I define Shell examples? Adding any Shell Script file with the right naming convention for the method names?
An other option would be to show the default examples for sdk's where no examples are found in the repository.