diff --git a/e2e/aks-runtime/aks_runtime_test.go b/e2e/aks-runtime/aks_runtime_test.go index 63eae4f67..184907501 100644 --- a/e2e/aks-runtime/aks_runtime_test.go +++ b/e2e/aks-runtime/aks_runtime_test.go @@ -25,8 +25,6 @@ import ( const testContainer = "testcontainer" -var imageReplacementsFile, namespaceFile, _platformStr string - func TestAKSRuntime(t *testing.T) { require := require.New(t) @@ -117,9 +115,7 @@ func TestAKSRuntime(t *testing.T) { } func TestMain(m *testing.M) { - flag.StringVar(&imageReplacementsFile, "image-replacements", "", "path to image replacements file") - flag.StringVar(&namespaceFile, "namespace-file", "", "file to store the namespace in") - flag.StringVar(&_platformStr, "platform", "", "Deployment platform") + contrasttest.RegisterFlags() flag.Parse() os.Exit(m.Run()) diff --git a/e2e/genpolicy/genpolicy_test.go b/e2e/genpolicy/genpolicy_test.go index ca8030a71..a030b9572 100644 --- a/e2e/genpolicy/genpolicy_test.go +++ b/e2e/genpolicy/genpolicy_test.go @@ -37,7 +37,7 @@ func TestGenpolicy(t *testing.T) { for name, deploy := range testCases { t.Run(name, func(t *testing.T) { - ct := contrasttest.New(t, imageReplacementsFile, namespaceFile, platform) + ct := contrasttest.New(t) ct.Init(t, kuberesource.PatchRuntimeHandlers([]any{deploy}, runtimeHandler)) @@ -69,9 +69,7 @@ func TestGenpolicy(t *testing.T) { } func TestMain(m *testing.M) { - flag.StringVar(&imageReplacementsFile, "image-replacements", "", "path to image replacements file") - flag.StringVar(&namespaceFile, "namespace-file", "", "file to store the namespace in") - flag.StringVar(&platformStr, "platform", "", "Deployment platform") + contrasttest.RegisterFlags() flag.Parse() os.Exit(m.Run()) diff --git a/e2e/getdents/getdents_test.go b/e2e/getdents/getdents_test.go index 2db0edf56..33c8caa5f 100644 --- a/e2e/getdents/getdents_test.go +++ b/e2e/getdents/getdents_test.go @@ -33,7 +33,7 @@ var imageReplacementsFile, namespaceFile, platformStr string func TestGetDEnts(t *testing.T) { platform, err := platforms.FromString(contrasttest.Flags.PlatformStr) require.NoError(t, err) - ct := contrasttest.New(t, imageReplacementsFile, namespaceFile, platform) + ct := contrasttest.New(t) runtimeHandler, err := manifest.RuntimeHandler(platform) require.NoError(t, err) @@ -86,9 +86,7 @@ func TestGetDEnts(t *testing.T) { } func TestMain(m *testing.M) { - flag.StringVar(&imageReplacementsFile, "image-replacements", "", "path to image replacements file") - flag.StringVar(&namespaceFile, "namespace-file", "", "file to store the namespace in") - flag.StringVar(&platformStr, "platform", "", "Deployment platform") + contrasttest.RegisterFlags() flag.Parse() os.Exit(m.Run()) diff --git a/e2e/internal/contrasttest/contrasttest.go b/e2e/internal/contrasttest/contrasttest.go index ba7c91952..96e13e37d 100644 --- a/e2e/internal/contrasttest/contrasttest.go +++ b/e2e/internal/contrasttest/contrasttest.go @@ -41,7 +41,6 @@ type testFlags struct { ImageReplacementsFile string NamespaceFile string NamespaceSuffix string - SkipUndeploy bool } // RegisterFlags registers the flags that are shared between all tests. @@ -50,7 +49,6 @@ func RegisterFlags() { flag.StringVar(&Flags.NamespaceFile, "namespace-file", "", "file to store the namespace in") flag.StringVar(&Flags.NamespaceSuffix, "namespace-suffix", "", "suffix to append to the namespace") flag.StringVar(&Flags.PlatformStr, "platform", "", "Deployment platform") - flag.BoolVar(&Flags.SkipUndeploy, "skip-undeploy", false, "Skip undeploying the test namespace") } // ContrastTest is the Contrast test helper struct. @@ -79,7 +77,7 @@ func New(t *testing.T) *ContrastTest { WorkDir: t.TempDir(), ImageReplacementsFile: Flags.ImageReplacementsFile, Platform: platform, - NamespaceFile: namespaceFile, + NamespaceFile: Flags.NamespaceFile, Kubeclient: kubeclient.NewForTest(t), } }