theoremlp / rules_multitool

Bazel rules for ergonomic tool definitions
Apache License 2.0
24 stars 6 forks source link

Consider support for pulling multiple tools out of one archive or pkg #24

Open mark-thm opened 8 months ago

mark-thm commented 8 months ago

Sometimes, several applicable tools come packaged in the same archive.

@andyscott mentioned in https://github.com/theoremlp/rules_multitool/pull/22#issuecomment-2011165507:

As a heads up since you're going to be thinking about the schema: I was planning to open another PR to add add support for multiple binaries from a single archive. E.g. the envtest suite from https://kubebuilder-tools.storage.googleapis.com/kubebuilder-tools-1.27.1-darwin-amd64.tar.gz contains:

kubebuilder/bin/etcd
kubebuilder/bin/kube-apiserver
kubebuilder/bin/kubectl

Currently, our environment repos have a layout of something like:

tools/{tool_name}/{os}_{cpu}_archive/
tools/{tool_name}/{os}_{cpu}_executable -> symlink to a file in archive

We could consider updating the layout to something like:

archives/{archive_alias}/
archives/BUILD.bazel # export all dirs
tools/{tool_name}/{os}_{cpu}_executable -> symlink to a file in archive

Which would better support this particular use-case.

It's not obvious whether {archive_alias} should be the filename, filename+sha256, or a user-supplied value in the lockfile. We could add a new 'reference-archive' binary kind that depends on the alias, or we could tie together archives automatically. The specifics here need a bit more of a plan, but something of this shape is probably a thing we'd be willing to adopt in the repo.