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 ¶
- type Directory
- func (d *Directory) Counts() (tenants, projects, memberships int)
- func (d *Directory) ForgetCluster(cluster string)
- func (d *Directory) MembershipsIn(cluster string) []NamedMembership
- func (d *Directory) Ready() bool
- func (d *Directory) RemoveMembership(k Key)
- func (d *Directory) RemoveProject(k Key)
- func (d *Directory) RemoveTenant(k Key)
- func (d *Directory) ReviewFor(username string, groups []string, endpointFor func(cluster string) string) []tenancyv1alpha1.TenantClaim
- func (d *Directory) SetReady()
- func (d *Directory) UpsertMembership(k Key, m Membership)
- func (d *Directory) UpsertProject(k Key, p Project)
- func (d *Directory) UpsertTenant(k Key, t Tenant)
- type Key
- type Membership
- type NamedMembership
- type Project
- type Tenant
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 (*Directory) ForgetCluster ¶
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) RemoveMembership ¶
RemoveMembership forgets a membership.
func (*Directory) RemoveProject ¶
RemoveProject forgets a project.
func (*Directory) RemoveTenant ¶
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 ¶
UpsertProject records a project.
func (*Directory) UpsertTenant ¶
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.