File tree Expand file tree Collapse file tree 3 files changed +47
-7
lines changed Expand file tree Collapse file tree 3 files changed +47
-7
lines changed Original file line number Diff line number Diff line change 1- .PHONY : all container push clean node-problem-detector vet fmt
1+ .PHONY : all container push clean node-problem-detector vet fmt version
22
33all : push
44
5- # See node-problem-detector.yaml for the version currently running-- bump this ahead before rebuilding!
6- TAG = v0.2
5+ VERSION := $(shell git describe --tags --dirty)
6+
7+ TAG ?= $(VERSION )
78
89PROJ = google_containers
910
10- PKG_SOURCES := $(shell find pkg -name '* .go')
11+ PKG := k8s.io/node-problem-detector
12+
13+ PKG_SOURCES := $(shell find pkg cmd -name '* .go')
1114
1215vet :
1316 go list ./... | grep -v " ./vendor/*" | xargs go vet
1417
1518fmt :
1619 find . -type f -name " *.go" | grep -v " ./vendor/*" | xargs gofmt -s -w -l
1720
18- node-problem-detector : $(PKG_SOURCES ) node_problem_detector.go fmt vet
19- GOOS=linux go build -ldflags ' -w -extldflags "-static"' -o node-problem-detector
21+ version :
22+ @echo $(VERSION )
23+
24+ node-problem-detector : $(PKG_SOURCES ) fmt vet
25+ GOOS=linux go build -o node-problem-detector \
26+ -ldflags ' -w -extldflags "-static" -X $(PKG)/pkg/version.version=$(VERSION)' \
27+ cmd/node_problem_detector.go
2028
2129test :
2230 go test -timeout=1m -v -race ./pkg/...
Original file line number Diff line number Diff line change @@ -19,16 +19,20 @@ package main
1919import (
2020 "flag"
2121 "net/url"
22+ "os"
2223
2324 "k8s.io/node-problem-detector/pkg/kernelmonitor"
2425 "k8s.io/node-problem-detector/pkg/problemdetector"
26+ "k8s.io/node-problem-detector/pkg/version"
2527
2628 "github.com/golang/glog"
2729)
2830
31+ // TODO: Move flags to options directory.
2932var (
3033 kernelMonitorConfigPath = flag .String ("kernel-monitor" , "/config/kernel-monitor.json" , "The path to the kernel monitor config file" )
31- apiServerOverride = flag .String ("apiserver-override" , "" , "custom URI used to connect to Kubernetes ApiServer" )
34+ apiServerOverride = flag .String ("apiserver-override" , "" , "Custom URI used to connect to Kubernetes ApiServer" )
35+ printVersion = flag .Bool ("version" , false , "Print version information and quit" )
3236)
3337
3438func validateCmdParams () {
@@ -41,6 +45,11 @@ func main() {
4145 flag .Parse ()
4246 validateCmdParams ()
4347
48+ if * printVersion {
49+ version .PrintVersion ()
50+ os .Exit (0 )
51+ }
52+
4453 k := kernelmonitor .NewKernelMonitorOrDie (* kernelMonitorConfigPath )
4554 p := problemdetector .NewProblemDetector (k , * apiServerOverride )
4655 p .Run ()
Original file line number Diff line number Diff line change 1+ /*
2+ Copyright 2016 The Kubernetes Authors.
3+ Licensed under the Apache License, Version 2.0 (the "License");
4+ you may not use this file except in compliance with the License.
5+ You may obtain a copy of the License at
6+ http://www.apache.org/licenses/LICENSE-2.0
7+ Unless required by applicable law or agreed to in writing, software
8+ distributed under the License is distributed on an "AS IS" BASIS,
9+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+ See the License for the specific language governing permissions and
11+ limitations under the License.
12+ */
13+
14+ package version
15+
16+ import "fmt"
17+
18+ // version defines the version
19+ var version string = "UNKNOWN"
20+
21+ func PrintVersion () {
22+ fmt .Println (version )
23+ }
You can’t perform that action at this time.
0 commit comments