refactor(build): move build metadata to pkg/buildinfo (#4045)

Keep CLI binaries from importing pkg/api/config just for version strings by
centralizing Commit/ReleaseTag/BinaryType/GoVersion in a tiny buildinfo package.
Update ldflags targets and callers accordingly.

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
This commit is contained in:
Andrei Aaron
2026-05-08 19:37:04 +03:00
committed by GitHub
parent fa92366009
commit b89d10834c
7 changed files with 48 additions and 33 deletions
+3 -3
View File
@@ -7,7 +7,7 @@ import (
distspec "github.com/opencontainers/distribution-spec/specs-go"
"github.com/spf13/cobra"
"zotregistry.dev/zot/v2/pkg/api/config"
"zotregistry.dev/zot/v2/pkg/buildinfo"
"zotregistry.dev/zot/v2/pkg/log"
)
@@ -28,8 +28,8 @@ func NewPerfRootCmd() *cobra.Command {
Run: func(cmd *cobra.Command, args []string) {
if showVersion {
logger := log.NewLogger("info", "")
logger.Info().Str("distribution-spec", distspec.Version).Str("commit", config.Commit).
Str("binary-type", config.BinaryType).Str("go version", config.GoVersion).Msg("version")
logger.Info().Str("distribution-spec", distspec.Version).Str("commit", buildinfo.Commit).
Str("binary-type", buildinfo.BinaryType).Str("go version", buildinfo.GoVersion).Msg("version")
}
if len(args) == 0 {