project

package
v0.11.8 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 14 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package project is the domain layer for the Project entity — the unit inside a Team that owns Policies, Keys, and user-created HostKeys. A Project's owner is always its Team (owner.kind=team, owner.id=teamId); rows owned by a Project carry owner.kind=project.

Authorization (who in the team may touch a project's rows) lives in app/authz; this package validates shape only.

Index

Constants

View Source
const LegacyID = "00000000-0000-7000-8000-000000000001"

LegacyID is the id of the `legacy` project the tenancy migration creates for keys that predate projects. Fixed so the data plane can tell it apart from a project an operator later names `legacy`; ids are server-minted, so no other row can claim it.

Variables

This section is empty.

Functions

func OfTeam

func OfTeam(teamID string, projects []*Project, gone Gone, visible Visible) (named []string, hidden int)

OfTeam names, as "Project/name", every project in projects under team id the caller may see, and counts the rest.

Types

type DependentsError

type DependentsError struct {
	Rows   []string
	Hidden int
}

DependentsError refuses deleting a team or project that still has rows under it. The caller names the team or project. Hidden rows still block but are only counted.

func (*DependentsError) Error

func (e *DependentsError) Error() string

type Gone

type Gone func(kind, id string) bool

Gone reports a row the caller is deleting in the same operation, keyed by manifest kind and id. Such a row is not in the way.

type Project

type Project struct {
	Meta meta.Metadata `json:"metadata" yaml:"metadata"`
	Spec Spec          `json:"spec"     yaml:"spec"`
}

Project is a Team-owned grouping of request-authoring resources.

func FromDirectory added in v0.10.8

func FromDirectory(r *directory.Project) (*Project, error)

FromDirectory is a directory row as a Project.

func (*Project) IsEnabled

func (p *Project) IsEnabled() bool

IsEnabled returns true when Enabled is unset or explicitly true.

func (*Project) StampOwner

func (p *Project) StampOwner()

StampOwner sets Meta.Owner to the project's Team. Called by every write path (translate, CRUD guard) so Owner never drifts from TeamID.

func (*Project) ToDirectory added in v0.10.8

func (p *Project) ToDirectory() (*directory.Project, error)

ToDirectory is p as the directory stores it.

func (*Project) Validate

func (p *Project) Validate() error

Validate runs intra-row rules via the shared meta.Validator and enforces:

  • Owner.Kind is team; Owner.ID, when set, equals Spec.TeamID.

type Rows

type Rows struct {
	ServiceAccounts []*serviceaccount.ServiceAccount
	Keys            []*key.Key
	Policies        []*policy.Policy
	HostKeys        []*hostkey.HostKey
	RateLimits      []*ratelimit.RateLimit
	PolicyBindings  []*policybinding.PolicyBinding
}

Rows are the rows that can live under a project. Deleting the project would cascade through the foreign keys to its service accounts, their keys and its policy bindings, and leave its policies, host keys and rate limits owned by a project that no longer exists — so apply's prune refuses while any remain.

func (Rows) Dependents

func (r Rows) Dependents(id string, gone Gone, visible Visible) (named []string, hidden int)

Dependents names, as "Kind/name", every row in rows under project id the caller may see, and counts the rest.

type Spec

type Spec struct {
	// TeamID is the owning Team. Required; mirrors Meta.Owner.ID.
	TeamID string `json:"teamId" yaml:"teamId" validate:"required,uuid"`

	// Enabled defaults to true when nil.
	Enabled *bool `json:"enabled,omitempty" yaml:"enabled,omitempty"`

	// Budget caps spend for this project alone.
	Budget *team.Budget `json:"budget,omitempty" yaml:"budget,omitempty" validate:"omitempty"`
}

Spec carries the parent Team, the enabled flag, and the spend cap.

type Store

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

func NewStore

func NewStore(db storage.DB) *Store

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, id string) error

func (*Store) Directory added in v0.10.8

func (s *Store) Directory() directory.Store[directory.Project]

Directory is the auth module's store under this one, for writes that run through the directory.

func (*Store) Get

func (s *Store) Get(ctx context.Context, id string) (*Project, error)

Get returns (nil, nil) when no row has id.

func (*Store) List

func (s *Store) List(ctx context.Context) ([]*Project, error)

func (*Store) Upsert

func (s *Store) Upsert(ctx context.Context, p *Project) error

Upsert expects Meta.ID set by the caller and re-derives Owner from TeamID.

type Visible added in v0.10.1

type Visible func(kind string, m meta.Metadata) bool

Visible reports a row the caller may see, keyed by manifest kind. Nil sees every row.

Jump to

Keyboard shortcuts

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