Skip to content

Commit

Permalink
Add namespace override for testplan
Browse files Browse the repository at this point in the history
When the testplan is already provided and contains a namespace that is
not available in the current cluster, a manual change in the testplan
would be required. It would be easier if an override using a command
line flag could take precedence over the configuration file.

Add flag `namespace` to override the namespace defined in the testplan.
  • Loading branch information
HeavyWombat committed Oct 22, 2020
1 parent 6811b0a commit a89ad41
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/cmd/buildrun-testplan.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
)

var buildRunTestplanCmdSettings struct {
namespace string
testplanPath string
}

Expand Down Expand Up @@ -80,6 +81,11 @@ var buildRunTestplanCmd = &cobra.Command{
return err
}

// Override testplan namespace if command line flag namespace is used
if len(buildRunTestplanCmdSettings.namespace) > 0 {
testplan.Namespace = buildRunTestplanCmdSettings.namespace
}

return load.ExecuteTestPlan(*kubeAccess, *testplan)
},
}
Expand All @@ -90,6 +96,7 @@ func init() {
buildRunTestplanCmd.Flags().SortFlags = false
buildRunTestplanCmd.PersistentFlags().SortFlags = false

buildRunTestplanCmd.Flags().StringVar(&buildRunTestplanCmdSettings.namespace, "namespace", "", "namespace to run tests in (takes precedence over namespace in testplan YAML)")
buildRunTestplanCmd.Flags().StringVar(&buildRunTestplanCmdSettings.testplanPath, "testplan", "", "testplan configuration file")

cobra.MarkFlagRequired(buildRunTestplanCmd.Flags(), "testplan")
Expand Down

0 comments on commit a89ad41

Please sign in to comment.