Skip to content

Commit

Permalink
lvh: add version sub-command
Browse files Browse the repository at this point in the history
Signed-off-by: Kornilios Kourtis <[email protected]>
  • Loading branch information
kkourt committed Jan 30, 2024
1 parent e1c8135 commit ed24dee
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ GO ?= go

OCIREPO ?= quay.io/lvh-images/lvh
DOCKER ?= docker
VERSION ?= $(shell git describe --tags --always --long)

GO_BUILD_LDFLAGS =
GO_BUILD_LDFLAGS += -X 'github.com/cilium/little-vm-helper/pkg/version.Version=$(VERSION)'
GO_BUILD_FLAGS += -ldflags "$(GO_BUILD_LDFLAGS)"


all: tests little-vm-helper

Expand All @@ -10,7 +16,7 @@ tests:
$(GO) test -cover ./...

little-vm-helper: FORCE
CGO_ENABLED=0 $(GO) build ./cmd/lvh
CGO_ENABLED=0 $(GO) build $(GO_BUILD_FLAGS) ./cmd/lvh

.PHONY: image
image:
Expand Down
9 changes: 9 additions & 0 deletions cmd/lvh/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
package main

import (
"fmt"
"os"

"github.com/cilium/little-vm-helper/cmd/lvh/images"
"github.com/cilium/little-vm-helper/cmd/lvh/kernels"
"github.com/cilium/little-vm-helper/cmd/lvh/runner"
"github.com/cilium/little-vm-helper/pkg/version"

"github.com/spf13/cobra"
)
Expand All @@ -26,6 +28,13 @@ func init() {
images.ImagesCommand(),
kernels.KernelsCommand(),
runner.RunCommand(),
&cobra.Command{
Use: "version",
Short: "version",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println(version.Version)
},
},
)
}

Expand Down
6 changes: 6 additions & 0 deletions pkg/version/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Cilium

package version

var Version string

0 comments on commit ed24dee

Please sign in to comment.