-
Notifications
You must be signed in to change notification settings - Fork 533
Replace override paths with JSON pointer style paths #991
Replace override paths with JSON pointer style paths #991
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: shashidharatd The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
1873819
to
a43e958
Compare
a43e958
to
ec909b2
Compare
test/common/crudtester.go
Outdated
@@ -564,8 +564,10 @@ func (c *FederatedTypeCrudTester) waitForResource(client util.ResourceClient, qu | |||
|
|||
// Validate that the expected override was applied | |||
if len(expectedOverrides) > 0 { | |||
// TODO: use the json patch library to patch with the overrides and then compare it with cluster object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CI failure suggests that you may need to implement this strategy to support testing of overriding a path that embeds an index. The nested field copy won't work for that case.
ec909b2
to
29de00f
Compare
29de00f
to
0343749
Compare
a19213a
to
c797a29
Compare
c797a29
to
3844c72
Compare
finally the mechanim to test json-patch style override is working. @marun, ptal once again. Thanks ! |
Nice work, LGTM! |
56c1d7f
to
90e8731
Compare
90e8731
to
dcab3e2
Compare
@marun, PTAL. Thanks ! |
for i, clusterOverride := range clusterOverrides { | ||
path := clusterOverride.Path | ||
if invalidPaths.Has(path) { | ||
return nil, errors.Errorf("override[%d] for cluster %q has an invalid path: %s", i, clusterName, path) | ||
} | ||
if _, ok := overridesMap[clusterName][path]; ok { | ||
if paths.Has(path) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it makes sense to validate here for duplicate paths anymore given that a path could appear more than once for different operations? Selector-based overrides will complicate things still further. Maybe just remove detection of duplicate paths for now?
@@ -107,6 +107,9 @@ func federatedTypeValidationSchema(templateSchema map[string]v1beta1.JSONSchemaP | |||
Schema: &v1beta1.JSONSchemaProps{ | |||
Type: "object", | |||
Properties: map[string]v1beta1.JSONSchemaProps{ | |||
"op": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to validate for the specific values that are supported?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we consider making at least path
and value
fields required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Path can be required but value is required by replace
and add
but not remove
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @shashidharatd! There a few outstanding unresolved conversations, but this looks functionally good so I am merging this in anticipation of another release candidate.
/lgtm
Path string `json:"path"` | ||
Value interface{} `json:"value"` | ||
Value interface{} `json:"value,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason to make path
required and value
optional? Also, it appears to not match the validation schema as none of these fields are required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming the reason for it being optional is that interface{}
is implicitly a pointer. I don't think there is much value in worrying about this struct since it is just a convenience to enable typed use rather than a public interface. I share your concern about the validation schema, though - these fields really should be required.
@@ -107,6 +107,9 @@ func federatedTypeValidationSchema(templateSchema map[string]v1beta1.JSONSchemaP | |||
Schema: &v1beta1.JSONSchemaProps{ | |||
Type: "object", | |||
Properties: map[string]v1beta1.JSONSchemaProps{ | |||
"op": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we consider making at least path
and value
fields required?
Please refer to the design doc here
Ref issue: #520
todos:
/cc @marun