* refactor: Treat all of the target spec as a single object while replacing variables
Serialize it into a map string interface then back to a target seletor before returning
Signed-off-by: aerosouund <aerosound161@gmail.com>
* test: Add scenario for variables in the label selector test
Signed-off-by: aerosouund <aerosound161@gmail.com>
* Fix: Capitalize error message
Co-authored-by: shuting <shuting@nirmata.com>
Signed-off-by: Ammar Yasser <aerosound161@gmail.com>
* Fix: Adjust error message specification to mention target rather than selector
Co-authored-by: shuting <shuting@nirmata.com>
Signed-off-by: Ammar Yasser <aerosound161@gmail.com>
* fix: Pass the target selector only during variable replacement
Signed-off-by: aerosouund <aerosound161@gmail.com>
---------
Signed-off-by: aerosouund <aerosound161@gmail.com>
Signed-off-by: Ammar Yasser <aerosound161@gmail.com>
Co-authored-by: shuting <shuting@nirmata.com>
* feature: Add LabelSelector as a field of resource spec to allow fetching by labels
Signed-off-by: aerosouund <aerosound161@gmail.com>
* chore: Generate CRDs
Signed-off-by: aerosouund <aerosound161@gmail.com>
* feat: Add the capability to fetch with label selector
- Add the label selector as a parameter to GetResources of the engine api client and the dclient.
- Use the label selector with list options in the dclient.
- convert a metav1.LabelSelector to a labels.Selector before fetching to be able to convert it to a string to be used with ListOptions.
Signed-off-by: aerosouund <aerosound161@gmail.com>
* feat: Pass label selector to the GetResources method
Signed-off-by: aerosouund <aerosound161@gmail.com>
* feat: Return the resource selector when resolving spec
Signed-off-by: aerosouund <aerosound161@gmail.com>
* fix: Instantiate the fake client schema using the passed gvrToListKind map and by inferring schema from passed resources
All tests that use List will fail because the fake client doesn't infer the schema from the passed resources.
gvrToListKind can't be fully deprecated as some parts of kyverno use the fake client without passing resources to it (resource generation). And so both approaches have to be supported.
References:
- https://github.com/kubernetes/client-go/issues/983
- 46c1ad3baa
Signed-off-by: aerosouund <aerosound161@gmail.com>
* test: Add labelSelector unit test to mutate existing test.
- Remove the unwanted call to GetResource.
- Pass an empty map of GVR to string to the fake client constructor.
Signed-off-by: aerosouund <aerosound161@gmail.com>
* test: Add chainsaw test
Signed-off-by: aerosouund <aerosound161@gmail.com>
* chore: Run codegen
Signed-off-by: aerosouund <aerosound161@gmail.com>
* chore: Generate helm CRDs
Signed-off-by: aerosouund <aerosound161@gmail.com>
* refactor: Put the LabelSelector in a separate struct
Many types use the ResourceSpec struct and not all of them support label selectors.
This removes the field into a separate schema dedicated to target selection called TargetSelector.
It has the ResourceSpec and the selector.
Signed-off-by: aerosouund <aerosound161@gmail.com>
* chore: Run codegen after modifying selector comment
Signed-off-by: aerosouund <aerosound161@gmail.com>
* chore: Run codegen
Signed-off-by: aerosouund <aerosound161@gmail.com>
---------
Signed-off-by: aerosouund <aerosound161@gmail.com>
Co-authored-by: shuting <shuting@nirmata.com>
* chore: Fix spelling issue in breaker logging
Signed-off-by: aerosouund <aerosound161@gmail.com>
* feat: Introduce circuit breaking in background report scanning
Add the breaker as a field of the background controller and use it in the storeReport method which handles report creation
Signed-off-by: aerosouund <aerosound161@gmail.com>
* feat: Add required flags and instantiation for the circuit breaker in the background reports controller
Signed-off-by: aerosouund <aerosound161@gmail.com>
* fix: Add flag for max background reports in the reports controller
Signed-off-by: ammar <ammar.yasser@vodafone.com>
* chore: Update flag description to use ephemeralreports instead of background reports
Signed-off-by: aerosouund <aerosound161@gmail.com>
* chore: Use a less verbose description for the flag
Co-authored-by: shuting <shuting@nirmata.com>
Signed-off-by: Ammar Yasser <aerosound161@gmail.com>
---------
Signed-off-by: aerosouund <aerosound161@gmail.com>
Signed-off-by: ammar <ammar.yasser@vodafone.com>
Signed-off-by: Ammar Yasser <aerosound161@gmail.com>
Co-authored-by: ammar <ammar.yasser@vodafone.com>
Co-authored-by: Jim Bugwadia <jim@nirmata.com>
Co-authored-by: shuting <shuting@nirmata.com>
* Added propagationPolicy to TTL controller for resource deletion
Signed-off-by: ShivamJha2436 <shivamkumar87148@gmail.com>
* Added per-resource deletion policy with optional global default
Signed-off-by: ShivamJha2436 <shivamkumar87148@gmail.com>
* Fix: Added nil check for annotations to prevent runtime errors
Signed-off-by: ShivamJha2436 <shivamkumar87148@gmail.com>
* Fix: Moved logic for retrieving propagation policy from annotations to a dedicated function
Signed-off-by: ShivamJha2436 <shivamkumar87148@gmail.com>
* Fix: Resolve merge conflict in controller.go and update propagation policy handling
- Added missing gvr field from main branch
- Improved annotation naming as per team discussion
- Moved propagation policy logic closer to usage
Signed-off-by: ShivamJha2436 <shivamkumar87148@gmail.com>
* Simplified propagation policy logic
Signed-off-by: ShivamJha2436 <shivamkumar87148@gmail.com>
* Add unit tests for controller.go
Signed-off-by: ShivamJha2436 <shivamkumar87148@gmail.com>
* Removed the test file for controller.go and fixed the lint error
Signed-off-by: ShivamJha2436 <shivamkumar87148@gmail.com>
* test: add unit tests for deletion propagation policy in TTL-based cleanup
Signed-off-by: ShivamJha2436 <shivamkumar87148@gmail.com>
* Resolved conflicts
Signed-off-by: ShivamJha2436 <shivamkumar87148@gmail.com>
* Resolved conflicts
Signed-off-by: ShivamJha2436 <shivamkumar87148@gmail.com>
* Resolved merge conflict
Signed-off-by: ShivamJha2436 <shivamkumar87148@gmail.com>
* Fix:Updated the unit tests
Signed-off-by: ShivamJha2436 <shivamkumar87148@gmail.com>
* Fix: Removed the method receiver from determinePropagationPolicy as it does not require access to the controller struct
Signed-off-by: ShivamJha2436 <shivamkumar87148@gmail.com>
* Fix: Fixed the formatting issue
Signed-off-by: ShivamJha2436 <shivamkumar87148@gmail.com>
* Fix: removed the switch statement inside the test case
Signed-off-by: ShivamJha2436 <shivamkumar87148@gmail.com>
* Updated the controller.go
Signed-off-by: ShivamJha2436 <shivamkumar87148@gmail.com>
* Resolved the formatting issue
Signed-off-by: ShivamJha2436 <shivamkumar87148@gmail.com>
* Fixing the deleted resource label in controller.go
Signed-off-by: ShivamJha2436 <shivamkumar87148@gmail.com>
* Fixed the linter issue
Signed-off-by: ShivamJha2436 <shivamkumar87148@gmail.com>
---------
Signed-off-by: ShivamJha2436 <shivamkumar87148@gmail.com>
Co-authored-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
* Added propagationPolicy to TTL controller for resource deletion
Signed-off-by: ShivamJha2436 <shivamkumar87148@gmail.com>
* Added per-resource deletion policy with optional global default
Signed-off-by: ShivamJha2436 <shivamkumar87148@gmail.com>
* Fix: Added nil check for annotations to prevent runtime errors
Signed-off-by: ShivamJha2436 <shivamkumar87148@gmail.com>
* Fix: Moved logic for retrieving propagation policy from annotations to a dedicated function
Signed-off-by: ShivamJha2436 <shivamkumar87148@gmail.com>
* Fix: Resolve merge conflict in controller.go and update propagation policy handling
- Added missing gvr field from main branch
- Improved annotation naming as per team discussion
- Moved propagation policy logic closer to usage
Signed-off-by: ShivamJha2436 <shivamkumar87148@gmail.com>
* Simplified propagation policy logic
Signed-off-by: ShivamJha2436 <shivamkumar87148@gmail.com>
* Add unit tests for controller.go
Signed-off-by: ShivamJha2436 <shivamkumar87148@gmail.com>
* Removed the test file for controller.go and fixed the lint error
Signed-off-by: ShivamJha2436 <shivamkumar87148@gmail.com>
---------
Signed-off-by: ShivamJha2436 <shivamkumar87148@gmail.com>