Add version flag to e2e.test

This commit is contained in:
Davanum Srinivas
2020-03-06 22:52:10 -05:00
parent ab40772439
commit 8f3dfea11f
2 changed files with 11 additions and 0 deletions

View File

@@ -30,6 +30,7 @@ import (
// See https://github.com/kubernetes/kubernetes/issues/74827
// "github.com/onsi/ginkgo"
"k8s.io/component-base/version"
"k8s.io/kubernetes/test/e2e/framework"
"k8s.io/kubernetes/test/e2e/framework/config"
"k8s.io/kubernetes/test/e2e/framework/testfiles"
@@ -68,6 +69,9 @@ func handleFlags() {
}
func TestMain(m *testing.M) {
var versionFlag bool
flag.CommandLine.BoolVar(&versionFlag, "version", false, "Displays version information.")
// Register test flags, then parse flags.
handleFlags()
@@ -85,6 +89,10 @@ func TestMain(m *testing.M) {
}
os.Exit(0)
}
if versionFlag {
fmt.Printf("%s\n", version.Get())
os.Exit(0)
}
framework.AfterReadingAllFlags(&framework.TestContext)