Skip to content

Commit 93ee57b

Browse files
committed
Add check for syncPolicy.automated.allowEmpty and syncPolicy.automated.selfHeal
1 parent 02f0adc commit 93ee57b

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

internal/controller/argo.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,14 @@ func compareAutomatedSyncPolicy(goal, actual *argoapi.SyncPolicyAutomated) bool
978978
log.Printf("SyncPolicy Prune changed %t -> %t\n", actual.Prune, goal.Prune)
979979
return false
980980
}
981+
if goal.AllowEmpty != actual.AllowEmpty {
982+
log.Printf("SyncPolicy AllowEmpty changed %t -> %t\n", actual.AllowEmpty, goal.AllowEmpty)
983+
return false
984+
}
985+
if goal.SelfHeal != actual.SelfHeal {
986+
log.Printf("SyncPolicy SelfHeal changed %t -> %t\n", actual.SelfHeal, goal.SelfHeal)
987+
return false
988+
}
981989
return true
982990
}
983991

internal/controller/argo_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,28 @@ var _ = Describe("Argo Pattern", func() {
599599
Expect(result).To(BeFalse())
600600
Expect(logBuffer.String()).To(ContainSubstring("SyncPolicy Prune changed true -> false"))
601601
})
602+
It("should return false and log the appropriate message", func() {
603+
automatedSyncPolicyChanged := automatedSyncPolicy.DeepCopy()
604+
automatedSyncPolicyChanged.AllowEmpty = true
605+
logBuffer := new(bytes.Buffer)
606+
log.SetOutput(logBuffer)
607+
defer log.SetOutput(os.Stderr)
608+
609+
result := compareAutomatedSyncPolicy(automatedSyncPolicy, automatedSyncPolicyChanged)
610+
Expect(result).To(BeFalse())
611+
Expect(logBuffer.String()).To(ContainSubstring("SyncPolicy AllowEmpty changed true -> false"))
612+
})
613+
It("should return false and log the appropriate message", func() {
614+
automatedSyncPolicyChanged := automatedSyncPolicy.DeepCopy()
615+
automatedSyncPolicyChanged.SelfHeal = true
616+
logBuffer := new(bytes.Buffer)
617+
log.SetOutput(logBuffer)
618+
defer log.SetOutput(os.Stderr)
619+
620+
result := compareAutomatedSyncPolicy(automatedSyncPolicy, automatedSyncPolicyChanged)
621+
Expect(result).To(BeFalse())
622+
Expect(logBuffer.String()).To(ContainSubstring("SyncPolicy SelfHeal changed true -> false"))
623+
})
602624
It("compareAutomatedSyncPolicy() function with nil arg1", func() {
603625
Expect(compareAutomatedSyncPolicy(automatedSyncPolicy, nil)).To(BeFalse())
604626
})

0 commit comments

Comments
 (0)