Documentation
¶
Overview ¶
Package pseudo turns a pseudo object, a request shape that stands for several real rows, into those rows and writes them together. A pseudo object has no table, no id and no read: the real rows are what is stored, checked and audited. Each kind's expansion is a pure function from its body and what it read to the steps in write order, each a row to create, update or delete with the JSON pointer of the part of the body it came from; Writer runs such a list in one transaction, each step through the caller's write function, then checks the whole result against the plans before the commit.
Out of scope: the checks one row passes (the caller's create function runs the ones the row's own create route runs), HTTP, and audit.
Index ¶
- Constants
- Variables
- func AfterCheck(ctx context.Context, fn func(plan.Findings) error) context.Context
- func CheckAccess(body Access) error
- func CheckAgent(body Agent) error
- func CheckAgentRemoval(body AgentRemoval) error
- func CheckHostKey(body HostKeyForm) error
- func CheckHostKeyValue(s HostKeyFormSpec, hostName string, keyless bool) error
- func CheckLimits(body Limits) error
- func CheckTarget(t Target) error
- func Record[T any](ctx context.Context, id string, row *T)
- func Values(rows []Row) []any
- type AboveError
- type Access
- type AccessChange
- type AccessReads
- type AccessSpec
- type AccountPolicy
- type Agent
- type AgentAccess
- type AgentKey
- type AgentMetadata
- type AgentOwner
- type AgentReads
- type AgentRemoval
- type AgentRemovalSpec
- type AgentSpec
- type BodyError
- type CreateFunc
- type ExpandFunc
- type HiddenPoolsError
- type HostKeyForm
- type HostKeyFormAccount
- type HostKeyFormMetadata
- type HostKeyFormSpec
- type HostKeyReads
- type IssuesError
- type KeptReason
- type KeptRow
- type Labelled
- type LimitLink
- type Limits
- type LimitsChange
- type LimitsMetadata
- type LimitsReads
- type LimitsSpec
- type Namer
- type Op
- type Organization
- type OrganizationError
- type Outside
- type PolicyCase
- type PolicyChange
- type PolicyCopy
- type PolicyReads
- type Removal
- type RemovalChange
- type RemovalReads
- type Row
- type RowError
- type Scope
- type ShareReceiver
- type Target
- type Transactor
- type UncarriedError
- type UndoError
- type Writer
Constants ¶
const AccessLabel = "access-for"
AccessLabel is the label carrying the target account's id on the pools the access kind makes.
const AgentLabel = "agent-id"
AgentLabel is the label carrying the service account's id on the pools and policy made for it.
Variables ¶
var ErrNoPlans = errors.New("pseudo: no published plans to check against")
ErrNoPlans is a write with no published plans to check it against.
Functions ¶
func AfterCheck ¶
AfterCheck returns ctx carrying fn for the pseudo write run under it: once the plan check passed, fn is given what it found, with the view of the plans with the steps applied and its baseline, before the commit and while the check's slot is held; an error from fn refuses the write. A kind reads there what its rows make of the plans.
func CheckAccess ¶
CheckAccess refuses a body whose target or access is malformed, access left out included, or names a row by anything but its id; it needs no read, so a caller runs it before reading what the body names. ExpandAccess runs it too.
func CheckAgent ¶
CheckAgent refuses a body that names no owner, its access twice, not at all, or half, or a row by anything but its id; it needs no read, so a caller runs it before reading what the body names. ExpandAgent runs it too.
func CheckAgentRemoval ¶
func CheckAgentRemoval(body AgentRemoval) error
CheckAgentRemoval refuses a body that names the service account or a kept row by anything but its id, or a kept row twice; it needs no read. ExpandAgentRemoval runs it too.
func CheckHostKey ¶
func CheckHostKey(body HostKeyForm) error
CheckHostKey refuses a body that names a row by anything but its id, its account twice or not at all, its value twice, or a receiver twice; it needs no read, so a caller runs it before reading what the body names. ExpandHostKey runs it too.
func CheckHostKeyValue ¶
func CheckHostKeyValue(s HostKeyFormSpec, hostName string, keyless bool) error
CheckHostKeyValue refuses a value for a host that takes no key, and none for a host that takes one.
func CheckLimits ¶
CheckLimits refuses a body whose target is malformed or that names not exactly one limit; it needs no read, so a caller runs it before reading what the body names. ExpandLimits runs it too.
func CheckTarget ¶
CheckTarget refuses a target of no kind the step takes, or named by anything but its id; it needs no read.
Types ¶
type AboveError ¶
type AboveError struct{ Scope Scope }
AboveError refuses a change of an account whose policy is set above the caller; it names only the scope.
func (*AboveError) Error ¶
func (e *AboveError) Error() string
type Access ¶
type Access struct {
Spec AccessSpec `json:"spec" doc:"The target and its whole access."`
}
Access is the body of POST /pseudo-access.
type AccessChange ¶
type AccessChange struct {
PolicyChange
// Unchanged is set when nothing needed writing: an account naming no policy already uses every credential and every model.
Unchanged bool
// HiddenPoolsKept counts the pool links the caller may not see that the policy keeps.
HiddenPoolsKept int
}
AccessChange is what an access body expands to.
func ExpandAccess ¶
func ExpandAccess(body Access, in AccessReads) (AccessChange, error)
ExpandAccess returns the steps that set the target's access: the shares access.accountIds needs, one pool per host (the labelled pool for that host updated in place when only the policy changed in place links it, else a new one labelled AccessLabel), the policy step setting the policy's pools to poolIds then those pools (none with everyCredential) and its models to access.models, then the delete of each labelled pool the policy no longer links that nothing else links and the caller may delete; one the caller may not delete is only unlinked. A pool link the caller may not see is kept where it was in the policy's order, in place and in a copy, as an update of the policy keeps the links it holds.
type AccessReads ¶
type AccessReads struct {
Policy PolicyReads
// Accounts are the accounts access.accountIds names, by id; HostNames and KeylessHosts are of their hosts.
Accounts map[string]*account.Account
HostNames map[string]string
KeylessHosts map[string]bool
// Reaches reports whether a pool of the target's scope may list the real account a without a share; Shares are that scope's shares, by the real account's id.
Reaches func(a *account.Account) bool
// OwnerName is the name of the target's scope; a share's name carries it.
OwnerName string
// Labelled are the pools this kind made for the target: labelled AccessLabel=<target account id>, owned by the target's scope, seen by the caller and linked by no policy but the one the account is under. LinkedBy are the ids of the policies linking each, by pool id; LabelledDeletable those the caller may delete.
Labelled []*pool.Pool
LinkedBy map[string][]string
LabelledDeletable map[string]bool
// HiddenPools are the pools the policy links that the caller may not see, by id.
HiddenPools map[string]bool
}
AccessReads is what expanding an access body reads besides it.
type AccessSpec ¶
type AccessSpec struct {
Target Target `json:"target" doc:"The team, project or service account whose account's access is set."`
Access *AgentAccess `` /* 301-byte string literal not displayed */
}
AccessSpec names the target and what it may use.
type AccountPolicy ¶
AccountPolicy sets an existing account's policy with the write PUT /accounts/{ref}/policy makes, an update of the account; with no PolicyID it clears the policy. Set is the account as that write left it, what the plan check sees.
type Agent ¶
type Agent struct {
Metadata AgentMetadata `json:"metadata" doc:"The service account's metadata."`
Spec AgentSpec `json:"spec" doc:"What the service account may use, and its first key."`
}
Agent is the body of POST /pseudo-agents.
type AgentAccess ¶
type AgentAccess struct {
EveryCredential bool `` /* 255-byte string literal not displayed */
PoolIDs []string `` /* 345-byte string literal not displayed */
AccountIDs []string `` /* 620-byte string literal not displayed */
Models []string `` /* 176-byte string literal not displayed */
}
AgentAccess is what the service account may use.
type AgentKey ¶
type AgentKey struct {
DisplayName string `json:"displayName,omitempty" doc:"Free-text name of the key; its slug is derived from it."`
ExpiresAt *time.Time `json:"expiresAt,omitempty" doc:"When the key stops authenticating. Omitted or null never expires."`
PassthroughAllowed bool `json:"passthroughAllowed,omitempty" doc:"Let the key send its own upstream credential in proxy mode."`
PayloadLoggingEnabled bool `json:"payloadLoggingEnabled,omitempty" doc:"Capture request and response bodies of this key's requests."`
}
AgentKey is the service account's first key.
type AgentMetadata ¶
type AgentMetadata struct {
Name string `` /* 208-byte string literal not displayed */
DisplayName string `json:"displayName,omitempty" doc:"Free-text name shown in the UI."`
Description string `json:"description,omitempty" doc:"Free-text description of the service account."`
Labels map[string]string `json:"labels,omitempty" doc:"Labels of the service account."`
Owner AgentOwner `` /* 164-byte string literal not displayed */
}
AgentMetadata is the service account's metadata.
type AgentOwner ¶
type AgentOwner struct {
Kind meta.OwnerKind `json:"kind,omitempty" doc:"Kind of the owning scope: one a service account may be owned by."`
ID string `json:"id,omitempty" doc:"Id of the owning scope."`
}
AgentOwner is the scope a service account is owned by; its kinds are serviceaccount.OwnerKinds.
func (AgentOwner) TransformSchema ¶
TransformSchema lists the owner kinds a service account takes, so the documented choices follow serviceaccount.OwnerKinds.
type AgentReads ¶
type AgentReads struct {
// Accounts are the accounts access.accountIds names, by id.
Accounts map[string]*account.Account
// HostNames are the names of those accounts' hosts, by id.
HostNames map[string]string
// KeylessHosts are those of the hosts that take no key (host.Spec.NoAuth), by id.
KeylessHosts map[string]bool
// Reaches reports whether a pool of the owner may list the real account a without a share.
Reaches func(a *account.Account) bool
Shares map[string]*account.Account
// OwnerName is the name of the owner scope; a share's name carries it.
OwnerName string
// PolicyName is the name of the policy policyId names, for the answer.
PolicyName string
Names *Namer
NewID func() string
}
AgentReads is what expanding an agent reads besides its body.
type AgentRemoval ¶
type AgentRemoval struct {
Spec AgentRemovalSpec `json:"spec" doc:"The service account to remove, and what of its labelled rows to keep."`
}
AgentRemoval is the body of POST /pseudo-agent-removals.
type AgentRemovalSpec ¶
type AgentRemovalSpec struct {
ServiceAccountID string `json:"serviceAccountId" doc:"Id (metadata.id) of the service account; a slug answers 400."`
Keep []string `` /* 186-byte string literal not displayed */
Expect []string `` /* 180-byte string literal not displayed */
}
AgentRemovalSpec names the service account, the labelled rows to keep, and the set a dry run answered.
type AgentSpec ¶
type AgentSpec struct {
PolicyID string `` /* 163-byte string literal not displayed */
Access *AgentAccess `` /* 132-byte string literal not displayed */
Key *AgentKey `json:"key,omitempty" doc:"The service account's first key. Omitted makes no key."`
}
AgentSpec is what the service account may use, through an existing policy or one made for it, and its first key.
type BodyError ¶
BodyError is a pseudo body that expands to no rows; Pointer names the part at fault.
type CreateFunc ¶
CreateFunc runs the checks the route of row's step runs (its kind's create, update or delete, by row.Op) and writes it through tx.
type ExpandFunc ¶
ExpandFunc reads what a kind's expansion needs through tx and returns the steps in write order.
type HiddenPoolsError ¶
type HiddenPoolsError struct{ Count int }
HiddenPoolsError refuses everyCredential on a policy that links pools the caller may not see: the policy keeps those links, so it would reach only them, the opposite of every credential.
func (*HiddenPoolsError) Error ¶
func (e *HiddenPoolsError) Error() string
type HostKeyForm ¶
type HostKeyForm struct {
Metadata HostKeyFormMetadata `json:"metadata" doc:"The host key's metadata; its owner owns the account too."`
Spec HostKeyFormSpec `json:"spec" doc:"The key's value, the account it belongs to, the account's tier and who the account is shared with."`
}
HostKeyForm is the body of POST /pseudo-host-keys.
type HostKeyFormAccount ¶
type HostKeyFormAccount struct {
DisplayName string `json:"displayName,omitempty" doc:"Free-text name of the account; its slug is derived from it."`
}
HostKeyFormAccount is the new account a key belongs to.
type HostKeyFormMetadata ¶
type HostKeyFormMetadata struct {
Name string `json:"name,omitempty" doc:"Slug of the host key. Omitted: derived from displayName, suffixed -2, -3, … while taken."`
DisplayName string `json:"displayName,omitempty" doc:"Free-text name of the host key."`
Description string `json:"description,omitempty" doc:"Free-text description of the host key."`
Labels map[string]string `json:"labels,omitempty" doc:"Labels of the host key."`
Owner meta.Owner `` /* 155-byte string literal not displayed */
}
HostKeyFormMetadata is the host key's metadata.
type HostKeyFormSpec ¶
type HostKeyFormSpec struct {
HostID string `json:"hostId" doc:"Id (metadata.id) of the host the key authenticates to; a slug answers 400."`
Value string `` /* 263-byte string literal not displayed */
ValueFrom *hostkey.ValueFrom `` /* 206-byte string literal not displayed */
PricingStrategy string `` /* 135-byte string literal not displayed */
AccountID string `` /* 189-byte string literal not displayed */
Account *HostKeyFormAccount `` /* 143-byte string literal not displayed */
TierPolicyID string `` /* 247-byte string literal not displayed */
}
HostKeyFormSpec is the key's value, its account, the account's tier and who the account is shared with.
type HostKeyReads ¶
type HostKeyReads struct {
// Account is the account accountId names; nil for a new one.
Account *account.Account
// OwnerAccounts are the owner's provider accounts at the host that the caller sees.
OwnerAccounts []*account.Account
HostName string
// Keyless reports whether the host takes no key (host.Spec.NoAuth).
Keyless bool
// Tier is the policy tierPolicyId names; nil when it is missing or the caller may not see it, which the account's own checks answer.
Tier *policy.Policy
// Detected is the organization the host named for the value; nil when it named none.
Detected *Organization
// Receivers are where each shareWith entry stands, in order.
Receivers []ShareReceiver
// HostKeyID is the host key's id, minted before the transaction: its value is sealed under it first.
HostKeyID string
Names *Namer
NewID func() string
}
HostKeyReads is what expanding a host key reads besides its body.
type IssuesError ¶
IssuesError is a set of rows the plan check refused: Issues are the errors the rows would raise that the live plans do not have.
func (*IssuesError) Error ¶
func (e *IssuesError) Error() string
type KeptReason ¶
type KeptReason string
KeptReason says why a labelled policy or pool stays.
const ( // KeptInUse: an account or policy the request does not delete still uses it, seen by the caller or not. KeptInUse KeptReason = "in_use" // KeptByRequest: spec.keep names it. KeptByRequest KeptReason = "kept_by_request" // KeptNotVisible: it is owned by the service account's scope, but the caller may not see it. KeptNotVisible KeptReason = "not_visible" // KeptNotDeletable: it is owned outside the service account's scope, or its delete's grant or governance refuses the caller. KeptNotDeletable KeptReason = "not_deletable" )
type KeptRow ¶
type KeptRow struct {
Kind string
Meta *meta.Metadata
Visible bool
Reason KeptReason
}
KeptRow is a labelled row that stays, with why.
type Labelled ¶
type Labelled struct {
// Kind is policy or pool; Value is the *policy.Policy or *pool.Pool, Meta its metadata.
Kind string
Meta *meta.Metadata
Value any
// Visible: the caller may see it. InScope: the service account's owner scope owns it. Deletable: its delete's grant and governance pass for the caller.
Visible, InScope, Deletable bool
}
Labelled is a policy or pool labelled AgentLabel with the service account's id, and what the caller may do with it.
type LimitLink ¶
type LimitLink struct {
Models []string `` /* 332-byte string literal not displayed */
}
LimitLink is how the policy links the limit: the fields of its budgets or rateLimits entry.
type Limits ¶
type Limits struct {
Metadata LimitsMetadata `json:"metadata,omitempty" doc:"The budget's or rate limit's metadata; its owner is the target's scope."`
Spec LimitsSpec `json:"spec" doc:"The target and the limit."`
}
Limits is the body of POST /pseudo-limits.
type LimitsChange ¶
type LimitsChange struct {
PolicyChange
// Limit is the budget's or rate limit's row.
Limit Row
}
LimitsChange is what a limits body expands to: the policy step and the limit made.
func ExpandLimits ¶
func ExpandLimits(body Limits, in PolicyReads) (LimitsChange, error)
ExpandLimits returns the steps that put the limit on the target: the Budget or RateLimit owned by the target's scope, then the policy step adding its link to what the policy links already.
type LimitsMetadata ¶
type LimitsMetadata struct {
Name string `` /* 137-byte string literal not displayed */
DisplayName string `json:"displayName,omitempty" doc:"Free-text name shown in the UI."`
Description string `json:"description,omitempty" doc:"Free-text description."`
Labels map[string]string `json:"labels,omitempty" doc:"Labels of the budget or rate limit."`
}
LimitsMetadata is the budget's or rate limit's metadata.
type LimitsReads ¶
type LimitsReads struct {
Policy PolicyReads
}
LimitsReads is what expanding a limits body reads besides it.
type LimitsSpec ¶
type LimitsSpec struct {
Target Target `json:"target" doc:"The team, project or service account whose account the limit applies to."`
Budget *budget.Spec `` /* 178-byte string literal not displayed */
RateLimit *ratelimit.Spec `json:"rateLimit,omitempty" doc:"A rate limit, as POST /rate-limits takes its spec. Exactly one of budget and rateLimit."`
Link *LimitLink `` /* 135-byte string literal not displayed */
}
LimitsSpec names the target and the one limit to put on it.
type Namer ¶
type Namer struct {
// Taken reports whether a stored row of the API kind holds name.
Taken func(kind, name string) bool
// contains filtered or unexported fields
}
Namer mints row names as the control API's creates do: a slug of a base, suffixed -2, -3, … while a stored row of the kind holds it or an earlier row of the same expansion took it.
type Op ¶
type Op string
Op is what a step does to its row.
const ( // OpCreate makes the row; the zero Op. OpCreate Op = "" // OpUpdate replaces the stored row of the same id with the row, whose resource version is the one read in the transaction. OpUpdate Op = "update" // OpDelete deletes the stored row; the row is the one read in the transaction. OpDelete Op = "delete" )
type Organization ¶
type Organization struct {
ID, Name string
}
Organization is a provider organization a host named for a key.
type OrganizationError ¶
OrganizationError refuses a key whose provider organization does not fit the account it would join: Holder, another account of the owner at the host, holds the organization, or, with no Holder, the account names another one.
func (*OrganizationError) Error ¶
func (e *OrganizationError) Error() string
type Outside ¶
type Outside struct {
// What names what Write makes, for errors; it never carries a secret.
What string
// Write makes it; a Write that fails leaves nothing.
Write func(ctx context.Context) error
// Undo removes what Write made. It runs without the request's cancellation, and leaves alone a write the transaction committed after all.
Undo func(ctx context.Context) error
}
Outside is a write a pseudo kind makes before its rows' transaction opens, on a connection that transaction cannot share, such as a stored secret's value (see app/catalog.Stores.InTx). Writer.Run makes each one in order once the plans are loaded, never on a dry run, and undoes those it made when the transaction does not commit.
type PolicyCase ¶
type PolicyCase string
PolicyCase names what the policy step does.
const ( // CaseNone: the account names no policy; a policy is made for it and the account names it. CaseNone PolicyCase = "none" // CaseOwn: the account alone names a policy of its own scope the caller may update; that policy is changed in place. CaseOwn PolicyCase = "own" // CaseCopy: the account's policy is named by other accounts too, is a preset, or is owned elsewhere; it is copied into the account's scope, the copy changed, and the account names the copy. CaseCopy PolicyCase = "copy" // CaseAbove: the account's policy is one the caller may not see, or the caller may not change the account's policy; refused. CaseAbove PolicyCase = "above" )
type PolicyChange ¶
type PolicyChange struct {
Case PolicyCase
Rows []Row
Policy *policy.Policy
}
PolicyChange is what the step does: the case, the steps in write order, and the policy the account is under once they are written.
func ChangePolicy ¶
func ChangePolicy(in PolicyReads, change func(*policy.Spec), pointer string) (PolicyChange, error)
ChangePolicy returns the steps that put change over the policy of in.Account: none makes the account first when it is new, then a policy of change applied to an empty spec, owned by the account's scope, and sets the account's policy to it (an AccountPolicy, the write PUT /accounts/{ref}/policy makes); own updates the policy in place, or writes nothing when change leaves it as it is; copy makes a copy owned by the account's scope (models, links, description and labels), applies change, refuses with *UncarriedError links the copy would still carry that the scope may not link, then sets the account's policy to the copy, as PUT /accounts/{ref}/policy does. above is an *AboveError. pointer is the part of the body the steps come from.
type PolicyCopy ¶
PolicyCopy is Policy made as a copy of Source, with the checks POST /policies/{ref}/duplicate runs: a link taken over from Source passes as Source's own did, so a link the caller may not see is kept, while the owner rules still apply. The plan check sees Policy.
type PolicyReads ¶
type PolicyReads struct {
// Account is the target's account; AccountNew when it is not made yet and is made first.
Account *account.Account
AccountNew bool
// TargetLabel is the target's display name, or its name.
TargetLabel string
// Above is the scope owning the policy Account names, when the caller may not see that policy.
Above *Scope
// Policy is the policy Account names, nil when it names none that exists; PolicyScope is its owner.
Policy *policy.Policy
PolicyScope Scope
// AccountChangeable reports whether the caller may set Account's policy as PUT /accounts/{ref}/policy would: update on the account.
AccountChangeable bool
// Alone reports whether no other account names Policy.
Alone bool
// MayUpdate reports whether the caller may update Policy in place.
MayUpdate bool
// Uncarried counts, by kind (pool, rate-limit, budget), the links of a policy its owner may not link.
Uncarried func(p *policy.Policy) map[string]int
Names *Namer
NewID func() string
}
PolicyReads is what the policy step reads of the target's account, in the caller's view. The reads stop at the first row the caller may not see or change, which sets Above.
func (PolicyReads) Case ¶
func (in PolicyReads) Case() PolicyCase
Case decides what the step does for in.
type Removal ¶
Removal is a delete step whose route also changes or deletes other rows: a share's revoke takes it out of pools and moves the keys running in it, a service account takes its account along through a foreign key. Row is the row deleted; Along are the others, each with its kind, metadata and Op, as the write left them. The write fills Along; an expansion may fill it with what it expects, which the write replaces.
type RemovalChange ¶
RemovalChange is what an agent removal expands to: the delete steps in order, and the labelled rows listed as kept.
func ExpandAgentRemoval ¶
func ExpandAgentRemoval(body AgentRemoval, in RemovalReads) (RemovalChange, error)
ExpandAgentRemoval returns the steps that remove the service account, in an order each ordinary delete accepts: its keys; each share it holds revoked; the service account, which takes its account along, policy and all; then each labelled policy, then each labelled pool, that its scope owns, the caller may see and delete, keep does not name, and no account or policy left after the earlier steps uses. Every other labelled row the caller may see, or its scope owns, is listed as kept with why; one owned elsewhere that the caller may not see is neither touched nor listed.
type RemovalReads ¶
type RemovalReads struct {
ServiceAccount *serviceaccount.ServiceAccount
// Lane is the service account's account, nil when relay has not made it.
Lane *account.Account
// Keys are the relay keys of the service account; Shares the shares it holds.
Keys []*key.Key
// Accounts are every account and Policies every policy, those the caller may not see included: what still uses a labelled row.
Accounts []*account.Account
Policies []*policy.Policy
// Labelled are the labelled policies, then the labelled pools.
Labelled []Labelled
}
RemovalReads is what expanding an agent removal reads besides its body.
type Row ¶
type Row struct {
// Kind is the API singular of the row's kind, such as service-account or account.
Kind string
// Pointer is the JSON pointer of the part of the pseudo body the row came from.
Pointer string
Meta *meta.Metadata
// Value points at the row, such as a *pool.Pool; the write function writes it as it leaves it.
Value any
Op Op
}
Row is one step of a pseudo object: a real row to create, update or delete.
func Changed ¶
Changed lists the rows the steps that do op write, in write order, each as its kind and metadata; a removal's rows taken along follow it.
func ExpandAgent ¶
func ExpandAgent(body Agent, in AgentReads) ([]Row, error)
ExpandAgent returns the rows an agent body stands for, in write order: the service account, its lane account, then for policyId the lane's policy set to it; for access the shares and pools it needs, its policy (linking poolIds, then the pools made) and the lane's policy set to that; then the key.
func ExpandHostKey ¶
func ExpandHostKey(body HostKeyForm, in HostKeyReads) ([]Row, error)
ExpandHostKey returns the rows a host key body stands for, in write order: the new account naming its tier (or the existing account's tier set), the host key, and a share with each receiver that neither holds one nor reaches the account.
type Scope ¶
type Scope struct {
Kind string `json:"kind" doc:"Kind of the scope: organization, system, team, project, user or host."`
Name string `json:"name,omitempty" doc:"Name of the scope; empty when the caller may not see it, or it has none."`
}
Scope names an owner scope as the caller is shown it: its kind, and its name only when the caller may see it.
type ShareReceiver ¶
type ShareReceiver struct {
// Owner is the owner a share with it takes: the receiver itself, or a service account's owner. Name names it in the share's name.
Share *account.Account
Reaches bool
}
ShareReceiver is the scope a shareWith entry names and where it stands with the account.
type Target ¶
type Target struct {
Kind string `` /* 189-byte string literal not displayed */
ID string `` /* 132-byte string literal not displayed */
}
Target names the team, project or service account whose account a kind changes.
type Transactor ¶
type Transactor interface {
InTx(ctx context.Context, fn func(ctx context.Context, tx *appcatalog.Stores) error) error
}
Transactor runs fn with the stores bound to one transaction; *catalog.Stores is one.
type UncarriedError ¶
UncarriedError refuses a copy that would carry links its owner may not link; Counts are by kind.
func (*UncarriedError) Error ¶
func (e *UncarriedError) Error() string
type UndoError ¶
UndoError is a pseudo write that wrote no row but could not undo every write it made before its transaction: Left names each one left behind, Err is why no row was written.
type Writer ¶
type Writer struct {
Stores Transactor
Check *plan.Check
// View is the live plans' current view.
View func() *engine.View
// Outside are the writes made before the transaction opens, undone when it does not commit.
Outside []Outside
}
Writer writes expanded rows in one transaction once the plans accept them.
func (Writer) Run ¶
func (w Writer) Run(ctx context.Context, expand ExpandFunc, create CreateFunc, dryRun bool) ([]Row, error)
Run makes the outside writes, then in one transaction expands, writes each step in order, checks the result against the plans and commits; a dry run does all but the outside writes and the commit. It holds the check slot (plan.Check.Hold) throughout, so one write is open at a time; past the bound it answers plan.ErrCheckTimeout. It returns the steps as written, on a dry run too. Nothing is written on any error: a refused step is a *RowError, a body that expands to nothing a *BodyError, steps the plans refuse an *IssuesError, and an *UndoError names an outside write that could not be undone. The plan check lays the rows passed to Record over the live view, a changed row as first read. Once the check passed, the AfterCheck hook on ctx is given what it found.
func (Writer) RunWithWarnings ¶
func (w Writer) RunWithWarnings(ctx context.Context, expand ExpandFunc, create CreateFunc, dryRun bool) ([]Row, []engine.Issue, error)
RunWithWarnings is Run that also answers the warnings the plan check found new on the rows created, updated or deleted (as their source or target), from the same build; they refuse nothing.