Skip to content

Commit

Permalink
fix: correct some issues
Browse files Browse the repository at this point in the history
  • Loading branch information
saman2000hoseini committed Oct 25, 2023
1 parent caf5faf commit 0edf9b1
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions internal/hubble-middleware/handler/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ import (

type (
ProjectHandler struct {
k8sClusterConfig *rest.Config
k8sUserConfig rest.Config
k8sAppConfig rest.Config
}
)

func NewProject(k8s *rest.Config) *ProjectHandler {
return &ProjectHandler{k8sClusterConfig: k8s}
func NewProject(k8s rest.Config) *ProjectHandler {
return &ProjectHandler{k8sUserConfig: k8s, k8sAppConfig: k8s}
}

func (h *ProjectHandler) Get(c echo.Context) error {
Expand Down Expand Up @@ -53,13 +54,13 @@ func (h *ProjectHandler) Get(c echo.Context) error {
}

func (h *ProjectHandler) getUserProjects(username string, groups []string) ([]string, error) {
h.k8sClusterConfig.Impersonate.UserName = username
h.k8sUserConfig.Impersonate.UserName = username

if len(groups) > 0 {
h.k8sClusterConfig.Impersonate.Groups = groups
h.k8sUserConfig.Impersonate.Groups = groups
}

projectClientset, err := projectv1.NewForConfig(h.k8sClusterConfig)
projectClientset, err := projectv1.NewForConfig(&h.k8sUserConfig)
if err != nil {
logrus.Error(err)
return nil, err
Expand All @@ -80,7 +81,7 @@ func (h *ProjectHandler) getUserProjects(username string, groups []string) ([]st
}

func (h *ProjectHandler) getUserGroups(username string) ([]string, error) {
groupClientset, err := groupv1.NewForConfig(h.k8sClusterConfig)
groupClientset, err := groupv1.NewForConfig(&h.k8sAppConfig)
if err != nil {
logrus.Error(err)
return nil, err
Expand Down

0 comments on commit 0edf9b1

Please sign in to comment.