Open jayconrod opened 6 years ago
This would also be useful for bazel-integration-testing's bazel_go_integration_test
This would be very useful also to allow gazelle to generate predefined go_image
and container_push
targets from rules_docker together with go_binary
, instead of having to manually write those.
Any ideas on how to do that? Where to start? I would love to help.
Have you tried
# gazelle:map_kind go_binary go_image @io_bazel_rules_docker//go:image.bzl
I've been using this in my repo for a long time to great success. Where it would have generated a go_binary
it generates a go_image
imported from @io_bazel_rules_docker//go:image.bzl
.
@achew22 I didn't now about that. Worked here, thanks a lot.
About container_push
, do you know if there is a similar approach or for that case we have to manually write on all targets?
What would the container_push
wrap? If you want one next to every go_image
you could make a macro that has the rules_docker
go_image
in addition to a container_push
and then you'd get it at the same time. That said, macros that silently create resources that you probably want to run are suboptimal from a usability standpoint. It's very nice to be able to see all the targets that you care about explicitly listed in a BUILD
.
You could pretty easily put together a Gazelle plugin to create a container_push
automatically for every *_image
that it finds.
Thanks. Yes, that was my goal: to have container_push
next to each go_image
. I will try to write a Gazelle plugin. If I succeed I will post here. It might be useful, because I didn't find anything similar to that atm.
If you're looking for some inspiration, there are a couple of simple plugins that are pretty easy to work through. The easiest is one that makes a filegroup
for every file in the repo[0]. A slightly more involved one is the xlang
[1] that you can use as a sample as well.
[0] https://github.com/bazelbuild/bazel-gazelle/blob/master/internal/language/test_filegroup/lang.go [1] https://github.com/bazelbuild/bazel-gazelle/blob/master/internal/gazellebinarytest/xlang.go
I added a # gazelle:macro
directive in #1986 to allow gazelle to recognize that a macro wraps an underlying rule, but not force all targets to become the macro like map_kind
does.
Migrated from bazelbuild/rules_go#748
Allow people to mark rules as a wrapper for a go rule, so they can be managed by gazelle as if the were the underlying rule. It would be even nicer if you could do this once for an entire rule type rather than per rule. The original example was bazelbuild/rules_docker#119 where go_image is a proxy for go_binary as far as gazelle should be concerned.