Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update resources plugin to support resource refs with namespace. #3782

Merged
merged 2 commits into from
Nov 23, 2021

Conversation

absoludity
Copy link
Contributor

Description of the change

Follows #3781 and updates the resources plugin itself to support the namespace field in a resource ref.

This means the plugin is now able to get or watch resources from a namespace other than that of the installed package - as long as it belongs to the installed package.

It also makes it much cleaner to handle non-namespaced resources since it's simply depends on whether the resource ref has a namespace (hmm, actually, we've had non-namespaced resources in the kubeapps chart where we've specified the namespace, so we'll still need to ensure, server-side, that the resource is namespaced or not).

Benefits

See benefits of #3781

Possible drawbacks

Applicable issues

Additional information

@@ -198,7 +198,12 @@ func (s *Server) GetResources(r *v1alpha1.GetResourcesRequest, stream v1alpha1.R
}

if !r.GetWatch() {
resource, err := dynamicClient.Resource(gvr).Namespace(namespace).Get(stream.Context(), ref.GetName(), metav1.GetOptions{})
var resource interface{}
if ref.Namespace != "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat!

Copy link
Contributor

@antgamdia antgamdia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!!

Signed-off-by: Michael Nelson <minelson@vmware.com>
Signed-off-by: Michael Nelson <minelson@vmware.com>
@absoludity absoludity force-pushed the 3779-use-namespace-in-resources-plugin branch from f6dffc7 to 51b1766 Compare November 22, 2021 04:43
Base automatically changed from 3779-add-namespace-to-ref to master November 23, 2021 00:22
@absoludity absoludity merged commit 8098d41 into master Nov 23, 2021
@absoludity absoludity deleted the 3779-use-namespace-in-resources-plugin branch November 23, 2021 00:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants