Skip to content

Commit 2fbdb31

Browse files
authored
fix(dryrun): Require converge reason (#3)
1 parent 665b2c7 commit 2fbdb31

File tree

5 files changed

+37
-34
lines changed

5 files changed

+37
-34
lines changed

keel-core/src/main/kotlin/com/netflix/spinnaker/keel/IntentProcessor.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ interface IntentProcessor<in I : Intent<IntentSpec>> {
2525
}
2626

2727
enum class ConvergeReason(val reason: String) {
28-
UNCHANGED("System state matches desired state")
28+
UNCHANGED("System state matches desired state"),
29+
CHANGED("System state does not match desired state")
2930
}
3031

3132
data class ConvergeResult(
3233
val orchestrations: List<OrchestrationRequest>,
33-
val reason: String? = null
34+
val reason: String
3435
)

keel-core/src/test/groovy/com/netflix/spinnaker/keel/dryrun/DryRunIntentLauncherSpec.groovy

+2-1
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@ class DryRunIntentLauncherSpec extends Specification {
5555
new Job("wait", [waitTime: 5]),
5656
new Job("wait", [name: "wait for more time", waitTime: 5])
5757
], new Trigger("1", "keel", "keel"))
58-
], null)
58+
], "Raisins")
5959
}
6060
result instanceof DryRunLaunchedIntentResult
61+
result.reason == "Raisins"
6162
result.steps.size() == 1
6263
result.steps[0].name == "my orchestration"
6364
result.steps[0].description == "testing dry-runs"

keel-intents/src/main/kotlin/com/netflix/spinnaker/keel/intents/processors/ApplicationIntentProcessor.kt

+15-13
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,21 @@ class ApplicationIntentProcessor
5757
))
5858

5959
return ConvergeResult(listOf(
60-
OrchestrationRequest(
61-
name = if (currentState == null) "Create application" else "Update application",
62-
application = intent.spec.name,
63-
description = "Converging on desired application state",
64-
job = listOf(
65-
Job(
66-
type = "upsertApplication",
67-
m = objectMapper.convertValue(intent.spec, ANY_MAP_TYPE)
68-
)
69-
),
70-
trigger = Trigger(intent.getId())
71-
)
72-
))
60+
OrchestrationRequest(
61+
name = if (currentState == null) "Create application" else "Update application",
62+
application = intent.spec.name,
63+
description = "Converging on desired application state",
64+
job = listOf(
65+
Job(
66+
type = "upsertApplication",
67+
m = objectMapper.convertValue(intent.spec, ANY_MAP_TYPE)
68+
)
69+
),
70+
trigger = Trigger(intent.getId())
71+
)
72+
),
73+
if (currentState == null) "Application does not exist" else "Application has been updated"
74+
)
7375
}
7476

7577
private fun getApplication(name: String): Application? {

keel-intents/src/main/kotlin/com/netflix/spinnaker/keel/intents/processors/ParrotIntentProcessor.kt

+2-5
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@
1515
*/
1616
package com.netflix.spinnaker.keel.intents.processors
1717

18-
import com.netflix.spinnaker.keel.ConvergeResult
19-
import com.netflix.spinnaker.keel.Intent
20-
import com.netflix.spinnaker.keel.IntentProcessor
21-
import com.netflix.spinnaker.keel.IntentSpec
18+
import com.netflix.spinnaker.keel.*
2219
import com.netflix.spinnaker.keel.intents.ParrotIntent
2320
import com.netflix.spinnaker.keel.model.Job
2421
import com.netflix.spinnaker.keel.model.OrchestrationRequest
@@ -48,6 +45,6 @@ class ParrotIntentProcessor
4845
),
4946
trigger = Trigger(intent.getId())
5047
)
51-
))
48+
), ConvergeReason.CHANGED.reason)
5249
}
5350
}

keel-intents/src/main/kotlin/com/netflix/spinnaker/keel/intents/processors/SecurityGroupIntentProcessor.kt

+15-13
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,21 @@ class SecurityGroupIntentProcessor
6666
}
6767

6868
return ConvergeResult(listOf(
69-
OrchestrationRequest(
70-
name = "Upsert security group",
71-
application = intent.spec.application,
72-
description = "Converging on desired security group state",
73-
job = listOf(
74-
Job(
75-
type = "upsertSecurityGroup",
76-
m = securityGroupConverter.convertToJob(intent.spec)
77-
)
78-
),
79-
trigger = Trigger(intent.getId())
80-
)
81-
))
69+
OrchestrationRequest(
70+
name = "Upsert security group",
71+
application = intent.spec.application,
72+
description = "Converging on desired security group state",
73+
job = listOf(
74+
Job(
75+
type = "upsertSecurityGroup",
76+
m = securityGroupConverter.convertToJob(intent.spec)
77+
)
78+
),
79+
trigger = Trigger(intent.getId())
80+
)
81+
),
82+
ConvergeReason.CHANGED.reason
83+
)
8284
}
8385

8486
private fun getSecurityGroups(spec: SecurityGroupSpec): Set<SecurityGroup> {

0 commit comments

Comments
 (0)