Skip to content

Commit

Permalink
Merge pull request #47 from ibuildthecloud/main
Browse files Browse the repository at this point in the history
Compare resourceVersions as int
  • Loading branch information
ibuildthecloud authored Aug 19, 2021
2 parents 3f27401 + 1c0a7aa commit 0695431
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/k8splan/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"reflect"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -53,6 +54,12 @@ type watcher struct {
lastAppliedResourceVersion string
}

func toInt(resourceVersion string) int {
// we assume this is always a valid number
n, _ := strconv.Atoi(resourceVersion)
return n
}

func (w *watcher) start(ctx context.Context) {
kc, err := clientcmd.RESTConfigFromKubeConfig([]byte(w.connInfo.KubeConfig))
if err != nil {
Expand Down Expand Up @@ -108,7 +115,7 @@ func (w *watcher) start(ctx context.Context) {
}
logrus.Debugf("[K8s] Processing secret %s in namespace %s at generation %d with resource version %s", secret.Name, secret.Namespace, secret.Generation, secret.ResourceVersion)
needsApplied := true
if w.lastAppliedResourceVersion > secret.ResourceVersion {
if toInt(w.lastAppliedResourceVersion) > toInt(secret.ResourceVersion) {
logrus.Debugf("received secret to process that was older than the last secret operated on. (%s vs %s)", secret.ResourceVersion, w.lastAppliedResourceVersion)
return secret, nil
}
Expand Down

0 comments on commit 0695431

Please sign in to comment.