v1alpha1

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetupWorkspaceWebhookWithManager

func SetupWorkspaceWebhookWithManager(mgr ctrl.Manager) error

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

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

ValidateCreate ensures the requesting user is listed as an admin member of the new Workspace. Privileged callers bypass the check.

func (*WorkspaceCustomValidator) ValidateDelete

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.

Jump to

Keyboard shortcuts

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