diff --git a/test/components/util/util.go b/test/components/util/util.go index 7111c63b9..f24d76c2d 100644 --- a/test/components/util/util.go +++ b/test/components/util/util.go @@ -319,3 +319,23 @@ func (p *PortForwardInfo) WaitUntilForwardingAvailable(t *testing.T) { } p.findLocalPort(t) } + +// IsPlatformSupported takes in the test object and the map of supported platform. The function +// detects the supported platform from environment variable. And if the platform is available in the +// supported platforms provided then this returns true otherwise false. +func IsPlatformSupported(t *testing.T, platforms map[string]interface{}) bool { + if _, ok := platforms["*"]; ok { + return true + } + + platform := os.Getenv("PLATFORM") + if platform == "" { + t.Fatalf("env var PLATFORM was not set") + } + + if _, ok := platforms[platform]; !ok { + return false + } + + return true +}