Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

Commit

Permalink
Output version information when called directly
Browse files Browse the repository at this point in the history
Include version and commit in output when called without the CNI args.

Signed-off-by: Paul Holzinger <[email protected]>
  • Loading branch information
Luap99 committed Sep 6, 2021
1 parent 73614d4 commit fd05f77
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 234 deletions.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ ifeq ($(GOBIN),)
GOBIN := $(FIRST_GOPATH)/bin
endif

COMMIT_NO ?= $(shell git rev-parse HEAD 2> /dev/null || true)
GIT_COMMIT ?= $(if $(shell git status --porcelain --untracked-files=no),${COMMIT_NO}-dirty,${COMMIT_NO})

LDFLAGS_MACHINE ?= -X main.gitCommit=$(GIT_COMMIT)

all: binaries

validate: install.tools gofmt .gitvalidation lint
Expand All @@ -34,7 +39,7 @@ gofmt:


binaries:
$(GO_BUILD) -o bin/podman-machine github.com/containers/podman-machine-cni/plugins/meta/podman-machine
$(GO_BUILD) -ldflags '$(LDFLAGS_MACHINE)' -o bin/podman-machine github.com/containers/podman-machine-cni/plugins/meta/podman-machine

.PHONY: .gitvalidation
.gitvalidation:
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ go 1.16

require (
github.com/containernetworking/cni v0.8.1
github.com/containernetworking/plugins v0.9.1
)
3 changes: 1 addition & 2 deletions plugins/meta/podman-machine/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"github.com/containernetworking/cni/pkg/skel"
"github.com/containernetworking/cni/pkg/types"
"github.com/containernetworking/cni/pkg/version"
bv "github.com/containernetworking/plugins/pkg/utils/buildversion"
)

func cmdAdd(args *skel.CmdArgs) error {
Expand Down Expand Up @@ -93,7 +92,7 @@ func cmdDel(args *skel.CmdArgs) error {
}

func main() {
skel.PluginMain(cmdAdd, cmdCheck, cmdDel, version.All, bv.BuildString("machine"))
skel.PluginMain(cmdAdd, cmdCheck, cmdDel, version.All, getVersion())
}

func cmdCheck(args *skel.CmdArgs) error {
Expand Down
14 changes: 14 additions & 0 deletions plugins/meta/podman-machine/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package main

import "fmt"

// overwritten at build time
var gitCommit = "unknown"

const machineVersion = "0.1.0-dev"

func getVersion() string {
return fmt.Sprintf(`CNI podman-machine plugin
version: %s
commit: %s`, machineVersion, gitCommit)
}
201 changes: 0 additions & 201 deletions vendor/github.com/containernetworking/plugins/LICENSE

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,3 @@ github.com/containernetworking/cni/pkg/types/020
github.com/containernetworking/cni/pkg/types/current
github.com/containernetworking/cni/pkg/utils
github.com/containernetworking/cni/pkg/version
# github.com/containernetworking/plugins v0.9.1
## explicit
github.com/containernetworking/plugins/pkg/utils/buildversion

0 comments on commit fd05f77

Please sign in to comment.