vmware-archive / octant

Highly extensible platform for developers to better understand the complexity of Kubernetes clusters.
https://octant.dev
Apache License 2.0
6.28k stars 486 forks source link

How to get current namespace when creating a custom list view? #3236

Open fengye87 opened 2 years ago

fengye87 commented 2 years ago

What steps did you take and what happened: I was trying to write a plugin that supports a custom resource list view. When listing objects, how can I get current user selected namespace?

Screen Shot 2022-04-01 at 5 01 45 PM

router.HandleFunc("*", func(request service.Request) (component.ContentResponse, error) {
    podList, err := request.DashboardClient().List(request.Context(), store.Key{
        Namespace:  "default", // TODO: how to get current namespace?
        APIVersion: "v1",
        Kind:       "Pod",
    })
    if err != nil {
        return *contentResponse, err
    }
    ...
})

Environment: