forked from rancher/rancher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
project.go
35 lines (27 loc) · 819 Bytes
/
project.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package project
import (
mgmtv3 "github.com/rancher/types/apis/management.cattle.io/v3"
"github.com/pkg/errors"
"k8s.io/apimachinery/pkg/labels"
)
const (
System = "System"
Default = "Default"
)
const (
SystemImageVersionAnn = "field.cattle.io/systemImageVersion"
ProjectIDAnn = "field.cattle.io/projectId"
)
var (
SystemProjectLabel = map[string]string{"authz.management.cattle.io/system-project": "true"}
)
func GetSystemProject(clusterName string, projectLister mgmtv3.ProjectLister) (*mgmtv3.Project, error) {
projects, err := projectLister.List(clusterName, labels.Set(SystemProjectLabel).AsSelector())
if err != nil {
return nil, errors.Wrapf(err, "list project failed")
}
if len(projects) == 0 {
return nil, errors.New("can't find system project")
}
return projects[0], nil
}