aclscope

package
v1.19.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var KindToLegacy = map[Scope]Scope{
	"KubernetesCluster": "cluster",
	"Project":           "project",
	"Workspace":         "workspace",
	"VirtualMachine":    "virtualmachine",
	"BackupJob":         "backup",
	"Datacenter":        "datacenter",
	"Machine":           "machine",
}

KindToLegacy maps resource Kind names back to legacy V2 scope names. Used when returning data to V2 API consumers that expect the old naming.

View Source
var KindToLegacySubject = map[Subject]Subject{
	"KubernetesCluster": "cluster",
	"Project":           "project",
	"Workspace":         "workspace",
	"VirtualMachine":    "virtualmachine",
	"BackupJob":         "backup",
	"Datacenter":        "datacenter",
	"Machine":           "machine",
}

KindToLegacySubject maps resource Kind subject names back to legacy V2 subject names.

View Source
var LegacySubjectToKind = map[Subject]Subject{
	"cluster":        "KubernetesCluster",
	"project":        "Project",
	"workspace":      "Workspace",
	"virtualmachine": "VirtualMachine",
	"backup":         "BackupJob",
	"datacenter":     "Datacenter",
	"machine":        "Machine",
}

LegacySubjectToKind maps legacy V2 subject names (used with scope "ror") to resource Kind names. These represent type-level grants (e.g. "can manage all clusters").

View Source
var LegacyToKind = map[Scope]Scope{
	"cluster":        "KubernetesCluster",
	"project":        "Project",
	"workspace":      "Workspace",
	"virtualmachine": "VirtualMachine",
	"backup":         "BackupJob",
	"datacenter":     "Datacenter",
	"machine":        "Machine",
}

LegacyToKind maps legacy V2 scope names to resource Kind names. Used to translate V2 API calls to the Kind-based scope values stored in the database after the scope migration.

Functions

This section is empty.

Types

type Scope

type Scope string

Scope represents the scope of an ACL entry. Valid values are known resource kinds (e.g. "cluster", "project") or system identifiers (e.g. "ror", "all").

const (
	ScopeUnknown        Scope = "UNKNOWN"
	ScopeRor            Scope = "ror"
	ScopeCluster        Scope = "KubernetesCluster"
	ScopeProject        Scope = "Project"
	ScopeDatacenter     Scope = "Datacenter"
	ScopeVirtualMachine Scope = "VirtualMachine"
	ScopeMachine        Scope = "Machine"
	ScopeBackup         Scope = "BackupJob"
	ScopeAll            Scope = "all"
	ScopeSpam           Scope = "spam"
)

func GetScopes

func GetScopes() []Scope

GetScopes returns all valid scopes.

func (Scope) GetSubjects

func (s Scope) GetSubjects(ctx context.Context) []Subject

GetSubjects returns valid subjects for a given scope.

func (Scope) IsValid

func (s Scope) IsValid() bool

IsValid validates the scope

func (Scope) ToKind

func (s Scope) ToKind() Scope

ToKind translates a legacy scope to its Kind equivalent. If no mapping exists, returns the scope unchanged (it may already be a Kind).

func (Scope) ToLegacy

func (s Scope) ToLegacy() Scope

ToLegacy translates a Kind-based scope to its legacy V2 equivalent. If no mapping exists, returns the scope unchanged.

type Subject

type Subject string

Subject represents the subject of an ACL entry. This is the identifier of the specific object, e.g. a cluster ID, project ID, or "All".

const (
	SubjectUnknown        Subject = "UNKNOWN"
	SubjectCluster        Subject = "cluster"
	SubjectProject        Subject = "project"
	SubjectGlobal         Subject = "globalscope"
	SubjectAcl            Subject = "acl"
	SubjectApiKey         Subject = "apikey"
	SubjectDatacenter     Subject = "datacenter"
	SubjectWorkspace      Subject = "workspace"
	SubjectPrice          Subject = "price"
	SubjectVirtualMachine Subject = "virtualmachine"
	SubjectBackup         Subject = "backup"
	SubjectAll            Subject = "all"
	SubjectSpamGit        Subject = "spamgit"
)

func GetValidSubjects

func GetValidSubjects() []Subject

GetValidSubjects returns all valid subjects for the "ror" scope.

func (Subject) HasValidScope

func (s Subject) HasValidScope(scope Scope) bool

HasValidScope checks if the subject is valid for the given scope.

func (Subject) ToKind

func (s Subject) ToKind() Subject

ToKind translates a legacy subject to its Kind equivalent. If no mapping exists, returns the subject unchanged.

func (Subject) ToLegacy

func (s Subject) ToLegacy() Subject

ToLegacy translates a Kind-based subject to its legacy V2 equivalent. If no mapping exists, returns the subject unchanged.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL