-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use resource version while listing (#156)
* fix: use resource version while listing Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com> * fix: bump go Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com> * fix: imports Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com> --------- Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>
- Loading branch information
1 parent
9f5069a
commit 19dc442
Showing
11 changed files
with
127 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
ARG ARCH | ||
FROM golang:1.21.5 as build | ||
FROM golang:1.22.2 as build | ||
|
||
WORKDIR / | ||
COPY . ./ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package api | ||
|
||
import ( | ||
"strconv" | ||
|
||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/labels" | ||
) | ||
|
||
func allowObjectListWatch(object metav1.ObjectMeta, labelSelector labels.Selector, desiredRv uint64, rvmatch metav1.ResourceVersionMatch) (bool, uint64, error) { | ||
rv, err := strconv.ParseUint(object.ResourceVersion, 10, 64) | ||
if err != nil { | ||
return false, 0, err | ||
} | ||
|
||
switch rvmatch { | ||
case metav1.ResourceVersionMatchNotOlderThan: | ||
if rv < desiredRv { | ||
return false, 0, nil | ||
} | ||
case metav1.ResourceVersionMatchExact: | ||
if rv != desiredRv { | ||
return false, 0, nil | ||
} | ||
} | ||
|
||
if labelSelector == nil { | ||
return true, rv, nil | ||
} | ||
|
||
if labelSelector.Matches(labels.Set(object.Labels)) { | ||
return true, rv, nil | ||
} else { | ||
return false, 0, nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters