mirror of
https://github.com/zrepl/zrepl.git
synced 2024-11-25 01:44:43 +01:00
move version info to separate package
This commit is contained in:
parent
ee5445777d
commit
428339e1ad
2
Makefile
2
Makefile
@ -20,7 +20,7 @@ ifndef ZREPL_VERSION
|
||||
$(error cannot infer variable ZREPL_VERSION using git and variable is not overriden by make invocation)
|
||||
endif
|
||||
endif
|
||||
GO_LDFLAGS := "-X github.com/zrepl/zrepl/cmd.zreplVersion=$(ZREPL_VERSION)"
|
||||
GO_LDFLAGS := "-X github.com/zrepl/zrepl/version.zreplVersion=$(ZREPL_VERSION)"
|
||||
|
||||
GO_BUILD := go build -ldflags $(GO_LDFLAGS)
|
||||
|
||||
|
@ -142,7 +142,7 @@ func doControLVersionCmd(cmd *cobra.Command, args []string) {
|
||||
die()
|
||||
}
|
||||
|
||||
var info ZreplVersionInformation
|
||||
var info version.ZreplVersionInformation
|
||||
err = json.NewDecoder(resp.Body).Decode(&info)
|
||||
if err != nil {
|
||||
log.Printf("error unmarshaling response: %s", err)
|
||||
|
@ -20,10 +20,6 @@ import (
|
||||
// Printf(format string, v ...interface{})
|
||||
//}
|
||||
|
||||
var (
|
||||
zreplVersion string // set by build infrastructure
|
||||
)
|
||||
|
||||
type Logger = logger.Logger
|
||||
|
||||
var RootCmd = &cobra.Command{
|
||||
|
@ -3,7 +3,7 @@ package cmd
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/spf13/cobra"
|
||||
"runtime"
|
||||
"github.com/zrepl/zrepl/version"
|
||||
)
|
||||
|
||||
var versionCmd = &cobra.Command{
|
||||
@ -17,26 +17,6 @@ func init() {
|
||||
}
|
||||
|
||||
func doVersion(cmd *cobra.Command, args []string) {
|
||||
fmt.Println(NewZreplVersionInformation().String())
|
||||
fmt.Println(version.NewZreplVersionInformation().String())
|
||||
}
|
||||
|
||||
type ZreplVersionInformation struct {
|
||||
Version string
|
||||
RuntimeGOOS string
|
||||
RuntimeGOARCH string
|
||||
RUNTIMECompiler string
|
||||
}
|
||||
|
||||
func NewZreplVersionInformation() *ZreplVersionInformation {
|
||||
return &ZreplVersionInformation{
|
||||
Version: zreplVersion,
|
||||
RuntimeGOOS: runtime.GOOS,
|
||||
RuntimeGOARCH: runtime.GOARCH,
|
||||
RUNTIMECompiler: runtime.Compiler,
|
||||
}
|
||||
}
|
||||
|
||||
func (i *ZreplVersionInformation) String() string {
|
||||
return fmt.Sprintf("zrepl version=%s GOOS=%s GOARCH=%s Compiler=%s",
|
||||
i.Version, i.RuntimeGOOS, i.RuntimeGOARCH, i.RUNTIMECompiler)
|
||||
}
|
||||
|
31
version/version.go
Normal file
31
version/version.go
Normal file
@ -0,0 +1,31 @@
|
||||
package version
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var (
|
||||
zreplVersion string // set by build infrastructure
|
||||
)
|
||||
|
||||
type ZreplVersionInformation struct {
|
||||
Version string
|
||||
RuntimeGOOS string
|
||||
RuntimeGOARCH string
|
||||
RUNTIMECompiler string
|
||||
}
|
||||
|
||||
func NewZreplVersionInformation() *ZreplVersionInformation {
|
||||
return &ZreplVersionInformation{
|
||||
Version: zreplVersion,
|
||||
RuntimeGOOS: runtime.GOOS,
|
||||
RuntimeGOARCH: runtime.GOARCH,
|
||||
RUNTIMECompiler: runtime.Compiler,
|
||||
}
|
||||
}
|
||||
|
||||
func (i *ZreplVersionInformation) String() string {
|
||||
return fmt.Sprintf("zrepl version=%s GOOS=%s GOARCH=%s Compiler=%s",
|
||||
i.Version, i.RuntimeGOOS, i.RuntimeGOARCH, i.RUNTIMECompiler)
|
||||
}
|
Loading…
Reference in New Issue
Block a user