Skip to content

Commit

Permalink
fix test user (#358)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiancandevloper authored Dec 8, 2023
1 parent 27f3b69 commit 91a6a21
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 103 deletions.
5 changes: 1 addition & 4 deletions pkg/ctrlmgr/controllers/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ package controllers

import (
"errors"
"github.com/kubecube-io/kubecube/pkg/ctrlmgr/controllers/binding"

"k8s.io/apimachinery/pkg/api/meta"
"sigs.k8s.io/controller-runtime/pkg/manager"

"github.com/kubecube-io/kubecube/pkg/clog"
"github.com/kubecube-io/kubecube/pkg/ctrlmgr/controllers/binding"
cluster "github.com/kubecube-io/kubecube/pkg/ctrlmgr/controllers/cluster"
"github.com/kubecube-io/kubecube/pkg/ctrlmgr/controllers/quota"
user "github.com/kubecube-io/kubecube/pkg/ctrlmgr/controllers/user"
"github.com/kubecube-io/kubecube/pkg/ctrlmgr/options"
"github.com/kubecube-io/kubecube/pkg/utils/ctrlopts"
)
Expand All @@ -36,7 +34,6 @@ var setupFns = make(ctrlopts.ControllerInitFns)
func init() {
// setup controllers
setupFns["cluster"] = cluster.SetupWithManager
setupFns["user"] = user.SetupWithManager
setupFns["cuberesourcequota"] = quota.SetupWithManager
setupFns["clusterrolebinding"] = binding.SetupClusterRoleBindingReconcilerWithManager
setupFns["rolebinding"] = binding.SetupRoleBindingReconcilerWithManager
Expand Down
94 changes: 0 additions & 94 deletions pkg/ctrlmgr/controllers/user/user_controller.go

This file was deleted.

20 changes: 15 additions & 5 deletions pkg/utils/transition/transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,21 @@ package transition
import (
"context"
"fmt"
tenantv1 "github.com/kubecube-io/kubecube/pkg/apis/tenant/v1"
"github.com/kubecube-io/kubecube/pkg/clog"
"sort"
"strings"

userv1 "github.com/kubecube-io/kubecube/pkg/apis/user/v1"
"github.com/kubecube-io/kubecube/pkg/utils/constants"
v1 "k8s.io/api/core/v1"
rbacv1 "k8s.io/api/rbac/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/client-go/util/retry"
"sigs.k8s.io/controller-runtime/pkg/client"

tenantv1 "github.com/kubecube-io/kubecube/pkg/apis/tenant/v1"
userv1 "github.com/kubecube-io/kubecube/pkg/apis/user/v1"
"github.com/kubecube-io/kubecube/pkg/clog"
"github.com/kubecube-io/kubecube/pkg/utils/constants"
)

func SubNs2Ns(subNs *SubnamespaceAnchor) *v1.Namespace {
Expand Down Expand Up @@ -204,7 +207,14 @@ func addUserToProject(user *userv1.User, project string, tenant string) {
Project: project,
Tenant: tenant,
})
user.Status.BelongProjectInfos = projectSet.UnsortedList()
list := projectSet.UnsortedList()
sort.Slice(list, func(i, j int) bool {
if list[i].Tenant != list[j].Tenant {
return strings.Compare(list[i].Tenant, list[j].Tenant) < 0
}
return strings.Compare(list[i].Project, list[j].Project) < 0
})
user.Status.BelongProjectInfos = list
clog.Info("ensure user %v belongs to project %v", user.Name, project)
}

Expand Down

0 comments on commit 91a6a21

Please sign in to comment.