-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Web: Define fetch kube resource web api endpoint #46741
Conversation
@@ -869,6 +869,7 @@ func (h *Handler) bindDefaultEndpoints() { | |||
// Kube access handlers. | |||
h.GET("/webapi/sites/:site/kubernetes", h.WithClusterAuth(h.clusterKubesGet)) | |||
h.GET("/webapi/sites/:site/pods", h.WithClusterAuth(h.clusterKubePodsGet)) | |||
h.GET("/webapi/sites/:site/kubernetes/resources", h.WithClusterAuth(h.clusterKubeResourcesGet)) |
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 added a generic endpoint to allow requesting any kube sub resources @tigrato
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.
You can drop the h.GET("/webapi/sites/:site/pods", h.WithClusterAuth(h.clusterKubePodsGet))
endpoint.
It was never used and will be replaced by h.GET("/webapi/sites/:site/kubernetes/resources", h.WithClusterAuth(h.clusterKubeResourcesGet))
d18358f
to
e7a169d
Compare
@@ -869,6 +869,7 @@ func (h *Handler) bindDefaultEndpoints() { | |||
// Kube access handlers. | |||
h.GET("/webapi/sites/:site/kubernetes", h.WithClusterAuth(h.clusterKubesGet)) | |||
h.GET("/webapi/sites/:site/pods", h.WithClusterAuth(h.clusterKubePodsGet)) | |||
h.GET("/webapi/sites/:site/kubernetes/resources", h.WithClusterAuth(h.clusterKubeResourcesGet)) |
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.
You can drop the h.GET("/webapi/sites/:site/pods", h.WithClusterAuth(h.clusterKubePodsGet))
endpoint.
It was never used and will be replaced by h.GET("/webapi/sites/:site/kubernetes/resources", h.WithClusterAuth(h.clusterKubeResourcesGet))
lib/web/servers.go
Outdated
return nil, trace.Wrap(err) | ||
} | ||
|
||
resp, err := listKubeResources(r.Context(), clt, r.URL.Query(), site.GetName(), r.URL.Query().Get("kind")) |
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.
can we add a validation on kind?
if kind==""{
return trace.BadParameter..
}
if !slices.Contains(types.KubernetesResources, kind){
return trace.BadParameter(kind is not valid, valid kinds %v, types.KubernetesResources)
}
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, i also added a check for empty kube cluster since that's also 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.
From my side, all good.
Thanks @kimlisa
080672b
to
c5e423b
Compare
part of #46742
Opens a new web api endpoint where we can fetch kube sub resources such as namespaces, pods, secrets, etc (we are currently only utilizing
namespace
for now though)Added all the boilerplate code like adding types etc.