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
2
2
3
3
all : push
4
4
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 )
7
8
8
9
PROJ = google_containers
9
10
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')
11
14
12
15
vet :
13
16
go list ./... | grep -v " ./vendor/*" | xargs go vet
14
17
15
18
fmt :
16
19
find . -type f -name " *.go" | grep -v " ./vendor/*" | xargs gofmt -s -w -l
17
20
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
20
28
21
29
test :
22
30
go test -timeout=1m -v -race ./pkg/...
Original file line number Diff line number Diff line change @@ -19,16 +19,20 @@ package main
19
19
import (
20
20
"flag"
21
21
"net/url"
22
+ "os"
22
23
23
24
"k8s.io/node-problem-detector/pkg/kernelmonitor"
24
25
"k8s.io/node-problem-detector/pkg/problemdetector"
26
+ "k8s.io/node-problem-detector/pkg/version"
25
27
26
28
"github.com/golang/glog"
27
29
)
28
30
31
+ // TODO: Move flags to options directory.
29
32
var (
30
33
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" )
32
36
)
33
37
34
38
func validateCmdParams () {
@@ -41,6 +45,11 @@ func main() {
41
45
flag .Parse ()
42
46
validateCmdParams ()
43
47
48
+ if * printVersion {
49
+ version .PrintVersion ()
50
+ os .Exit (0 )
51
+ }
52
+
44
53
k := kernelmonitor .NewKernelMonitorOrDie (* kernelMonitorConfigPath )
45
54
p := problemdetector .NewProblemDetector (k , * apiServerOverride )
46
55
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