-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: withdeletiontimestamp filter (#1026)
## Description Adds a new filter `.WithDeletionTimestamp` to aid Operator developers as they use `ownerRefs`. Decide if `.HasDeletionTimestamp` needs to be done. Needs: - [x] e2e test (defenseunicorns/pepr-excellent-examples#61) - [x] docs ## Related Issue Fixes #1018 Fixes: #1027 <!-- or --> Relates to # ## Type of change - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Other (security config, docs update, etc) ## Checklist before merging - [ ] Test, docs, adr added or updated as needed - [ ] [Contributor Guide Steps](https://docs.pepr.dev/main/contribute/#submitting-a-pull-request) followed --------- Signed-off-by: Case Wylie <[email protected]> Co-authored-by: Barrett <[email protected]>
- Loading branch information
1 parent
8cd1cb1
commit a5ae3cc
Showing
8 changed files
with
180 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Pepr Filters | ||
|
||
Filters are functions that take a `AdmissionReview` or Watch event and return a boolean. They are used to filter out resources that do not meet certain criteria. Filters are used in the package to filter out resources that are not relevant to the user-defined admission or watch process. | ||
|
||
```ts | ||
When(a.ConfigMap) | ||
// This limits the action to only act on new resources. | ||
.IsCreated() | ||
// Namespace filter | ||
.InNamespace("webapp") | ||
// Name filter | ||
.WithName("example-1") | ||
// Label filter | ||
.WithLabel("app", "webapp") | ||
.WithLabel("env", "prod") | ||
.Mutate(request => { | ||
request | ||
.SetLabel("pepr", "was-here") | ||
.SetAnnotation("pepr.dev", "annotations-work-too"); | ||
}); | ||
``` | ||
|
||
|
||
## `Filters` | ||
|
||
- `.WithName("name")`: Filters resources by name. | ||
- `.InNamespace("namespace")`: Filters resources by namespace. | ||
- `.WithLabel("key", "value")`: Filters resources by label. (Can be multiple) | ||
- `.WithDeletionTimestamp()`: Filters resources that have a deletion timestamp. | ||
|
||
Notes: | ||
- `WithDeletionTimestamp()` is does not work on Delete through the `Mutate` or `Validate` methods because the Kubernetes Admission Process does not fire the DELETE event with a deletion timestamp on the resource. | ||
- `WithDeletionTimestamp()` _will_ match on an Update event during Admission (`Mutate` or `Validate`) when pending-deletion permitted changes (like removing a finalizer) occur. |
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
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