directory

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package directory keeps the tenancy virtual workspace's in-memory answer state: every Tenant, Project and Membership across all organization workspaces, indexed for the one question the VW answers — "what does this identity belong to?".

The directory is written by informer-driven controllers and read on every SelfTenancyReview, so writes take the lock briefly per object and reads assemble the answer under a read lock. Objects are keyed by (logical cluster, name): names only mean something inside their organization workspace.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Directory

type Directory struct {
	// contains filtered or unexported fields
}

Directory is safe for concurrent use.

The three kinds arrive from two different tiers: Tenants from the platform workspace, Projects and Memberships from inside each tenant's own workspace. They are joined on the tenant's workspace cluster — a Membership belongs to the tenant whose workspace it lives in — so nothing here relies on a name matching across a workspace boundary.

func New

func New() *Directory

New returns an empty directory.

func (*Directory) Counts

func (d *Directory) Counts() (tenants, projects, memberships int)

Counts returns how many objects the directory holds, for debug output.

func (*Directory) ForgetCluster

func (d *Directory) ForgetCluster(cluster string)

ForgetCluster drops everything recorded for one organization workspace, for when a cluster leaves the fleet.

func (*Directory) MembershipsIn

func (d *Directory) MembershipsIn(cluster string) []NamedMembership

MembershipsIn lists every grant recorded in one tenant workspace, sorted by name so the answer is stable.

Unlike ReviewFor this is not filtered to one identity: it reports who else holds what, which only an administrator of that tenant may see. Callers are responsible for having established that first.

func (*Directory) Ready

func (d *Directory) Ready() bool

Ready reports whether the initial sync completed.

func (*Directory) RemoveMembership

func (d *Directory) RemoveMembership(k Key)

RemoveMembership forgets a membership.

func (*Directory) RemoveProject

func (d *Directory) RemoveProject(k Key)

RemoveProject forgets a project.

func (*Directory) RemoveTenant

func (d *Directory) RemoveTenant(k Key)

RemoveTenant forgets a tenant.

func (*Directory) ReviewFor

func (d *Directory) ReviewFor(username string, groups []string, endpointFor func(cluster string) string) []tenancyv1alpha1.TenantClaim

ReviewFor assembles the SelfTenancyReview answer for one identity. endpointFor turns a workspace's logical cluster name into the URL the caller can reach it at; it is only called for non-empty clusters.

A caller reaches a tenant if any membership for that tenant matches the identity — tenant-wide or on any project. Tenant-wide roles carry into every project of the tenant; project-scoped roles reach only their project. Output is sorted by name at every level so answers are stable.

func (*Directory) SetReady

func (d *Directory) SetReady()

SetReady marks the initial sync complete. Before this, reviews are refused rather than answered partially.

func (*Directory) UpsertMembership

func (d *Directory) UpsertMembership(k Key, m Membership)

UpsertMembership records a membership.

func (*Directory) UpsertProject

func (d *Directory) UpsertProject(k Key, p Project)

UpsertProject records a project.

func (*Directory) UpsertTenant

func (d *Directory) UpsertTenant(k Key, t Tenant)

UpsertTenant records a tenant.

type Key

type Key struct {
	// Cluster is the logical cluster of the organization workspace the
	// object lives in.
	Cluster string
	// Name is the object's name.
	Name string
}

Key addresses one object in one organization workspace.

type Membership

type Membership struct {
	Subject tenancyv1alpha1.Subject
	Role    string
	// Tenant is the name of the Tenant the grant applies to, in the same
	// cluster as the Membership.
	Tenant string
	// Project is empty for a tenant-wide grant.
	Project string
}

Membership is the directory's projection of a Membership object.

type NamedMembership

type NamedMembership struct {
	Name string
	Membership
}

NamedMembership is a membership together with the name of the object it was mirrored from, which is what a caller needs to delete it again.

type Project

type Project struct {
	// Tenant is the name of the owning Tenant, in the same cluster.
	Tenant           string
	DisplayName      string
	WorkspaceCluster string
}

Project is the directory's projection of a Project object.

type Tenant

type Tenant struct {
	DisplayName string
	// WorkspaceCluster is the logical cluster of the tenant's provisioned
	// workspace; empty until the operator reports it.
	WorkspaceCluster string
}

Tenant is the directory's projection of a Tenant object.

Jump to

Keyboard shortcuts

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