IAM: Refactor team bindings to store one pair of team and member (#111871)
* store one pair of team member in team bindings object * generate queries for sql unit tests * remove TeamBinding struct
This commit is contained in:
@@ -4,12 +4,13 @@ TeamBindingSpec: {
|
||||
#Subject: {
|
||||
// uid of the identity
|
||||
name: string
|
||||
// permission of the identity in the team
|
||||
permission: TeamPermission
|
||||
}
|
||||
|
||||
subjects: [...#Subject]
|
||||
subject: #Subject
|
||||
teamRef: TeamRef
|
||||
|
||||
// permission of the identity in the team
|
||||
permission: TeamPermission
|
||||
}
|
||||
|
||||
TeamRef:{
|
||||
|
||||
@@ -6,8 +6,6 @@ package v0alpha1
|
||||
type TeamBindingspecSubject struct {
|
||||
// uid of the identity
|
||||
Name string `json:"name"`
|
||||
// permission of the identity in the team
|
||||
Permission TeamBindingTeamPermission `json:"permission"`
|
||||
}
|
||||
|
||||
// NewTeamBindingspecSubject creates a new TeamBindingspecSubject object.
|
||||
@@ -15,14 +13,6 @@ func NewTeamBindingspecSubject() *TeamBindingspecSubject {
|
||||
return &TeamBindingspecSubject{}
|
||||
}
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type TeamBindingTeamPermission string
|
||||
|
||||
const (
|
||||
TeamBindingTeamPermissionAdmin TeamBindingTeamPermission = "admin"
|
||||
TeamBindingTeamPermissionMember TeamBindingTeamPermission = "member"
|
||||
)
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type TeamBindingTeamRef struct {
|
||||
// Name is the unique identifier for a team.
|
||||
@@ -34,16 +24,26 @@ func NewTeamBindingTeamRef() *TeamBindingTeamRef {
|
||||
return &TeamBindingTeamRef{}
|
||||
}
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type TeamBindingTeamPermission string
|
||||
|
||||
const (
|
||||
TeamBindingTeamPermissionAdmin TeamBindingTeamPermission = "admin"
|
||||
TeamBindingTeamPermissionMember TeamBindingTeamPermission = "member"
|
||||
)
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type TeamBindingSpec struct {
|
||||
Subjects []TeamBindingspecSubject `json:"subjects"`
|
||||
TeamRef TeamBindingTeamRef `json:"teamRef"`
|
||||
Subject TeamBindingspecSubject `json:"subject"`
|
||||
TeamRef TeamBindingTeamRef `json:"teamRef"`
|
||||
// permission of the identity in the team
|
||||
Permission TeamBindingTeamPermission `json:"permission"`
|
||||
}
|
||||
|
||||
// NewTeamBindingSpec creates a new TeamBindingSpec object.
|
||||
func NewTeamBindingSpec() *TeamBindingSpec {
|
||||
return &TeamBindingSpec{
|
||||
Subjects: []TeamBindingspecSubject{},
|
||||
TeamRef: *NewTeamBindingTeamRef(),
|
||||
Subject: *NewTeamBindingspecSubject(),
|
||||
TeamRef: *NewTeamBindingTeamRef(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2103,17 +2103,10 @@ func schema_pkg_apis_iam_v0alpha1_TeamBindingSpec(ref common.ReferenceCallback)
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"object"},
|
||||
Properties: map[string]spec.Schema{
|
||||
"subjects": {
|
||||
"subject": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"array"},
|
||||
Items: &spec.SchemaOrArray{
|
||||
Schema: &spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Default: map[string]interface{}{},
|
||||
Ref: ref("github.com/grafana/grafana/apps/iam/pkg/apis/iam/v0alpha1.TeamBindingspecSubject"),
|
||||
},
|
||||
},
|
||||
},
|
||||
Default: map[string]interface{}{},
|
||||
Ref: ref("github.com/grafana/grafana/apps/iam/pkg/apis/iam/v0alpha1.TeamBindingspecSubject"),
|
||||
},
|
||||
},
|
||||
"teamRef": {
|
||||
@@ -2122,8 +2115,16 @@ func schema_pkg_apis_iam_v0alpha1_TeamBindingSpec(ref common.ReferenceCallback)
|
||||
Ref: ref("github.com/grafana/grafana/apps/iam/pkg/apis/iam/v0alpha1.TeamBindingTeamRef"),
|
||||
},
|
||||
},
|
||||
"permission": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "permission of the identity in the team",
|
||||
Default: "",
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
},
|
||||
Required: []string{"subjects", "teamRef"},
|
||||
Required: []string{"subject", "teamRef", "permission"},
|
||||
},
|
||||
},
|
||||
Dependencies: []string{
|
||||
@@ -2210,16 +2211,8 @@ func schema_pkg_apis_iam_v0alpha1_TeamBindingspecSubject(ref common.ReferenceCal
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
"permission": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "permission of the identity in the team",
|
||||
Default: "",
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
},
|
||||
Required: []string{"name", "permission"},
|
||||
Required: []string{"name"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user