Fixed kitchen env filter function
Change-Id: Ifc7c69ff7e4e124af61e92ed1a87b3936bbc1ef3
diff --git a/src/com/mirantis/mk/Ruby.groovy b/src/com/mirantis/mk/Ruby.groovy
index cd68371..3988e90 100644
--- a/src/com/mirantis/mk/Ruby.groovy
+++ b/src/com/mirantis/mk/Ruby.groovy
@@ -79,4 +79,21 @@
}else{
return sh(script: "rbenv exec bundler exec kitchen ${cmd}", returnStdout: true)
}
+}
+
+/**
+ * Filters given kitchen env lists for forbidden env properties
+ * @param input list of kitchenEnvs
+ * @param cleanRegex regex will be used for env cleaning (default removing SUITE=* properties)
+ * @return filtered env list
+ */
+def filterKitchenEnvs(inputEnvs = [], cleanRegex = "\\s?SUITE\\=[^\\s]*") {
+ def output = []
+ for(int i=0; i<inputEnvs.size(); i++) {
+ def cleanEnv = inputEnvs[i].replaceAll(cleanRegex, "")
+ if(cleanEnv != "") {
+ output.add(cleanEnv.trim())
+ }
+ }
+ return output
}
\ No newline at end of file