Skip to content

Commit 5c9e561

Browse files
michel-guillonjreynard-code
authored andcommitted
Set the dependencies correctly if the previous container steps have been stacked
1 parent 826c977 commit 5c9e561

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

scenariorun/src/main/kotlin/com/cosmotech/scenariorun/ContainerFactory.kt

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,25 +1624,48 @@ internal fun getCommonEnvVars(
16241624
return (minimalEnvVars + commonEnvVars).toMutableMap()
16251625
}
16261626

1627+
private fun getNewDependenciesIfExist(
1628+
mergedContainerNames: MutableMap<String, String>,
1629+
container: ScenarioRunContainer
1630+
): ScenarioRunContainer {
1631+
var tmp: ScenarioRunContainer = container
1632+
var dependencies: MutableList<String> = mutableListOf()
1633+
container.dependencies?.forEach {
1634+
if (mergedContainerNames.containsKey(it)) {
1635+
dependencies.add(mergedContainerNames.get(it)!!)
1636+
}
1637+
}
1638+
if (dependencies.isNotEmpty()) {
1639+
tmp = container.copy(dependencies = dependencies)
1640+
}
1641+
return tmp
1642+
}
1643+
16271644
private fun stackSolutionContainers(
16281645
containers: MutableList<ScenarioRunContainer>
16291646
): MutableList<ScenarioRunContainer> {
16301647
val stackedContainers: MutableList<ScenarioRunContainer> = mutableListOf()
16311648
var stackedContainer: ScenarioRunContainer? = null
16321649
var stackedIndex = 1
1650+
val mergedContainerNames: MutableMap<String, String> = mutableMapOf()
16331651
for (container in containers) {
16341652
if (container.solutionContainer != true) {
1653+
var tmpContainer: ScenarioRunContainer = container
16351654
if (stackedContainer != null) {
16361655
stackedContainers.add(stackedContainer)
1656+
tmpContainer = container.copy(dependencies = mutableListOf(stackedContainer.name))
16371657
stackedIndex++
16381658
}
16391659
stackedContainer = null
1640-
stackedContainers.add(container)
1660+
stackedContainers.add(tmpContainer)
16411661
} else {
16421662
if (stackedContainer == null) {
1643-
stackedContainer = container
1663+
stackedContainer = getNewDependenciesIfExist(mergedContainerNames, container)
16441664
} else {
1665+
val previousStackedContainer = stackedContainer
16451666
stackedContainer = mergeSolutionContainer(stackedIndex, stackedContainer, container)
1667+
mergedContainerNames[previousStackedContainer.name] = stackedContainer.name
1668+
mergedContainerNames[container.name] = stackedContainer.name
16461669
}
16471670
}
16481671
}

0 commit comments

Comments
 (0)