cmd/kola: Validate --platform argument
We were only catching invalid values when we tried to do something with
them.
@@ -17,6 +17,7 @@ package main
import (
"fmt"
"os"
+ "strings"
"github.com/coreos/mantle/kola"
"github.com/coreos/mantle/sdk"
@@ -26,6 +27,7 @@ var (
outputDir string
kolaPlatform string
defaultTargetBoard = sdk.DefaultBoard()
+ kolaPlatforms = []string{"aws", "gce", "qemu"}
kolaDefaultImages = map[string]string{
"amd64-usr": sdk.BuildRoot() + "/images/amd64-usr/latest/coreos_production_image.bin",
"arm64-usr": sdk.BuildRoot() + "/images/arm64-usr/latest/coreos_production_image.bin",
@@ -43,7 +45,7 @@ func init() {
// general options
sv(&outputDir, "output-dir", "_kola_temp", "Temporary output directory for test data and logs")
- sv(&kolaPlatform, "platform", "qemu", "VM platform: qemu, gce, aws")
+ sv(&kolaPlatform, "platform", "qemu", "VM platform: "+strings.Join(kolaPlatforms, ", "))
root.PersistentFlags().IntVar(&kola.TestParallelism, "parallel", 1, "number of tests to run in parallel")
sv(&kola.TAPFile, "tapfile", "", "file to write TAP results to")
sv(&kola.Options.BaseName, "basename", "kola", "Cluster name prefix")
@@ -77,6 +79,17 @@ func init() {
// Sync up the command line options if there is dependency
func syncOptions() error {
+ ok := false
+ for _, platform := range kolaPlatforms {
+ if platform == kolaPlatform {
+ ok = true
+ break
+ }
+ }
+ if !ok {
+ return fmt.Errorf("unsupport platform %q", kolaPlatform)
+ }
+
image, ok := kolaDefaultImages[kola.QEMUOptions.Board]
if !ok {
return fmt.Errorf("unsupport board %q", kola.QEMUOptions.Board)
