pool

package
v0.21.1 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 10 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 pool is the domain layer for the Pool entity: an ordered set of one host's keys, listed one by one or as whole provider accounts, plus the selection algorithm that picks among them. Policies link pools; many policies may draw on one pool, and nothing in a pool is reserved for any of them.

This package validates one row's shape, fills its defaults, and stores it. Out of scope: picking a key per request (app/keypool), checking that every key belongs to the pool's host (app/refcheck), and spend caps, which belong on the account.

Index

Constants

View Source
const DefaultSelection = keypool.KeySelectionPrioritized

DefaultSelection is the selection a pool that names none uses.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

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

Pool is a set of host keys at one host.

func (*Pool) Default

func (p *Pool) Default()

Default fills the fields a wire form may omit, so a stored row and the manifest that declared it converge. Nil receiver is a no-op.

func (*Pool) Validate

func (p *Pool) Validate() error

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

  • an owner of kind system, team, project or user; team and project owners carry an id.
  • no key and no account listed twice.

Cross-row checks (the host exists; every key and account exists and is at that host) live in app/refcheck.

type Spec

type Spec struct {
	// HostID is the one host every key in the pool authenticates to.
	HostID string `json:"hostId" yaml:"hostId" validate:"required,uuid" doc:"Id of the one host every key in the pool authenticates to."`

	// AccountIDs are provider accounts the pool draws on whole: each contributes every key it holds now or later, a shared account the keys of its real account. They come before CredentialIDs in prioritized order.
	AccountIDs []string `` /* 493-byte string literal not displayed */

	// CredentialIDs are the pool's host keys. Order is the preference for prioritized selection. Empty is valid: deleting a key removes it from every pool, which may leave one empty.
	CredentialIDs []string `` /* 247-byte string literal not displayed */

	Selection keypool.KeySelection `` /* 354-byte string literal not displayed */
}

Spec names the host, its keys, and how a key is picked.

type Store

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

Store holds a DB rather than Queries so Upsert can run a multi-table transaction.

func NewStore

func NewStore(db storage.DB) *Store

NewStore constructs a Store bound to a pool or an open transaction.

func (*Store) Delete

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

Delete removes a Pool by id and its credential and account rows. A policy linking it keeps the id, so it narrows rather than widens.

func (*Store) Get

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

Get returns the Pool with the given id, or (nil, nil) if not found.

func (*Store) List

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

List returns every Pool row with its credentials in order.

func (*Store) Upsert

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

Upsert writes p and replaces its credential list in one transaction.

Jump to

Keyboard shortcuts

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