File tree Expand file tree Collapse file tree 3 files changed +19
-8
lines changed Expand file tree Collapse file tree 3 files changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -84,6 +84,7 @@ GOOS=linux
84
84
PACKAGE =sigs.k8s.io/node-feature-discovery-operator
85
85
MAIN_PACKAGE =main.go
86
86
BIN =node-feature-discovery-operator
87
+ LDFLAGS = -ldflags "-s -w -X sigs.k8s.io/node-feature-discovery-operator/pkg/version.version=$(VERSION ) "
87
88
88
89
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST ) ) ) )
89
90
@@ -100,7 +101,7 @@ go_mod:
100
101
101
102
# Build binary
102
103
build : go_mod
103
- @GOOS=$(GOOS ) GO111MODULE=on CGO_ENABLED=0 $(GO_CMD ) build -o $(BIN ) $(MAIN_PACKAGE )
104
+ @GOOS=$(GOOS ) GO111MODULE=on CGO_ENABLED=0 $(GO_CMD ) build -o $(BIN ) $(LDFLAGS ) $( MAIN_PACKAGE )
104
105
105
106
# Run against the configured Kubernetes cluster in ~/.kube/config
106
107
run : generate fmt vet manifests
Original file line number Diff line number Diff line change @@ -22,7 +22,6 @@ import (
22
22
"os"
23
23
24
24
_ "k8s.io/client-go/plugin/pkg/client/auth"
25
- "k8s.io/component-base/version"
26
25
"k8s.io/klog/v2"
27
26
28
27
"k8s.io/apimachinery/pkg/runtime"
@@ -34,6 +33,7 @@ import (
34
33
nfdkubernetesiov1 "sigs.k8s.io/node-feature-discovery-operator/api/v1"
35
34
"sigs.k8s.io/node-feature-discovery-operator/controllers"
36
35
"sigs.k8s.io/node-feature-discovery-operator/pkg/utils"
36
+ "sigs.k8s.io/node-feature-discovery-operator/pkg/version"
37
37
// +kubebuilder:scaffold:imports
38
38
)
39
39
Original file line number Diff line number Diff line change 1
1
/*
2
- Copyright 2020 The Kubernetes Authors.
2
+ Copyright 2022 The Kubernetes Authors.
3
3
4
4
Licensed under the Apache License, Version 2.0 (the "License");
5
5
you may not use this file except in compliance with the License.
6
6
You may obtain a copy of the License at
7
7
8
- http://www.apache.org/licenses/LICENSE-2.0
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
9
10
10
Unless required by applicable law or agreed to in writing, software
11
11
distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,7 +16,17 @@ limitations under the License.
16
16
17
17
package version
18
18
19
- var (
20
- // Version tracks the NFD operator release
21
- Version = "0.0.1"
22
- )
19
+ const undefinedVersion string = "undefined"
20
+
21
+ // Must not be const, supposed to be set using ldflags at build time
22
+ var version = undefinedVersion
23
+
24
+ // Get returns the version as a string
25
+ func Get () string {
26
+ return version
27
+ }
28
+
29
+ // Undefined returns if version is at it's default value
30
+ func Undefined () bool {
31
+ return version == undefinedVersion
32
+ }
You can’t perform that action at this time.
0 commit comments