Documentation
¶
Index ¶
- func SetupWorkspaceWebhookWithManager(mgr ctrl.Manager) error
- type WorkspaceCustomDefaulter
- type WorkspaceCustomValidator
- func (v *WorkspaceCustomValidator) ValidateCreate(ctx context.Context, ws *tenantv1alpha1.Workspace) (admission.Warnings, error)
- func (v *WorkspaceCustomValidator) ValidateDelete(ctx context.Context, ws *tenantv1alpha1.Workspace) (admission.Warnings, error)
- func (v *WorkspaceCustomValidator) ValidateUpdate(ctx context.Context, oldWorkspace, newWorkspace *tenantv1alpha1.Workspace) (admission.Warnings, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetupWorkspaceWebhookWithManager ¶
SetupWorkspaceWebhookWithManager registers the Workspace webhook.
Both hooks read through mgr.GetAPIReader() rather than the cached client: a cache lagging the API server by a moment would admit the very name conflicts these checks exist to prevent, and workspaces are few enough that the extra round trip costs nothing.
Types ¶
type WorkspaceCustomDefaulter ¶
type WorkspaceCustomDefaulter struct {
// Reader looks up existing Namespaces so a generated name is not handed out
// on top of one. Must be uncached — see SetupWorkspaceWebhookWithManager.
Reader client.Reader
}
WorkspaceCustomDefaulter sets default values on CREATE and UPDATE. It mirrors member subjects as labels so external APIs can select on them (e.g. "find all workspaces a user belongs to").
func (*WorkspaceCustomDefaulter) Default ¶
func (d *WorkspaceCustomDefaulter) Default(ctx context.Context, ws *tenantv1alpha1.Workspace) error
Default fills in a generated namespace when none was given, and makes the "user.otterscale.io/" labels mirror the current member subjects.
type WorkspaceCustomValidator ¶
type WorkspaceCustomValidator struct {
// Reader looks up existing Workspaces and Namespaces to check that the
// target namespace can still be claimed. Must be uncached — see
// SetupWorkspaceWebhookWithManager.
Reader client.Reader
// Client submits the SubjectAccessReview backing the cluster-wide access
// check. Writes never go through the cache, so the manager's client is fine.
Client client.Client
}
WorkspaceCustomValidator enforces workspace-level authorization on mutating operations: create requires the caller to list themselves as an admin member, update and delete require workspace-admin or cluster-privileged identity.
The authorization logic itself lives in internal/workspace/ for testability.
func (*WorkspaceCustomValidator) ValidateCreate ¶
func (v *WorkspaceCustomValidator) ValidateCreate(ctx context.Context, ws *tenantv1alpha1.Workspace) (admission.Warnings, error)
ValidateCreate ensures the requesting user is listed as an admin member of the new Workspace. Privileged callers bypass the check.
func (*WorkspaceCustomValidator) ValidateDelete ¶
func (v *WorkspaceCustomValidator) ValidateDelete(ctx context.Context, ws *tenantv1alpha1.Workspace) (admission.Warnings, error)
ValidateDelete ensures only workspace admins (or privileged identities) can delete a Workspace.
func (*WorkspaceCustomValidator) ValidateUpdate ¶
func (v *WorkspaceCustomValidator) ValidateUpdate(ctx context.Context, oldWorkspace, newWorkspace *tenantv1alpha1.Workspace) (admission.Warnings, error)
ValidateUpdate ensures only workspace admins (or privileged identities) can modify an existing Workspace. It checks the old object, so a user cannot grant themselves admin and approve it in the same request.