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:
commit
6d1aa73ca1
3 changed files with 14 additions and 6 deletions
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue