Add support for displaying git commit in version

Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
This commit is contained in:
Mrunal Patel 2017-09-07 11:27:20 -07:00
parent 6d2b19acbb
commit 0ae21a5f08
2 changed files with 35 additions and 2 deletions

View file

@ -23,6 +23,14 @@ import (
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
)
// This is populated by the Makefile from the VERSION file
// in the repository
var version = ""
// gitCommit is the commit that the binary is being built from.
// It will be populated by the Makefile.
var gitCommit = ""
func validateConfig(config *server.Config) error {
switch config.ImageVolumes {
case libkpod.ImageVolumesMkdir:
@ -161,9 +169,17 @@ func main() {
return
}
app := cli.NewApp()
var v []string
if version != "" {
v = append(v, version)
}
if gitCommit != "" {
v = append(v, fmt.Sprintf("commit: %s", gitCommit))
}
app.Name = "crio"
app.Usage = "crio server"
app.Version = "1.0.0-beta.0"
app.Version = strings.Join(v, "\n")
app.Metadata = map[string]interface{}{
"config": server.DefaultConfig(),
}

View file

@ -5,6 +5,7 @@ import (
"fmt"
"net"
"os"
"strings"
"time"
"github.com/sirupsen/logrus"
@ -13,6 +14,14 @@ import (
pb "k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
)
// This is populated by the Makefile from the VERSION file
// in the repository
var version = ""
// gitCommit is the commit that the binary is being built from.
// It will be populated by the Makefile.
var gitCommit = ""
func getClientConnection(context *cli.Context) (*grpc.ClientConn, error) {
conn, err := grpc.Dial(context.GlobalString("connect"), grpc.WithInsecure(), grpc.WithTimeout(context.GlobalDuration("timeout")),
grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) {
@ -65,9 +74,17 @@ func loadContainerConfig(path string) (*pb.ContainerConfig, error) {
func main() {
app := cli.NewApp()
var v []string
if version != "" {
v = append(v, version)
}
if gitCommit != "" {
v = append(v, fmt.Sprintf("commit: %s", gitCommit))
}
app.Name = "crioctl"
app.Usage = "client for crio"
app.Version = "1.0.0-beta.0"
app.Version = strings.Join(v, "\n")
app.Commands = []cli.Command{
podSandboxCommand,