Files
zitadel/backend/v3/domain/projectgrantstate_enumer.go
T
9274e008fe feat(rt): project grants (#10951)
This pull request introduces a new feature that allows adding, updating,
and querying project grants The changes are primarily in the backend and
include new database tables, repositories, and domain logic to support
project grants.

## Changes

* New `project_grants` table: A new table `zitadel.project_grants` is
introduced to store project grants It includes columns for
`instance_id`, `id`, `state`, `project_id`, `granted_org_id` and
`granting_org_id`.
* New `ProjectGrantRepository`: A new repository
`ProjectGrantRepository` is created to handle all database operations
for project grants. It provides methods to `Get`, `List`, `Create`,
`Update`, and `Delete`.
* New `project_grant_roles` table: A new table
`zitadel.project_grant_roles` is introduced to store project grant roles
It includes columns for `instance_id`, `grant_id`, `key`, `project_id`
and `project_org_id`.
* New `ProjectGrantRoleRepository`: A new repository
`ProjectGrantRoleRepository` is created to handle all database
operations for project grant roles. It provides methods to `Get`,
`List`, `Add`, and `Delete`.
* New `project_grant_relational_projection`: A new projection
`project_grant_relational_projection` is added to update the
`zitadel.project_grants` and `zitadel.project_grant_roles` tables based
on events. It handles all project grant events.
* Updated `ProjectRepository`: The `ProjectRepository` is updated to
list granted projects.

# Additional Context

Closes https://github.com/zitadel/zitadel/issues/10766

---------

Co-authored-by: Stefan Benz <[email protected]>
Co-authored-by: Marco A. <[email protected]>
Co-authored-by: Silvan <[email protected]>
2025-11-14 11:04:16 +00:00

110 lines
2.9 KiB
Go

// Code generated by "enumer -type ProjectGrantState -transform lower -trimprefix ProjectGrantState -sql"; DO NOT EDIT.
package domain
import (
"database/sql/driver"
"fmt"
"strings"
)
const _ProjectGrantStateName = "activeinactive"
var _ProjectGrantStateIndex = [...]uint8{0, 6, 14}
const _ProjectGrantStateLowerName = "activeinactive"
func (i ProjectGrantState) String() string {
if i >= ProjectGrantState(len(_ProjectGrantStateIndex)-1) {
return fmt.Sprintf("ProjectGrantState(%d)", i)
}
return _ProjectGrantStateName[_ProjectGrantStateIndex[i]:_ProjectGrantStateIndex[i+1]]
}
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
func _ProjectGrantStateNoOp() {
var x [1]struct{}
_ = x[ProjectGrantStateActive-(0)]
_ = x[ProjectGrantStateInactive-(1)]
}
var _ProjectGrantStateValues = []ProjectGrantState{ProjectGrantStateActive, ProjectGrantStateInactive}
var _ProjectGrantStateNameToValueMap = map[string]ProjectGrantState{
_ProjectGrantStateName[0:6]: ProjectGrantStateActive,
_ProjectGrantStateLowerName[0:6]: ProjectGrantStateActive,
_ProjectGrantStateName[6:14]: ProjectGrantStateInactive,
_ProjectGrantStateLowerName[6:14]: ProjectGrantStateInactive,
}
var _ProjectGrantStateNames = []string{
_ProjectGrantStateName[0:6],
_ProjectGrantStateName[6:14],
}
// ProjectGrantStateString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func ProjectGrantStateString(s string) (ProjectGrantState, error) {
if val, ok := _ProjectGrantStateNameToValueMap[s]; ok {
return val, nil
}
if val, ok := _ProjectGrantStateNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to ProjectGrantState values", s)
}
// ProjectGrantStateValues returns all values of the enum
func ProjectGrantStateValues() []ProjectGrantState {
return _ProjectGrantStateValues
}
// ProjectGrantStateStrings returns a slice of all String values of the enum
func ProjectGrantStateStrings() []string {
strs := make([]string, len(_ProjectGrantStateNames))
copy(strs, _ProjectGrantStateNames)
return strs
}
// IsAProjectGrantState returns "true" if the value is listed in the enum definition. "false" otherwise
func (i ProjectGrantState) IsAProjectGrantState() bool {
for _, v := range _ProjectGrantStateValues {
if i == v {
return true
}
}
return false
}
func (i ProjectGrantState) Value() (driver.Value, error) {
return i.String(), nil
}
func (i *ProjectGrantState) Scan(value interface{}) error {
if value == nil {
return nil
}
var str string
switch v := value.(type) {
case []byte:
str = string(v)
case string:
str = v
case fmt.Stringer:
str = v.String()
default:
return fmt.Errorf("invalid value of ProjectGrantState: %[1]T(%[1]v)", value)
}
val, err := ProjectGrantStateString(str)
if err != nil {
return err
}
*i = val
return nil
}