0
Fork 0
mirror of https://github.com/project-zot/zot.git synced 2025-01-20 22:52:51 -05:00

ci/cd:inculde binary type in version information

This commit is contained in:
Shivam Mishra 2021-02-12 16:52:02 -08:00 committed by Ramkumar Chinchani
parent a7c17b7c16
commit cf25c6f3c8
3 changed files with 17 additions and 11 deletions

View file

@ -12,15 +12,15 @@ all: doc binary binary-minimal debug test check
.PHONY: binary-minimal .PHONY: binary-minimal
binary-minimal: doc binary-minimal: doc
go build -tags minimal -v -ldflags "-X github.com/anuvu/zot/pkg/api.Commit=${COMMIT}" -o bin/zot-minimal ./cmd/zot go build -tags minimal -v -ldflags "-X github.com/anuvu/zot/pkg/api.Commit=${COMMIT} -X github.com/anuvu/zot/pkg/api.BinaryType=minimal" -o bin/zot-minimal ./cmd/zot
.PHONY: binary .PHONY: binary
binary: doc binary: doc
go build -tags extended -v -ldflags "-X github.com/anuvu/zot/pkg/api.Commit=${COMMIT}" -o bin/zot ./cmd/zot go build -tags extended -v -ldflags "-X github.com/anuvu/zot/pkg/api.Commit=${COMMIT} -X github.com/anuvu/zot/pkg/api.BinaryType=extended" -o bin/zot ./cmd/zot
.PHONY: debug .PHONY: debug
debug: doc debug: doc
go build -tags extended -v -gcflags all='-N -l' -ldflags "-X github.com/anuvu/zot/pkg/api.Commit=${COMMIT}" -o bin/zot-debug ./cmd/zot go build -tags extended -v -gcflags all='-N -l' -ldflags "-X github.com/anuvu/zot/pkg/api.Commit=${COMMIT} -X github.com/anuvu/zot/pkg/api.BinaryType=extended" -o bin/zot-debug ./cmd/zot
.PHONY: test .PHONY: test
test: test:

View file

@ -8,8 +8,11 @@ import (
dspec "github.com/opencontainers/distribution-spec" dspec "github.com/opencontainers/distribution-spec"
) )
// Commit ... // Global vars...
var Commit string //nolint: gochecknoglobals var (
Commit string // nolint: gochecknoglobals
BinaryType string // nolint: gochecknoglobals
)
type StorageConfig struct { type StorageConfig struct {
RootDirectory string RootDirectory string
@ -72,6 +75,7 @@ type LogConfig struct {
type Config struct { type Config struct {
Version string Version string
Commit string Commit string
BinaryType string
Storage StorageConfig Storage StorageConfig
HTTP HTTPConfig HTTP HTTPConfig
Log *LogConfig Log *LogConfig
@ -80,11 +84,12 @@ type Config struct {
func NewConfig() *Config { func NewConfig() *Config {
return &Config{ return &Config{
Version: dspec.Version, Version: dspec.Version,
Commit: Commit, Commit: Commit,
Storage: StorageConfig{GC: true, Dedupe: true}, BinaryType: BinaryType,
HTTP: HTTPConfig{Address: "127.0.0.1", Port: "8080"}, Storage: StorageConfig{GC: true, Dedupe: true},
Log: &LogConfig{Level: "debug"}, HTTP: HTTPConfig{Address: "127.0.0.1", Port: "8080"},
Log: &LogConfig{Level: "debug"},
} }
} }

View file

@ -88,7 +88,8 @@ func NewRootCmd() *cobra.Command {
Long: "`zot`", Long: "`zot`",
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
if showVersion { if showVersion {
log.Info().Str("distribution-spec", dspec.Version).Str("commit", api.Commit).Msg("version") log.Info().Str("distribution-spec", dspec.Version).Str("commit", api.Commit).
Str("binary-type", api.BinaryType).Msg("version")
} }
_ = cmd.Usage() _ = cmd.Usage()
}, },