Skip to content
This repository was archived by the owner on May 24, 2025. It is now read-only.

Commit 53ef356

Browse files
authored
Merge pull request #3 from Bobonium/main
trigger only 1 event on startup
2 parents 7ab2450 + 5ad1427 commit 53ef356

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

cmd/main.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ var dovecotDirectorLabels string
2626
var namespace string
2727
var kubeconf *rest.Config
2828

29+
var initialDovecotPodCount int
30+
2931
func main() {
3032
clientset, err := InClusterAuth()
3133

@@ -39,6 +41,9 @@ func main() {
3941
dovecotLabels = os.Getenv("DOVECOT_LABELS")
4042
namespace = os.Getenv("DOVECOT_NAMESPACE")
4143

44+
dovecotPods := GetPodsByLabel(clientset, namespace, dovecotLabels)
45+
initialDovecotPodCount = len(dovecotPods.Items)
46+
4247
StartWatcher(clientset, namespace)
4348
}
4449

@@ -95,6 +100,11 @@ func ExecuteCommand(command string, podname string, namespace string, clientset
95100
}
96101

97102
func handleEvent(pod *v1.Pod, clientset *kubernetes.Clientset) {
103+
if initialDovecotPodCount > 1 {
104+
initialDovecotPodCount--
105+
return
106+
}
107+
98108
switch pod.Status.Phase {
99109
case v1.PodFailed, v1.PodSucceeded:
100110
case v1.PodRunning:

0 commit comments

Comments
 (0)