Avoid reading empty yaml variable which is not supported by readYaml
Change-Id: Ibea272402c6bc7af18e49df49d24a415f59b07c3
diff --git a/src/com/mirantis/mk/SaltModelTesting.groovy b/src/com/mirantis/mk/SaltModelTesting.groovy
index 3e551f6..a4c90f1 100644
--- a/src/com/mirantis/mk/SaltModelTesting.groovy
+++ b/src/com/mirantis/mk/SaltModelTesting.groovy
@@ -93,17 +93,21 @@
def extraRepoMergeStrategy = config.get('extraRepoMergeStrategy', 'merge')
def extraReposYaml = null
if (extraRepoMergeStrategy == 'merge') {
- def extraReposYamlConfig = config.get('extraReposYaml', '')
- def extraRepos = readYaml text: extraReposYamlConfig
+ def extraReposYamlConfig = config.get('extraReposYaml', '').trim()
def defaultRepos = readYaml text: defaultExtraReposYaml
+ if (extraReposYamlConfig) {
+ def extraRepos = readYaml text: extraReposYamlConfig
- Map.metaClass.mergeNested = { Map rhs ->
- def lhs = delegate
- rhs.each { k, v -> lhs[k] = lhs[k] in Map ? lhs[k].addNested(v) : v }
- lhs
+ Map.metaClass.mergeNested = { Map rhs ->
+ def lhs = delegate
+ rhs.each { k, v -> lhs[k] = lhs[k] in Map ? lhs[k].addNested(v) : v }
+ lhs
+ }
+
+ extraReposYaml = defaultRepos.mergeNested(extraRepos)
+ } else {
+ extraReposYaml = defaultRepos
}
-
- extraReposYaml = defaultRepos.mergeNested(extraRepos)
} else {
extraReposYaml = config.get('extraReposYaml', defaultExtraReposYaml)
}