|
10 | 10 |
|
11 | 11 | package com.tsystemsmms.cmcc.cmccoperator.targetstate; |
12 | 12 |
|
| 13 | +import com.tsystemsmms.cmcc.cmccoperator.components.Component; |
13 | 14 | import com.tsystemsmms.cmcc.cmccoperator.components.ComponentSpecBuilder; |
14 | 15 | import com.tsystemsmms.cmcc.cmccoperator.components.corba.CAEComponent; |
15 | 16 | import com.tsystemsmms.cmcc.cmccoperator.components.generic.MongoDBComponent; |
@@ -97,7 +98,7 @@ public void convergeDefaultComponents() { |
97 | 98 | ComponentSpecBuilder.ofType("management-tools") |
98 | 99 | .withName("initcms") |
99 | 100 | .withMilestone(Milestone.ContentServerInitialized) |
100 | | - .withArgs(List.of("change-passwords")) |
| 101 | + //.withArgs(List.of("change-passwords")) |
101 | 102 | .build() |
102 | 103 | )); |
103 | 104 |
|
@@ -159,21 +160,14 @@ public void convergeOverrideResources() { |
159 | 160 | } |
160 | 161 |
|
161 | 162 | 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. |
162 | 164 | 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))); |
169 | 167 | } |
170 | 168 | 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))); |
177 | 171 | } |
178 | 172 | } |
179 | 173 |
|
|
0 commit comments