Open mauriciovasquezbernal opened 3 months ago
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs.
This issue has been automatically closed due to inactivity. If you believe this was closed in error, please feel free to reopen it.
Some examples of the usage of the Golang API to run image-based gadgets were introduced in #2753. I think we way to specify parameters is confusing for users. See https://github.com/inspektor-gadget/inspektor-gadget/pull/2753#discussion_r1575262388
Issue
Currently the parameters are passed using a
map[string]string
:It's impossible for the users to understand what parameters a gadget or operator support. One solution could be to document the parameters (as #2374), but I still fear that many users won't read it.
Possible solutions
I believe we can improve it by implement Golang structures that define the parameters an operator / gadget / runtime supports.
For operators and runtimes it's not so critical as they're implemented in Go, hence we can expose those structures and use then. For instance, the grpc runtime could expose this:
For gadgets it's a bit more difficult as they don't have a Golang implementation. One solution could be to generate them at build time from the eBPF code or allow the user to manually specify them, however this still requires more exploration.
Another challenge is how to transport those parameters over the wire, currently those are encoded as map<string,string>:
https://github.com/inspektor-gadget/inspektor-gadget/blob/582ab8df8caf64a22753018b891e2f143889ba3a/pkg/gadget-service/api/api.proto#L28-L31
hence we'll need a way to marshal and unmarshal from the struct to and from map[string]string. I think some reflection-based magic could help.