Skip to content

Commit c8daabf

Browse files
committed
Keep custom configuration of db components (fix mongodb)
1 parent 912ae0b commit c8daabf

1 file changed

Lines changed: 7 additions & 13 deletions

File tree

src/main/java/com/tsystemsmms/cmcc/cmccoperator/targetstate/DefaultTargetState.java

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
package com.tsystemsmms.cmcc.cmccoperator.targetstate;
1212

13+
import com.tsystemsmms.cmcc.cmccoperator.components.Component;
1314
import com.tsystemsmms.cmcc.cmccoperator.components.ComponentSpecBuilder;
1415
import com.tsystemsmms.cmcc.cmccoperator.components.corba.CAEComponent;
1516
import com.tsystemsmms.cmcc.cmccoperator.components.generic.MongoDBComponent;
@@ -97,7 +98,7 @@ public void convergeDefaultComponents() {
9798
ComponentSpecBuilder.ofType("management-tools")
9899
.withName("initcms")
99100
.withMilestone(Milestone.ContentServerInitialized)
100-
.withArgs(List.of("change-passwords"))
101+
//.withArgs(List.of("change-passwords"))
101102
.build()
102103
));
103104

@@ -159,21 +160,14 @@ public void convergeOverrideResources() {
159160
}
160161

161162
if (cmcc.getSpec().getWith().getDatabases()) {
163+
// If create databese is activated, the components were already created in convergeDefaultComponents(). Now we only need to create the user.
162164
if (cmcc.getSpec().getWith().databaseCreateForKind("mongodb")) {
163-
componentCollection.addAll(List.of(
164-
ComponentSpecBuilder.ofType("mongodb")
165-
.withMilestone(Milestone.DeploymentStarted)
166-
.withExtra(MongoDBComponent.createUsersFromClientSecrets(this))
167-
.build()
168-
));
165+
Optional<Component> mongoDb = componentCollection.getOfTypeAndKind("mongodb", "");
166+
mongoDb.ifPresent(c -> c.getComponentSpec().getExtra().putAll(MongoDBComponent.createUsersFromClientSecrets(this)));
169167
}
170168
if (cmcc.getSpec().getWith().databaseCreateForKind("mysql")) {
171-
componentCollection.addAll(List.of(
172-
ComponentSpecBuilder.ofType("mysql")
173-
.withMilestone(Milestone.DeploymentStarted)
174-
.withExtra(MySQLComponent.createUsersFromClientSecrets(this))
175-
.build()
176-
));
169+
Optional<Component> mysqlDb = componentCollection.getOfTypeAndKind("mysql", "");
170+
mysqlDb.ifPresent(c -> c.getComponentSpec().getExtra().putAll(MySQLComponent.createUsersFromClientSecrets(this)));
177171
}
178172
}
179173

0 commit comments

Comments
 (0)