[cmd/builder] Support components whose module source is published as a release artifact
Component(s)
cmd/builder
Is your feature request related to a problem? Please describe.
Some Go modules cannot be compiled from what go get fetches, because part of their
source is generated at build time and intentionally not committed: generated BPF
bindings (bpf2go), embedded artifacts, large codegen outputs. The concrete case today
is go.opentelemetry.io/obi (the OBI receiver)
Describe the solution you'd like
In order to allow such artifacts to be included inside a collector distribution using OCB,
This suggestion allows to fetch the artifact from a source archive instead of using go get
Manifest schema
For example, taking OBI as an example:
receivers:
- import: go.opentelemetry.io/obi/collector # mandatory for archive modules
source_archive:
url: https://github.com/open-telemetry/opentelemetry-ebpf-instrumentation/releases/download/v0.9.0/obi-v0.9.0-source-generated.tar.gz
sha256: 4ac1e7… # exactly one of sha256 / sha256_url
# sha256_url: https://…/releases/download/v0.9.0/SHA256SUMSsource_archive is a standalone module source, mutually exclusive with gomod: a module
is either a Go module reference or an artifact.
import— required; the module path from the archive'sgo.mod, or a package within it. It selects what gets built out of the archive (there is nogomodto default it from).url—https://orfile://sha256— hex digest pinning the archive bytessha256_url— alternatively, a standardsha256sum-format checksum file; the entry matching the archive's filename is usedsubdir— for archives where the module is not at the root.- Mutually exclusive with both
gomodandpath:on the same module.
Several components can be built from one artifact (e.g. a receiver and an extension): declare
each with its own import and an identical source_archive; the archive is fetched once and
the generated go.mod carries a single deduplicated require/replace.identity by digest, so there is no second, divergeable version
claim to keep in sync.
Describe alternatives you've considered
- Generic pre-build hooks in OCB: probably a bad idea to allow custom code execution, plus a lot of overhead
- Commit generated bpf files to github: rejected by OBI sig, after calculation of growing github history size, especially if we keep adding more and more bpf programs and structs
Additional context
Draft implementation: https://github.com/open-telemetry/opentelemetry-collector/pull/15431
Tip
React with to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.
Source: open-telemetry/opentelemetry-collector