-
Notifications
You must be signed in to change notification settings - Fork 385
Ensure that ObjectMeta field selectors (e.g. name and namespace) can be used appropriately for all types #2214
Ensure that ObjectMeta field selectors (e.g. name and namespace) can be used appropriately for all types #2214
Conversation
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 for adding this! Once it is in we can use it to clean up some of our existing code around filtering by name vs external name. I'll create a follow-on issue once this is merged.
Just need a few new tests and this should be all set.
@@ -89,8 +89,7 @@ func Match(label labels.Selector, field fields.Selector) storage.SelectionPredic | |||
|
|||
// toSelectableFields returns a field set that represents the object for matching purposes. | |||
func toSelectableFields(broker *servicecatalog.ClusterServiceBroker) fields.Set { | |||
objectMetaFieldsSet := generic.ObjectMetaFieldsSet(&broker.ObjectMeta, true) | |||
return generic.MergeFieldsSets(objectMetaFieldsSet, nil) | |||
return generic.ObjectMetaFieldsSet(&broker.ObjectMeta, false) |
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 for fixing the "hasnamespacefield" arg
test/integration/clientset_test.go
Outdated
@@ -542,6 +542,15 @@ func testClusterServiceClassClient(sType server.StorageType, client servicecatal | |||
return fmt.Errorf("should have two ClusterServiceClasses, had %v ClusterServiceClasses", len(serviceClasses.Items)) | |||
} | |||
|
|||
serviceClasses, err = serviceClassClient.List(metav1.ListOptions{FieldSelector: "metadata.name=" + name}) |
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.
Looks like we are missing existing tests for ServiceClasses
and ServicePlan
which were also modified in this PR.
Let's use those existing tests in this file and add tests for these resources as well so that we can test all of your changes.
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 can't find any existing tests for these non-namespaced resources so just to clarify: would you like me to add tests for them in this PR? Or have I missed them somehow?
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 suggesting that you copy the existing test testClusterServiceClassClient
and tweak it to test the namespaced resource ServiceClasss
so that you can also test your changes made to that as well. Same for plans (TestClusterServicePlanClient
).
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.
Done.
test/integration/clientset_test.go
Outdated
client, _, shutdownServer := getFreshApiserverAndClient(t, sType.String(), func() runtime.Object { | ||
return &servicecatalog.ClusterServicePlan{} | ||
return &servicecatalog.ClusterServiceClass{} |
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 think this should be ServiceClass{}
, no?
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.
Yep good catch thanks! Updated.
test/integration/clientset_test.go
Outdated
@@ -568,17 +770,23 @@ func testClusterServiceClassClient(sType server.StorageType, client servicecatal | |||
return nil | |||
} | |||
|
|||
// TestClusterServicePlanClient exercises the ClusterServicePlan client. | |||
func TestClusterServicePlanClient(t *testing.T) { | |||
// TestClusterServiceClassClient exercises the ClusterServiceClass client. |
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.
Is this test for namespaced classes or cluster scoped class?
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.
Aligned all types/names/comments now (I hope!).
test/integration/clientset_test.go
Outdated
}) | ||
defer shutdownServer() | ||
|
||
if err := testClusterServicePlanClient(sType, client, name); err != nil { | ||
if err := testClusterServiceClassClient(sType, client, name); err != nil { |
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.
Let's get the comment, the function name and this call to all align. 😀
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.
Done - sorry!
test/integration/clientset_test.go
Outdated
// check that the plan is the same from get and list | ||
servicePlanListed := &servicePlans.Items[0] | ||
if !reflect.DeepEqual(servicePlanAtServer, servicePlanListed) { | ||
// check that the broker is the same from get and list |
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.
shouldn't this say class instead of broker?
@@ -33,3 +49,19 @@ func falsePtr() *bool { | |||
b := false | |||
return &b | |||
} | |||
|
|||
func enableNamespacedResources() (resetFeaturesFunc func(), err error) { |
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.
👍
/test pull-service-catalog-xbuild |
Any chance of a review of this? |
@jimmidyson I see @carolynvs left some review comments & requested some changes. |
Which I'm pretty sure I've addressed... |
fixes #2260 |
test/integration/clientset_test.go
Outdated
// t.Errorf("%q test failed", sType) | ||
// } | ||
// } | ||
sType := server.StorageTypeEtcd |
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.
if this is copy and paste of another test, it should be fixed up as well and remove the CRD comments.
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.
Fixed up and removed comments.
…be used appropriately for all types
@jimmidyson This looks solid to me. A couple of things still outstanding here: @carolynvs called out issues in #2214 about inconsistencies between the Name Spaced ServiceClass vs ClusterServiceClass and a nit on an old comment. and @MHBauer asking to clean up some dead CRD comments in #2214 Thanks for the work, I look forward to getting this merged. |
Sorry I missed those things... I'm on it later today, will be ready for merge then. |
@jboyd01 @carolynvs Ready for another review round - thanks for your comments! |
Thanks @jimmidyson! |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jboyd01 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 |
Noticed that the ObjectMeta fields
metadata.name
andmetadata.namespace
do not work as they haven't been registered in conversions.I also took the liberty of tidying up the fields methods in registry to make them consitent in their approach.