Skip to content

Commit

Permalink
Inject version to correct package
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
  • Loading branch information
alexellis committed Aug 19, 2024
1 parent 31c1515 commit bbf47c6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
5 changes: 0 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
Version := $(shell git describe --tags --dirty)
GitCommit := $(shell git rev-parse HEAD)
LDFLAGS := "-s -w -X github.com/alexellis/kubetrim/pkg.Version=$(Version) -X github.com/alexellis/kubetrim/pkg.GitCommit=$(GitCommit)"
PLATFORM := $(shell ./hack/platform-tag.sh)
SOURCE_DIRS = cmd pkg main.go
export GO111MODULE=on

Expand All @@ -20,10 +19,6 @@ gofmt:
test:
CGO_ENABLED=0 go test $(shell go list ./... | grep -v /vendor/|xargs echo) -cover

.PHONY: e2e
e2e:
CGO_ENABLED=0 go test github.com/alexellis/kubetrim/pkg/get -cover --tags e2e -v

.PHONY: dist
dist:
mkdir -p bin
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
kubetrim
====================================================

Tidy up any old or broken Kubernetes clusters and contexts from your kubeconfig.
Tidy up old Kubernetes clusters from kubeconfig.

kubetrim tries to connect to each cluster in the current kubeconfig file, and removes any that are unreachable, or which error.

Expand Down
13 changes: 5 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"path/filepath"
"time"

"github.com/alexellis/kubetrim/pkg"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
_ "k8s.io/client-go/plugin/pkg/client/auth/azure"
Expand All @@ -22,12 +23,6 @@ import (
)

var (
// Version is the version of the tool
Version = "dev"

// GitCommit is the git commit of the tool
GitCommit = ""

writeFile bool
)

Expand All @@ -36,7 +31,9 @@ func main() {
// set usage:

flag.Usage = func() {
fmt.Printf("kubetrim Copyright Alex Ellis (c) 2024\n\n")

fmt.Printf("kubetrim (%s %s) Copyright Alex Ellis (c) 2024\n\n", pkg.Version, pkg.GitCommit)
fmt.Print("Sponsor Alex on GitHub: https://github.com/sponsors/alexellis\n\n")
fmt.Fprintf(flag.CommandLine.Output(), "Usage of %s:\n", os.Args[0])
fmt.Fprintf(flag.CommandLine.Output(), "kubetrim removes contexts & clusters from your kubeconfig if they are not accessible.\n\n")
fmt.Fprintf(flag.CommandLine.Output(), "Set the kubeconfig file to use through the KUBECONFIG environment variable\n")
Expand All @@ -62,7 +59,7 @@ func main() {
os.Exit(1)
}

fmt.Printf("kubetrim (%s %s) by Alex Ellis \n\nLoaded: %s. Checking..\n", Version, GitCommit, kubeconfig)
fmt.Printf("kubetrim (%s %s) by Alex Ellis \n\nLoaded: %s. Checking..\n", pkg.Version, pkg.GitCommit, kubeconfig)

st := time.Now()
// List of contexts to be deleted
Expand Down
9 changes: 9 additions & 0 deletions pkg/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package pkg

var (
// Version is the version of the tool
Version = "dev"

// GitCommit is the git commit of the tool
GitCommit = ""
)

0 comments on commit bbf47c6

Please sign in to comment.