Skip to content

Commit

Permalink
speed up namespace lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
hookenz committed Sep 5, 2023
1 parent 4a29697 commit 7134294
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
3 changes: 3 additions & 0 deletions http/handler/kubernetes/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@ func NewHandler(notaryService *security.NotaryService, kubernetesDeployer *exec.
h.Handle("/kubernetes/stack",
notaryService.DigitalSignatureVerification(httperror.LoggerHandler(h.kubernetesDeploy))).Methods(http.MethodPost)

h.Handle("/kubernetes/namespaces",
notaryService.DigitalSignatureVerification(httperror.LoggerHandler(h.kubernetesGetNamespaces))).Methods(http.MethodGet)

return h
}
33 changes: 33 additions & 0 deletions http/handler/kubernetes/kubernetes_namespaces.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package kubernetes

import (
"fmt"
"net/http"

httperror "github.com/portainer/portainer/pkg/libhttp/error"
"github.com/portainer/portainer/pkg/libhttp/request"
"github.com/portainer/portainer/pkg/libhttp/response"
)

type getNamespacePayload struct{}

func (payload *getNamespacePayload) Validate(r *http.Request) error {

return nil
}

func (handler *Handler) kubernetesGetNamespaces(rw http.ResponseWriter, r *http.Request) *httperror.HandlerError {
var payload getNamespacePayload
err := request.DecodeAndValidateJSONPayload(r, &payload)
if err != nil {
return httperror.BadRequest("Invalid request payload", err)
}

for _, header := range r.Header {
for _, value := range header {
fmt.Println("Header:", value)
}
}

return response.Empty(rw)
}

0 comments on commit 7134294

Please sign in to comment.