mirror of
https://github.com/project-zot/zot.git
synced 2026-06-16 04:17:55 +08:00
version: add commit id to binary during build
This commit is contained in:
@@ -4,6 +4,9 @@ import (
|
||||
dspec "github.com/opencontainers/distribution-spec"
|
||||
)
|
||||
|
||||
//nolint (gochecknoglobals)
|
||||
var Commit string
|
||||
|
||||
type StorageConfig struct {
|
||||
RootDirectory string
|
||||
}
|
||||
@@ -39,6 +42,7 @@ type LogConfig struct {
|
||||
|
||||
type Config struct {
|
||||
Version string
|
||||
Commit string
|
||||
Storage StorageConfig
|
||||
HTTP HTTPConfig
|
||||
Log LogConfig `mapstructure:",omitempty"`
|
||||
@@ -47,6 +51,7 @@ type Config struct {
|
||||
func NewConfig() *Config {
|
||||
return &Config{
|
||||
Version: dspec.Version,
|
||||
Commit: Commit,
|
||||
HTTP: HTTPConfig{Address: "127.0.0.1", Port: "8080"},
|
||||
Log: LogConfig{Level: "debug"},
|
||||
}
|
||||
|
||||
+1
-1
@@ -85,7 +85,7 @@ func NewRootCmd() *cobra.Command {
|
||||
Long: "`zot`",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
if showVersion {
|
||||
log.Info().Str("version", dspec.Version).Msg("distribution-spec")
|
||||
log.Info().Str("distribution-spec", dspec.Version).Str("commit", api.Commit).Msg("version")
|
||||
}
|
||||
_ = cmd.Usage()
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user