Skip to content

Commit

Permalink
tidy: update deps and add version flags
Browse files Browse the repository at this point in the history
  • Loading branch information
tinyzimmer committed Oct 29, 2023
1 parent 5416829 commit 4922b98
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ builds:
- -s
- -w
- -X github.com/webmeshproj/webmesh-cni/internal/version.Version={{ .Version }}
- -X github.com/webmeshproj/webmesh-cni/internal/version.Commit={{ .Commit }}
- -X github.com/webmeshproj/webmesh-cni/internal/version.GitCommit={{ .Commit }}
- -X github.com/webmeshproj/webmesh-cni/internal/version.BuildDate={{ .Date }}
goos:
- linux
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
github.com/vishvananda/netlink v1.2.1-beta.2
github.com/webmeshproj/api v0.10.0
github.com/webmeshproj/storage-provider-k8s v0.3.0
github.com/webmeshproj/webmesh v0.15.0
github.com/webmeshproj/webmesh v0.15.2
gopkg.in/yaml.v3 v3.0.1
k8s.io/api v0.28.3
k8s.io/apiextensions-apiserver v0.28.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -842,8 +842,8 @@ github.com/webmeshproj/api v0.10.0 h1:QJU3vj6Zj1pIjuqAb6ZoDwI+07/DWybOzD7XXajemw
github.com/webmeshproj/api v0.10.0/go.mod h1:lFGd4eyG9wr0mQiAJxQDBJ6VwEe5EC0AXKZjTv6ZA3U=
github.com/webmeshproj/storage-provider-k8s v0.3.0 h1:iNc/GklTBN5/nPACzrxoyvY5JxTDAf7UfWlEEVKcupo=
github.com/webmeshproj/storage-provider-k8s v0.3.0/go.mod h1:r9JXAqPK4jvq5M0WNUVr7qTiNRVbJnKXMcG5rN4UDFY=
github.com/webmeshproj/webmesh v0.15.0 h1:TkqWYqKOaIweT1iZrek6EMIx2F1mSqqt/5/i3behEXw=
github.com/webmeshproj/webmesh v0.15.0/go.mod h1:dDvc/YZI4nEuTeoyx1DXsagzDSZ30VDIL7jAF1FbJQg=
github.com/webmeshproj/webmesh v0.15.2 h1:weLVbo7KY2Mm267Z9O8htaB3sp83kExev7YKU7e2i38=
github.com/webmeshproj/webmesh v0.15.2/go.mod h1:dDvc/YZI4nEuTeoyx1DXsagzDSZ30VDIL7jAF1FbJQg=
github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 h1:EKhdznlJHPMoKr0XTrX+IlJs1LH3lyx2nfr1dOlZ79k=
github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1/go.mod h1:8UvriyWtv5Q5EOgjHaSseUEdkQfvwFv1I/In/O2M9gc=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
Expand Down
4 changes: 2 additions & 2 deletions internal/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ import (
// Compile-time variables set by the build script.
var (
Version = "0.0.0"
Commit = "unknown"
GitCommit = "unknown"
BuildDate = "unknown"
)

// GetBuildInfo returns the build-time version information.
func GetBuildInfo() version.BuildInfo {
return version.BuildInfo{
Version: Version,
Commit: Commit,
GitCommit: GitCommit,
BuildDate: BuildDate,
}
}
16 changes: 16 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ limitations under the License.
package main

import (
"fmt"
"os"
"path/filepath"
"runtime"
Expand All @@ -38,6 +39,21 @@ func init() {
func main() {
// We run the entrypoint based on how we were invoked.
version := version.GetBuildInfo()
if len(os.Args) > 1 && os.Args[1] == "version" {
fmt.Println(version.PrettyJSON(func() string {
switch filepath.Base(os.Args[0]) {
case "webmesh":
return "webmesh-cni"
case "webmesh-cni-node", "webmesh-node":
return "webmesh-cni-node"
case "webmesh-cni-install":
return "webmesh-cni-install"
default:
return filepath.Base(os.Args[0])
}
}()))
os.Exit(0)
}
switch filepath.Base(os.Args[0]) {
case "webmesh":
plugin.Main(version)
Expand Down

0 comments on commit 4922b98

Please sign in to comment.