@@ -1015,14 +1015,15 @@ func TestAtomicRelease_Reconcile_Scenarios(t *testing.T) {
1015
1015
1016
1016
func TestAtomicRelease_actionForState (t * testing.T ) {
1017
1017
tests := []struct {
1018
- name string
1019
- releases []* helmrelease.Release
1020
- spec func (spec * v2.HelmReleaseSpec )
1021
- status func (releases []* helmrelease.Release ) v2.HelmReleaseStatus
1022
- state ReleaseState
1023
- want ActionReconciler
1024
- wantEvent * corev1.Event
1025
- wantErr error
1018
+ name string
1019
+ releases []* helmrelease.Release
1020
+ annotations map [string ]string
1021
+ spec func (spec * v2.HelmReleaseSpec )
1022
+ status func (releases []* helmrelease.Release ) v2.HelmReleaseStatus
1023
+ state ReleaseState
1024
+ want ActionReconciler
1025
+ wantEvent * corev1.Event
1026
+ wantErr error
1026
1027
}{
1027
1028
{
1028
1029
name : "in-sync release does not trigger any action" ,
@@ -1036,6 +1037,22 @@ func TestAtomicRelease_actionForState(t *testing.T) {
1036
1037
state : ReleaseState {Status : ReleaseStatusInSync },
1037
1038
want : nil ,
1038
1039
},
1040
+ {
1041
+ name : "in-sync release with force annotation triggers upgrade action" ,
1042
+ state : ReleaseState {Status : ReleaseStatusInSync },
1043
+ annotations : map [string ]string {
1044
+ meta .ReconcileRequestAnnotation : "force" ,
1045
+ v2 .ForceRequestAnnotation : "force" ,
1046
+ },
1047
+ status : func (releases []* helmrelease.Release ) v2.HelmReleaseStatus {
1048
+ return v2.HelmReleaseStatus {
1049
+ History : v2.Snapshots {
1050
+ {Version : 1 },
1051
+ },
1052
+ }
1053
+ },
1054
+ want : & Upgrade {},
1055
+ },
1039
1056
{
1040
1057
name : "locked release triggers unlock action" ,
1041
1058
state : ReleaseState {Status : ReleaseStatusLocked },
@@ -1046,6 +1063,20 @@ func TestAtomicRelease_actionForState(t *testing.T) {
1046
1063
state : ReleaseState {Status : ReleaseStatusAbsent },
1047
1064
want : & Install {},
1048
1065
},
1066
+ {
1067
+ name : "absent release without remaining retries and force annotation triggers install" ,
1068
+ annotations : map [string ]string {
1069
+ meta .ReconcileRequestAnnotation : "force" ,
1070
+ v2 .ForceRequestAnnotation : "force" ,
1071
+ },
1072
+ state : ReleaseState {Status : ReleaseStatusAbsent },
1073
+ status : func (releases []* helmrelease.Release ) v2.HelmReleaseStatus {
1074
+ return v2.HelmReleaseStatus {
1075
+ InstallFailures : 1 ,
1076
+ }
1077
+ },
1078
+ want : & Install {},
1079
+ },
1049
1080
{
1050
1081
name : "absent release without remaining retries returns error" ,
1051
1082
state : ReleaseState {Status : ReleaseStatusAbsent },
@@ -1159,6 +1190,22 @@ func TestAtomicRelease_actionForState(t *testing.T) {
1159
1190
},
1160
1191
want : & Upgrade {},
1161
1192
},
1193
+ {
1194
+ name : "out-of-sync release with no remaining retries and force annotation triggers upgrade" ,
1195
+ state : ReleaseState {
1196
+ Status : ReleaseStatusOutOfSync ,
1197
+ },
1198
+ annotations : map [string ]string {
1199
+ meta .ReconcileRequestAnnotation : "force" ,
1200
+ v2 .ForceRequestAnnotation : "force" ,
1201
+ },
1202
+ status : func (releases []* helmrelease.Release ) v2.HelmReleaseStatus {
1203
+ return v2.HelmReleaseStatus {
1204
+ UpgradeFailures : 1 ,
1205
+ }
1206
+ },
1207
+ want : & Upgrade {},
1208
+ },
1162
1209
{
1163
1210
name : "out-of-sync release with no remaining retries returns error" ,
1164
1211
state : ReleaseState {
@@ -1198,6 +1245,21 @@ func TestAtomicRelease_actionForState(t *testing.T) {
1198
1245
},
1199
1246
want : & Upgrade {},
1200
1247
},
1248
+ {
1249
+ name : "failed release with exhausted retries and force annotation triggers upgrade" ,
1250
+ state : ReleaseState {Status : ReleaseStatusFailed },
1251
+ annotations : map [string ]string {
1252
+ meta .ReconcileRequestAnnotation : "force" ,
1253
+ v2 .ForceRequestAnnotation : "force" ,
1254
+ },
1255
+ status : func (releases []* helmrelease.Release ) v2.HelmReleaseStatus {
1256
+ return v2.HelmReleaseStatus {
1257
+ LastAttemptedReleaseAction : v2 .ReleaseActionUpgrade ,
1258
+ UpgradeFailures : 1 ,
1259
+ }
1260
+ },
1261
+ want : & Upgrade {},
1262
+ },
1201
1263
{
1202
1264
name : "failed release with exhausted retries returns error" ,
1203
1265
state : ReleaseState {Status : ReleaseStatusFailed },
@@ -1348,6 +1410,9 @@ func TestAtomicRelease_actionForState(t *testing.T) {
1348
1410
g := NewWithT (t )
1349
1411
1350
1412
obj := & v2.HelmRelease {
1413
+ ObjectMeta : metav1.ObjectMeta {
1414
+ Annotations : tt .annotations ,
1415
+ },
1351
1416
Spec : v2.HelmReleaseSpec {
1352
1417
ReleaseName : mockReleaseName ,
1353
1418
TargetNamespace : mockReleaseNamespace ,
0 commit comments