#Generate Magefile from any dagger Go project?

1 messages · Page 1 of 1 (latest)

tame jasper
#

Here’s a puzzle for my Go SDK experts. I would love to be able to write a tool that, given a Go package that imports the Dagger Go SDK, can generate a Mage file. Currently that’s not possible because the Go SDK lets you call queries, but not register them in such a way that they can be inspected. I’m wondering how the Go SDK could add that capability. Kind of similar to a named operations file (foo.gql) but in Go.

Thoughts?

mortal crater
#

The idea would be to automatically create a magefile.go with automatically created target that can be called from the mage CLI? Based on what was used from the Dagger SDK for Go?

inner pecan
#

👋 had a similar thought to Tanguy here, what's the use-case that you have in mind? A Go package could potentially be using the Dagger SDK for multiple things. What do you see the Mage file containing after that generation?

tame jasper
#

For example if I have a build, test and deploy pipeline in my code, the magefile would have Build, Test and Deploy targets so I can call eg. mage build

inner pecan
#

Question is: how can we extract those build, test and deploy targets? In the case of Go, are those coming from Go functions? or each Dagger pipeline (concatenation of SDK builder calls) gets it's on Mage target?

tame jasper
#

That’s my question 🙂

inner pecan
#

I guess writing a Mage codegen that finds Public functions / structs with public methods that are using the dagger SDK and extract those to Mage targets shouldn't be that difficult using Go's AST lib