Skip to content

Commit 02e323a

Browse files
committed
Fix updateSolution with empty SolutionUpdateRequest
- Remove default property alwaysPull in SolutionUpdateRequest - fix update mechanism for runTemplates/parameters/parameterGroups on updateSolution
1 parent 98e7d0b commit 02e323a

File tree

4 files changed

+53
-7
lines changed

4 files changed

+53
-7
lines changed

doc/Models/SolutionUpdateRequest.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
| **name** | **String** | The Solution name | [optional] [default to null] |
88
| **description** | **String** | The Solution description | [optional] [default to null] |
99
| **repository** | **String** | The registry repository containing the image | [optional] [default to null] |
10-
| **alwaysPull** | **Boolean** | Set to true if the runtemplate wants to always pull the image | [optional] [default to false] |
10+
| **alwaysPull** | **Boolean** | Set to true if the runtemplate wants to always pull the image | [optional] [default to null] |
1111
| **version** | **String** | The Solution version MAJOR.MINOR.PATCH. Must be aligned with an existing repository tag | [optional] [default to null] |
1212
| **url** | **String** | An optional URL link to solution page | [optional] [default to null] |
1313
| **tags** | **List** | The list of tags | [optional] [default to null] |

solution/src/integrationTest/kotlin/com/cosmotech/solution/service/SolutionServiceIntegrationTest.kt

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,49 @@ class SolutionServiceIntegrationTest : CsmRedisTestBase() {
148148
assertTrue(solutionsFoundAfterDelete.size == 1)
149149
}
150150

151+
@Test
152+
fun `test update solution with empty SolutionUpdateRequest`() {
153+
154+
val solutionKey = "key"
155+
val solutionName = "name"
156+
val solutionDescription = "description"
157+
val solutionVersion = "1.0.0"
158+
val solutionTags = mutableListOf("tag1", "tag2")
159+
val solutionUrl = "url"
160+
val solutionRunTemplates = mutableListOf(RunTemplateCreateRequest(id = "template"))
161+
val solutionParameterGroups =
162+
mutableListOf(RunTemplateParameterGroupCreateRequest(id = "group"))
163+
val solutionRepository = "repository"
164+
165+
val solutionCreateRequest =
166+
SolutionCreateRequest(
167+
key = solutionKey,
168+
name = solutionName,
169+
description = solutionDescription,
170+
version = solutionVersion,
171+
tags = solutionTags,
172+
repository = solutionRepository,
173+
runTemplates = solutionRunTemplates,
174+
parameterGroups = solutionParameterGroups,
175+
parameters =
176+
mutableListOf(
177+
RunTemplateParameterCreateRequest(id = "parameterName", varType = "string")),
178+
security =
179+
SolutionSecurity(
180+
default = ROLE_ADMIN,
181+
accessControlList =
182+
mutableListOf(SolutionAccessControl("user_id", ROLE_ADMIN))),
183+
url = solutionUrl,
184+
alwaysPull = true,
185+
)
186+
val newSolution = solutionApiService.createSolution(organizationSaved.id, solutionCreateRequest)
187+
188+
val solutionUpdated =
189+
solutionApiService.updateSolution(
190+
organizationSaved.id, newSolution.id, SolutionUpdateRequest())
191+
assertEquals(newSolution, solutionUpdated)
192+
}
193+
151194
@TestFactory
152195
fun `sdkVersion on Solution CRUD`() =
153196
mapOf(
@@ -1019,7 +1062,8 @@ class SolutionServiceIntegrationTest : CsmRedisTestBase() {
10191062
alwaysPull = false,
10201063
repository = updatedRepository,
10211064
url = newUrl,
1022-
version = newVersion)
1065+
version = newVersion,
1066+
parameters = mutableListOf())
10231067

10241068
solutionSaved =
10251069
solutionApiService.updateSolution(
@@ -1161,7 +1205,10 @@ class SolutionServiceIntegrationTest : CsmRedisTestBase() {
11611205
alwaysPull = false,
11621206
repository = updatedRepository,
11631207
url = newUrl,
1164-
version = newVersion)
1208+
version = newVersion,
1209+
runTemplates = mutableListOf(),
1210+
parameters = mutableListOf(),
1211+
)
11651212

11661213
solutionSaved =
11671214
solutionApiService.updateSolution(

solution/src/main/kotlin/com/cosmotech/solution/service/SolutionServiceImpl.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,16 +259,16 @@ class SolutionServiceImpl(
259259

260260
val solutionRunTemplateParameters =
261261
solutionUpdateRequest.parameters?.map { convertToRunTemplateParameter(it) }?.toMutableList()
262-
?: mutableListOf()
262+
?: existingSolution.parameters
263263

264264
val solutionRunTemplateParameterGroups =
265265
solutionUpdateRequest.parameterGroups
266266
?.map { convertToRunTemplateParameterGroup(it) }
267-
?.toMutableList() ?: mutableListOf()
267+
?.toMutableList() ?: existingSolution.parameterGroups
268268

269269
val solutionRunTemplates =
270270
solutionUpdateRequest.runTemplates?.map { convertToRunTemplate(it) }?.toMutableList()
271-
?: mutableListOf()
271+
?: existingSolution.runTemplates
272272

273273
val updatedSolution =
274274
Solution(

solution/src/main/openapi/solution.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,6 @@ components:
11011101
alwaysPull:
11021102
type: boolean
11031103
description: Set to true if the runtemplate wants to always pull the image
1104-
default: false
11051104
version:
11061105
type: string
11071106
description: The Solution version MAJOR.MINOR.PATCH. Must be aligned with an existing repository tag

0 commit comments

Comments
 (0)