1
0
Fork 0
mirror of https://github.com/kubernetes-sigs/node-feature-discovery.git synced 2024-12-14 11:57:51 +00:00

Merge pull request #298 from marquiz/devel/version

version: allow undefined version
This commit is contained in:
Kubernetes Prow Robot 2020-03-24 09:46:48 -07:00 committed by GitHub
commit 6d1aa73ca1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 6 deletions

View file

@ -35,8 +35,8 @@ const (
func main() {
// Assert that the version is known
if version.Get() == "undefined" {
log.Fatalf("version not set! Set -ldflags \"-X sigs.k8s.io/node-feature-discovery/pkg/version.version=`git describe --tags --dirty --always`\" during build or run.")
if version.Undefined() {
log.Print("WARNING: version not set! Set -ldflags \"-X sigs.k8s.io/node-feature-discovery/pkg/version.version=`git describe --tags --dirty --always`\" during build or run.")
}
// Parse command-line arguments.

View file

@ -34,8 +34,8 @@ const (
func main() {
// Assert that the version is known
if version.Get() == "undefined" {
log.Fatalf("version not set! Set -ldflags \"-X sigs.k8s.io/node-feature-discovery/pkg/version.version=`git describe --tags --dirty --always`\" during build or run.")
if version.Undefined() {
log.Printf("WARNING: version not set! Set -ldflags \"-X sigs.k8s.io/node-feature-discovery/pkg/version.version=`git describe --tags --dirty --always`\" during build or run.")
}
// Parse command-line arguments.

View file

@ -16,9 +16,17 @@ limitations under the License.
package version
// Must not be const, supposed to be set using ldflags at build time
var version = "undefined"
const undefinedVersion string = "undefined"
// Must not be const, supposed to be set using ldflags at build time
var version = undefinedVersion
// Get returns the version as a string
func Get() string {
return version
}
// Undefined returns if version is at it's default value
func Undefined() bool {
return version == undefinedVersion
}