✨ feature: Add Ignore Fields selector options and error reason#421
✨ feature: Add Ignore Fields selector options and error reason#421ncr38 wants to merge 2 commits intoopen-cluster-management-io:mainfrom
Conversation
Signed-off-by: navin <navin.rai@groww.in>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: ncr38 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
WalkthroughIgnoreField gained two optional path-specifier fields (JSONPointers, JQPathExpressions) and JSONPaths became optional; CRD schemas were updated accordingly. deepcopy logic was extended to copy new fields. Three new applied-condition constants were added: AppliedManifestComplete, AppliedManifestFailed, AppliedManifestSSAIgnoreFieldError. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Signed-off-by: navin <navin.rai@groww.in>
There was a problem hiding this comment.
🧹 Nitpick comments (3)
work/v1/0000_00_work.open-cluster-management.io_manifestworks.crd.yaml (1)
340-366: Consider adding a validation rule requiring at least one path field to be non-empty.With
jsonPathsno longer required and no constraint on the new fields, a user can create anignoreFieldsentry with onlyconditionset and all three path arrays empty/absent. This would be a valid but meaningless no-op entry. Consider adding anx-kubernetes-validationsrule like:x-kubernetes-validations: - message: "At least one of jsonPaths, jsonPointers, or jqPathExpressions must be specified" rule: "has(self.jsonPaths) || has(self.jsonPointers) || has(self.jqPathExpressions)"This would apply to the
ignoreFieldsitem object (around Line 366, before the closingtype: object).🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@work/v1/0000_00_work.open-cluster-management.io_manifestworks.crd.yaml` around lines 340 - 366, Add an x-kubernetes-validations block to the ignoreFields item schema so at least one of the path arrays is present; specifically, update the object that defines ignoreFields (the schema containing jsonPaths, jsonPointers, jqPathExpressions and condition) to include an x-kubernetes-validations entry with a message like "At least one of jsonPaths, jsonPointers, or jqPathExpressions must be specified" and a rule such as has(self.jsonPaths) || has(self.jsonPointers) || has(self.jqPathExpressions) so empty/no-op ignoreFields are rejected.work/v1alpha1/0000_00_work.open-cluster-management.io_manifestworkreplicasets.crd.yaml (1)
376-402: Same validation gap as the ManifestWork CRD — no minimum-one-path constraint.Same concern as flagged in the ManifestWork CRD: an
ignoreFieldsentry can be created withconditiononly and all path arrays absent, resulting in a no-op. If you add a validation rule to the ManifestWork CRD, apply it here as well for consistency.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@work/v1alpha1/0000_00_work.open-cluster-management.io_manifestworkreplicasets.crd.yaml` around lines 376 - 402, The ignoreFields object allows creating entries with only condition set and no path arrays; add an OpenAPI validation requiring at least one path array to be non-empty by adding an anyOf (or oneOf) under the same schema that checks jqPathExpressions, jsonPaths, and jsonPointers each with minItems: 1; reference the ignoreFields object and its properties (condition, jqPathExpressions, jsonPaths, jsonPointers) and ensure the new anyOf rule is present in this CRD the same way you added it to the ManifestWork CRD so an entry must include at least one non-empty path array.addon/v1alpha1/0000_03_addon.open-cluster-management.io_addontemplates.crd.yaml (1)
357-383: Consistent with the other CRD changes — same validation gap applies.Same as the other two CRDs: consider adding an
x-kubernetes-validationsrule to ensure at least one of the three path fields is specified. All three CRDs should stay in sync.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@addon/v1alpha1/0000_03_addon.open-cluster-management.io_addontemplates.crd.yaml` around lines 357 - 383, Add an x-kubernetes-validations entry on the same object that contains jqPathExpressions, jsonPaths and jsonPointers (the "condition" object) to enforce that at least one of those three fields is present; implement a validation rule referencing jqPathExpressions, jsonPaths and jsonPointers (e.g. a CEL/validation expression that returns true if any of .jqPathExpressions, .jsonPaths or .jsonPointers is present) and include a clear message like "At least one of jqPathExpressions, jsonPaths or jsonPointers must be specified." Ensure this new validation mirrors the other CRDs so all three remain in sync.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@addon/v1alpha1/0000_03_addon.open-cluster-management.io_addontemplates.crd.yaml`:
- Around line 357-383: Add an x-kubernetes-validations entry on the same object
that contains jqPathExpressions, jsonPaths and jsonPointers (the "condition"
object) to enforce that at least one of those three fields is present; implement
a validation rule referencing jqPathExpressions, jsonPaths and jsonPointers
(e.g. a CEL/validation expression that returns true if any of
.jqPathExpressions, .jsonPaths or .jsonPointers is present) and include a clear
message like "At least one of jqPathExpressions, jsonPaths or jsonPointers must
be specified." Ensure this new validation mirrors the other CRDs so all three
remain in sync.
In `@work/v1/0000_00_work.open-cluster-management.io_manifestworks.crd.yaml`:
- Around line 340-366: Add an x-kubernetes-validations block to the ignoreFields
item schema so at least one of the path arrays is present; specifically, update
the object that defines ignoreFields (the schema containing jsonPaths,
jsonPointers, jqPathExpressions and condition) to include an
x-kubernetes-validations entry with a message like "At least one of jsonPaths,
jsonPointers, or jqPathExpressions must be specified" and a rule such as
has(self.jsonPaths) || has(self.jsonPointers) || has(self.jqPathExpressions) so
empty/no-op ignoreFields are rejected.
In
`@work/v1alpha1/0000_00_work.open-cluster-management.io_manifestworkreplicasets.crd.yaml`:
- Around line 376-402: The ignoreFields object allows creating entries with only
condition set and no path arrays; add an OpenAPI validation requiring at least
one path array to be non-empty by adding an anyOf (or oneOf) under the same
schema that checks jqPathExpressions, jsonPaths, and jsonPointers each with
minItems: 1; reference the ignoreFields object and its properties (condition,
jqPathExpressions, jsonPaths, jsonPointers) and ensure the new anyOf rule is
present in this CRD the same way you added it to the ManifestWork CRD so an
entry must include at least one non-empty path array.
Summary
This PR is aimed to add more advanced field selector options like JSONPointer and JQPathExpressions to the ignoreField config in case of ServerSideApply strategy.
Related Enhancement Proposal(s)
open-cluster-management-io/enhancements#173
Summary by CodeRabbit