docs/pkg/buildinfo.md
pkg/buildinfo
pkg/buildinfo owns EzAgent's runtime release identity and its embedded
third-party legal-notice report. To classify dependencies or regenerate that
report, see cmd/genlicenses; for the CLI flag that
prints it, see pkg/cli and cmd/ez-agent.
For provider and webfetch user-agent behavior, see
pkg/service/agent and
internal/webfetch.
What is in this package?
| Role | Source |
|---|---|
| Release identity and provider-facing user agent | version.go |
| Embedded report API and generation hook | licenses.go |
| Generated, committed notice artifact with version placeholder | third_party_licenses.txt |
| Package contracts | buildinfo_test.go |
How is release identity formed?
Version in version.go is the single
release-identity value; that file shows the release-build override and
UserAgent(). Do not infer a release pipeline or versioning policy from this
override mechanism.
How does the legal notice reach callers?
The embedding and placeholder substitution live in
licenses.go. Keep the generated artifact
committed and retain the placeholder that ThirdPartyLicenseReport()
substitutes.
Who consumes this information?
| Consumer | Contract |
|---|---|
| CLI | --third-party-licenses prints the report before daemon or configuration work. See pkg/cli. |
| Service providers | Applies the EzAgent user agent after configured extra headers, so configuration cannot silently replace that identity. See pkg/service/agent. |
| Webfetch | --version uses Version; its default user agent uses UserAgent(), but explicit user-agent/header input may override or suppress it. See internal/webfetch. |
For the standalone webfetch command, see
cmd/ez-agent-webfetch.
What must stay true when notices change?
Do not hand-edit the artifact. From the repository root, use just licenses
to refresh it and just licenses-check to verify it. The package's
go generate directive invokes the generator from pkg/buildinfo, with an
output path relative to that directory; do not interchange those command
contexts.
Dependency discovery, classification, legal-file selection, and rendering
policy belong to cmd/genlicenses, not this package.
The generator and its tests enforce a current deterministic artifact, complete
explicit policy, sorted components, and preserved legal-file bytes.
Where are exact rules verified?
- Identity and embedding API:
version.goandlicenses.go. - Report substitution and user-agent contract:
buildinfo_test.go. - Generation policy, artifact freshness, and edge cases:
cmd/genlicenses/main.goandmain_test.go. - CLI offline behavior:
pkg/cli/licenses_test.go. - Provider and webfetch identity behavior:
provider_identity_test.goandheaders_test.go.