postgres

package
v0.0.0-...-0ff9066 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Open

func Open(connStr string) (*sql.DB, error)

func OpenTestDB

func OpenTestDB(t *testing.T) *sql.DB

func TerminateTestContainer

func TerminateTestContainer()

Types

type AuthMethodRepo

type AuthMethodRepo struct {
	DB *sql.DB
}

AuthMethodRepo implements domain.AuthMethodRepository backed by Postgres. Unlike other repos in this package, it operates on *sql.DB directly because auth method operations do not participate in cross-repo transactions.

func (*AuthMethodRepo) Get

func (*AuthMethodRepo) List

func (*AuthMethodRepo) Save

func (r *AuthMethodRepo) Save(ctx context.Context, method domain.AuthMethod) error

type ConditionJSON

type ConditionJSON struct {
	Status                 domain.ConditionStatus `json:"status"`
	Reason                 string                 `json:"reason"`
	Message                string                 `json:"message"`
	LastTransitionTime     protoJSONTimestamp     `json:"lastTransitionTime"`
	LastTransitionTimeNorm string                 `json:"_lastTransitionTimeNorm"`
}

ConditionJSON is the JSON shape of a single entry within extension_resource_inventory.conditions, which stores a *map* of these keyed by condition type rather than an array -- see that column's migration doc comment for why.

LastTransitionTime is ProtoJSON (Z-normalized; 0/3/6/9 fractional digits) so direct CEL string filters match the QueryResources response spelling and GIN containment can participate. LastTransitionTimeNorm is the fixed-width UTC sibling used only by timestamp() filters; it is derived from the same time.Time on write and must not appear in API responses.

type DeliveryRepo

type DeliveryRepo struct {
	DB *sql.Tx
}

DeliveryRepo implements domain.DeliveryRepository backed by Postgres.

func (*DeliveryRepo) DeleteByFulfillment

func (r *DeliveryRepo) DeleteByFulfillment(ctx context.Context, fID domain.FulfillmentID) error

func (*DeliveryRepo) Get

func (*DeliveryRepo) GetByFulfillmentTarget

func (r *DeliveryRepo) GetByFulfillmentTarget(ctx context.Context, fID domain.FulfillmentID, tgtID domain.TargetID) (domain.Delivery, error)

func (*DeliveryRepo) ListActive

func (r *DeliveryRepo) ListActive(ctx context.Context, targetIDs []domain.TargetID) ([]domain.Delivery, error)

func (*DeliveryRepo) ListByFulfillment

func (r *DeliveryRepo) ListByFulfillment(ctx context.Context, fID domain.FulfillmentID) ([]domain.Delivery, error)

func (*DeliveryRepo) Put

type DeploymentRepo

type DeploymentRepo struct {
	DB *sql.Tx
}

DeploymentRepo implements domain.DeploymentRepository backed by Postgres.

func (*DeploymentRepo) Create

func (*DeploymentRepo) Delete

func (r *DeploymentRepo) Delete(ctx context.Context, name domain.ResourceName) error

func (*DeploymentRepo) Get

func (*DeploymentRepo) GetView

func (*DeploymentRepo) ListView

func (r *DeploymentRepo) ListView(ctx context.Context) ([]domain.DeploymentView, error)

type ExtensionResourceRepo

type ExtensionResourceRepo struct {
	DB interface {
		ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
		QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
		QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
	}
}

ExtensionResourceRepo implements domain.ExtensionResourceRepository for Postgres.

func (*ExtensionResourceRepo) ApplyInventoryDeltas

func (r *ExtensionResourceRepo) ApplyInventoryDeltas(ctx context.Context, deltas []domain.InventoryDelta) error

ApplyInventoryDeltas implements domain.ExtensionResourceRepository.ApplyInventoryDeltas in one statement against Postgres. ReplaceLabels/ReplaceConditions are whole-column JSONB assignments; UpsertLabels/DeleteLabels and UpsertConditions/DeleteConditions merge inside SQL against each row's current state, so concurrent incremental writers compose through Postgres row locking and EvalPlanQual re-evaluation instead of through a Go-side read-modify-write.

func (*ExtensionResourceRepo) Create

func (*ExtensionResourceRepo) CreateType

func (*ExtensionResourceRepo) Delete

func (*ExtensionResourceRepo) DeleteType

func (*ExtensionResourceRepo) Get

func (*ExtensionResourceRepo) GetByUID

func (*ExtensionResourceRepo) GetIntent

func (*ExtensionResourceRepo) GetType

func (*ExtensionResourceRepo) GetView

func (*ExtensionResourceRepo) ListByResourceType

func (*ExtensionResourceRepo) ListConditionTransitions

func (r *ExtensionResourceRepo) ListConditionTransitions(ctx context.Context, uid domain.ExtensionResourceUID, conditionType *domain.ConditionType, limit int) ([]domain.ConditionTransition, error)

func (*ExtensionResourceRepo) ListObservations

func (r *ExtensionResourceRepo) ListObservations(ctx context.Context, uid domain.ExtensionResourceUID, limit int) ([]domain.Observation, error)

func (*ExtensionResourceRepo) ListTypes

func (*ExtensionResourceRepo) ListViewsByType

func (*ExtensionResourceRepo) ReplaceInventory

func (r *ExtensionResourceRepo) ReplaceInventory(ctx context.Context, replacements []domain.InventoryReplacement) error

func (*ExtensionResourceRepo) UpdateType

type FulfillmentRepo

type FulfillmentRepo struct {
	DB *sql.Tx
}

FulfillmentRepo implements domain.FulfillmentRepository backed by Postgres.

func (*FulfillmentRepo) Create

func (*FulfillmentRepo) Delete

func (*FulfillmentRepo) Get

func (*FulfillmentRepo) Update

type InventoryRepo

type InventoryRepo struct {
	DB *sql.Tx
}

InventoryRepo implements domain.InventoryRepository backed by Postgres.

func (*InventoryRepo) Create

func (r *InventoryRepo) Create(ctx context.Context, item domain.InventoryItem) error

func (*InventoryRepo) CreateOrUpdate

func (r *InventoryRepo) CreateOrUpdate(ctx context.Context, item domain.InventoryItem) error

func (*InventoryRepo) Delete

func (*InventoryRepo) Get

func (*InventoryRepo) List

func (*InventoryRepo) ListByType

func (*InventoryRepo) Update

func (r *InventoryRepo) Update(ctx context.Context, item domain.InventoryItem) error

type QueryRepo

type QueryRepo struct {
	DB *sql.Tx

	// Compiler defaults to querysql.Compiler with this package's
	// queryFieldResolver and dollarParams when nil (see compiler()).
	// Overridable for tests that need to exercise QueryResources
	// against a stub compiler; in that case SchemaProvider is ignored
	// since the override owns its own field resolution, if any.
	Compiler querysql.CELSQLCompiler

	// SchemaProvider is threaded into the default compiler so
	// resource.spec.*/resource.observation.* field paths can be
	// validated against real descriptors when known, and is also used
	// to scope QueryResources to activated types (see
	// [domain.ResolveQueryResourceTypeScope]). Nil is a valid,
	// permissive default (no activation IN constraint).
	SchemaProvider domain.QuerySchemaProvider
}

QueryRepo implements domain.QueryRepository for Postgres. It is the read model query surface over extension resources -- see domain.QueryRepository's doc for why this is not an aggregate repository.

TODO: do not restore platform aggregate search by re-adding a platform_rows CTE union in buildQueryResourcesSQL. Platform rows are reserved for a future identity/query model with its own indexes; a derived approximation over extension_resources is not the intended surface.

func (*QueryRepo) QueryResources

type ResourceIdentityRepo

type ResourceIdentityRepo struct {
	DB *sql.Tx
}

ResourceIdentityRepo implements domain.ResourceIdentityRepository backed by Postgres.

func (*ResourceIdentityRepo) Create

func (*ResourceIdentityRepo) GetByName

func (*ResourceIdentityRepo) ListByCollection

func (r *ResourceIdentityRepo) ListByCollection(ctx context.Context, collection domain.CollectionName) ([]*domain.PlatformResource, error)

func (*ResourceIdentityRepo) ResolveAliasesBatch

func (r *ResourceIdentityRepo) ResolveAliasesBatch(ctx context.Context, aliases []domain.Alias) (map[domain.Alias]domain.ResourceName, error)

ResolveAliasesBatch implements domain.ResourceIdentityRepository.ResolveAliasesBatch as a single round trip against resource_alias_claims, whose rows already carry the owning resource's name directly -- no join needed, and no DISTINCT needed either: UNIQUE(namespace, key, value) (see the migration's doc comment) guarantees at most one row per requested alias regardless of how many contributors back it.

This never consults extension_resources.reported_aliases -- an alias absent here simply isn't in the map ResolveAliasesBatch returns, whether it was never reported or is still pending reconciliation.

func (*ResourceIdentityRepo) Update

type SignerEnrollmentRepo

type SignerEnrollmentRepo struct {
	DB *sql.Tx
}

SignerEnrollmentRepo implements domain.SignerEnrollmentRepository backed by Postgres.

func (*SignerEnrollmentRepo) Create

func (*SignerEnrollmentRepo) Get

func (*SignerEnrollmentRepo) ListBySubject

type Store

type Store struct {
	DB *sql.DB

	// SchemaProvider is threaded into every QueryRepo this store
	// hands out (see storeTx.Queries), so query-time
	// resource.spec.*/resource.observation.* field validation and
	// activation scoping can use the activated type set (see
	// [domain.QuerySchemaProvider] and
	// [domain.ResolveQueryResourceTypeScope]). Nil is a valid,
	// permissive default (no activation IN constraint).
	SchemaProvider domain.QuerySchemaProvider
}

Store implements domain.Store backed by Postgres.

func (*Store) Begin

func (s *Store) Begin(ctx context.Context) (domain.Tx, error)

func (*Store) BeginReadOnly

func (s *Store) BeginReadOnly(ctx context.Context) (domain.Tx, error)

type TargetRepo

type TargetRepo struct {
	DB *sql.Tx
}

TargetRepo implements domain.TargetRepository backed by Postgres.

func (*TargetRepo) Create

func (r *TargetRepo) Create(ctx context.Context, t domain.TargetInfo) error

func (*TargetRepo) CreateOrUpdate

func (r *TargetRepo) CreateOrUpdate(ctx context.Context, t domain.TargetInfo) error

func (*TargetRepo) Delete

func (r *TargetRepo) Delete(ctx context.Context, id domain.TargetID) error

func (*TargetRepo) Get

func (*TargetRepo) List

func (r *TargetRepo) List(ctx context.Context) ([]domain.TargetInfo, error)

type VaultStore

type VaultStore struct {
	DB *sql.DB
}

VaultStore implements domain.Vault backed by Postgres. It operates on *sql.DB directly (not within the transactional Store) because vault operations are independent of domain entity transactions.

func (*VaultStore) Delete

func (v *VaultStore) Delete(ctx context.Context, ref domain.SecretRef) error

func (*VaultStore) Get

func (v *VaultStore) Get(ctx context.Context, ref domain.SecretRef) ([]byte, error)

func (*VaultStore) Put

func (v *VaultStore) Put(ctx context.Context, ref domain.SecretRef, value []byte) error

Jump to

Keyboard shortcuts

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