sqlite

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store implements repo.Store using SQLite.

func NewStore

func NewStore(db *sqlx.DB) *Store

NewStore creates a new SQLite-backed store.

func (*Store) AddAuditEvent

func (s *Store) AddAuditEvent(ctx context.Context, e *repo.AuditEvent) error

func (*Store) BindingsForConsumer

func (s *Store) BindingsForConsumer(ctx context.Context, consumerTileID string) ([]repo.ResourceBinding, error)

BindingsForConsumer is the resolver's authorization lookup: everything this tile is allowed to read outputs from.

func (s *Store) BurnDropLink(ctx context.Context, id string, vars []repo.Variable) (bool, error)

BurnDropLink is ClaimSecretLink(burned) plus the variable writes in one transaction: a failed write rolls the burn back too, so the link stays open and the sender can resubmit, never a burned link with half the values.

func (*Store) BurnJoinKey

func (s *Store) BurnJoinKey(ctx context.Context, key string) (bool, error)

BurnJoinKey marks a key used. One-time by construction: the update only matches a key nobody has spent yet, so two joins racing the same key means exactly one of them gets a row back.

func (*Store) BurnServerJoinKeys

func (s *Store) BurnServerJoinKeys(ctx context.Context, serverID string) (int, error)

BurnServerJoinKeys spends every key a server still has unspent, and returns how many it took.

This is what revoking means here. IssueKey only ever inserts, so before this existed a second "new script" left the first key working for the rest of its hour: an operator who pasted a join command somewhere they should not have had nothing in the product that would stop it.

func (s *Store) ClaimSecretLink(ctx context.Context, id, state string) (bool, error)

ClaimSecretLink flips an open link to state and reports whether this caller won the race. Callers must act only when it returns true, checking the state and then writing would let two concurrent submits both through.

func (*Store) ClaimWorkItem

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

ClaimWorkItem moves one queued item to running, reporting whether this caller got it. The rows-affected check is the whole lock: two claimers race on the same UPDATE and exactly one sees a row change.

One panel process today, so this is enough, and it stays correct if a second ever appears, which matters because panel failover is on the roadmap (docs/notes.md, misc). No leases until there is a second writer.

func (*Store) ClaimedNetworks

func (s *Store) ClaimedNetworks(ctx context.Context) ([]string, error)

ClaimedNetworks lists every pooled network name a row still holds, from both owner tables at once. One query rather than walking stacks: the pool is global, and a name missed here is a network handed to a second tenant.

func (*Store) ClearDeclaredIntended

func (s *Store) ClearDeclaredIntended(ctx context.Context, envID string) error

func (*Store) CountStacksAwaitingPlan

func (s *Store) CountStacksAwaitingPlan(ctx context.Context, orgID string) (int, error)

CountStacksAwaitingPlan is how many of an org's stacks have a newest plan still waiting on someone (pending or error). Newest only: an old error plan that a later plan moved past is history, not a decision to make.

func (*Store) CountStagedByEnv

func (s *Store) CountStagedByEnv(ctx context.Context, envID string) (int, error)

func (*Store) CountUnreadNotifications

func (s *Store) CountUnreadNotifications(ctx context.Context, userID string) (int, error)

func (*Store) CountUsers

func (s *Store) CountUsers(ctx context.Context) (int, error)

func (*Store) Create

func (s *Store) Create(ctx context.Context, session *auth.Session) error

Create inserts a new session row. To store extra metadata, add your own columns to the sessions table and populate them here, or store a JSON blob if you prefer.

func (*Store) CreateAPIKey

func (s *Store) CreateAPIKey(ctx context.Context, k *repo.APIKey) error

func (*Store) CreateBackup

func (s *Store) CreateBackup(ctx context.Context, b *repo.Backup) error

func (*Store) CreateBackupDestination

func (s *Store) CreateBackupDestination(ctx context.Context, d *repo.BackupDestination) error

func (*Store) CreateBackupRun

func (s *Store) CreateBackupRun(ctx context.Context, r *repo.BackupRun) error

func (*Store) CreateBinding

func (s *Store) CreateBinding(ctx context.Context, b *repo.ResourceBinding) error

func (*Store) CreateConfigPlan

func (s *Store) CreateConfigPlan(ctx context.Context, p *repo.ConfigPlan) error

func (*Store) CreateConnector

func (s *Store) CreateConnector(ctx context.Context, cn *repo.Connector) error

func (*Store) CreateCronRun

func (s *Store) CreateCronRun(ctx context.Context, r *repo.CronRun) error

func (*Store) CreateDeployment

func (s *Store) CreateDeployment(ctx context.Context, d *repo.Deployment) error

func (*Store) CreateDomain

func (s *Store) CreateDomain(ctx context.Context, d *repo.Domain) error

func (*Store) CreateDomainResource

func (s *Store) CreateDomainResource(ctx context.Context, r *repo.DomainResource) error

func (*Store) CreateEnvironment

func (s *Store) CreateEnvironment(ctx context.Context, e *repo.Environment) error

func (*Store) CreateInvite

func (s *Store) CreateInvite(ctx context.Context, i *repo.Invite) error

func (*Store) CreateJoinKey

func (s *Store) CreateJoinKey(ctx context.Context, k *repo.JoinKey) error

func (*Store) CreateNotification

func (s *Store) CreateNotification(ctx context.Context, n *repo.Notification) error

func (*Store) CreateOrg

func (s *Store) CreateOrg(ctx context.Context, o *repo.Org) error

func (*Store) CreateOrgConfigPlan

func (s *Store) CreateOrgConfigPlan(ctx context.Context, p *repo.ConfigPlan) error

func (*Store) CreateOrgRegistryCredential

func (s *Store) CreateOrgRegistryCredential(ctx context.Context, c *repo.OrgRegistryCredential) error

func (*Store) CreateProvision

func (s *Store) CreateProvision(ctx context.Context, p *repo.Provision) error

func (*Store) CreateRegistry

func (s *Store) CreateRegistry(ctx context.Context, r *repo.Registry) error

func (*Store) CreateResource

func (s *Store) CreateResource(ctx context.Context, r *repo.ManagedResource) error
func (s *Store) CreateSecretLink(ctx context.Context, l *repo.SecretLink) error

func (*Store) CreateServer

func (s *Store) CreateServer(ctx context.Context, sv *repo.Server) error

func (*Store) CreateStack

func (s *Store) CreateStack(ctx context.Context, st *repo.Stack) error

CreateStack inserts the stack and its home environment together: a stack without a home has nowhere to put a shared tile.

func (*Store) CreateStagedChange

func (s *Store) CreateStagedChange(ctx context.Context, sc *repo.StagedChange) error

func (*Store) CreateStorage

func (s *Store) CreateStorage(ctx context.Context, st *repo.Storage) error

func (*Store) CreateStoragePath

func (s *Store) CreateStoragePath(ctx context.Context, p *repo.StoragePath) error

func (*Store) CreateTile

func (s *Store) CreateTile(ctx context.Context, t *repo.Tile) error

func (*Store) CreateUser

func (s *Store) CreateUser(ctx context.Context, user *repo.User) error

func (*Store) CreateWorkItem

func (s *Store) CreateWorkItem(ctx context.Context, w *repo.WorkItem) error

func (*Store) DB

func (s *Store) DB() *sqlx.DB

DB returns the underlying database connection for use in queries.

func (*Store) Delete

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

func (*Store) DeleteAPIKey

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

func (*Store) DeleteAllNotifications

func (s *Store) DeleteAllNotifications(ctx context.Context, userID string) error

func (*Store) DeleteAnnotation

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

func (*Store) DeleteBackup

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

func (*Store) DeleteBackupDestination

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

func (*Store) DeleteBinding

func (s *Store) DeleteBinding(ctx context.Context, resourceID, consumerTileID string) error

func (*Store) DeleteBySubjectID

func (s *Store) DeleteBySubjectID(ctx context.Context, subjectID string) error

func (*Store) DeleteConnector

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

func (*Store) DeleteDomain

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

func (*Store) DeleteDomainResource

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

func (*Store) DeleteEnvironment

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

func (*Store) DeleteGraphGroup

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

func (*Store) DeleteIntended

func (s *Store) DeleteIntended(ctx context.Context, envID, tileSlug, key string) error

func (*Store) DeleteInvite

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

func (*Store) DeleteNodePositions

func (s *Store) DeleteNodePositions(ctx context.Context, ownerID string) error

func (*Store) DeleteOrg

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

DeleteOrg removes the org and every canvas layout under it. The org's own layout plus one env- and one stack-scoped row set per stack: stacks cascade through their FK, but node_positions has none (it also holds org layouts), so those rows would be orphaned by the cascade.

func (*Store) DeleteOrgMember

func (s *Store) DeleteOrgMember(ctx context.Context, orgID, userID string) error

func (*Store) DeleteOrgRegistryCredential

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

func (*Store) DeleteProvision

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

func (*Store) DeleteRegistry

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

func (*Store) DeleteResource

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

DeleteResource takes its outputs and bindings with it, SQLite runs without foreign keys here, so nothing else would collect the orphans.

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

func (*Store) DeleteServer

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

func (*Store) DeleteStack

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

func (*Store) DeleteStagedByEnv

func (s *Store) DeleteStagedByEnv(ctx context.Context, envID string) error

func (*Store) DeleteStagedChange

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

func (*Store) DeleteStorage

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

func (*Store) DeleteStoragePath

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

func (*Store) DeleteSystemOrgRegistryCredential

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

DeleteSystemOrgRegistryCredential removes a system row, which the public delete refuses. The only caller is the repair path: the registry password changed, so the stored hash can never match again and the row is replaced.

func (*Store) DeleteTile

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

func (*Store) DeleteVariable

func (s *Store) DeleteVariable(ctx context.Context, ownerKind, ownerID, name string) error

func (*Store) EnvironmentsWithoutNetwork

func (s *Store) EnvironmentsWithoutNetwork(ctx context.Context) ([]string, error)

EnvironmentsWithoutNetwork lists environments that hold no pooled overlay.

Only ever non-empty on an install upgraded across 009, which added the column with an empty default and backfilled nothing: every environment that existed before the upgrade sat on no overlay until its next deploy, and the proxy quietly left it out of its routing map in the meantime.

func (*Store) FinishCronRun

func (s *Store) FinishCronRun(ctx context.Context, r *repo.CronRun) error

FinishCronRun closes out a run inserted while it was still going. Only the three columns a finish can move are written, so nothing races the insert.

func (*Store) FinishWorkItem

func (s *Store) FinishWorkItem(ctx context.Context, id, status, errMsg string) error

FinishWorkItem records how an item ended. errMsg empty means it worked.

func (*Store) GetAPIKeyByHash

func (s *Store) GetAPIKeyByHash(ctx context.Context, hash string) (*repo.APIKey, error)

func (*Store) GetBackup

func (s *Store) GetBackup(ctx context.Context, id string) (*repo.Backup, error)

func (*Store) GetBackupDestination

func (s *Store) GetBackupDestination(ctx context.Context, id string) (*repo.BackupDestination, error)

func (*Store) GetBackupRun

func (s *Store) GetBackupRun(ctx context.Context, id string) (*repo.BackupRun, error)

func (*Store) GetByToken

func (s *Store) GetByToken(ctx context.Context, token string) (*auth.Session, error)

func (*Store) GetConfigPlan

func (s *Store) GetConfigPlan(ctx context.Context, id string) (*repo.ConfigPlan, error)

func (*Store) GetConnector

func (s *Store) GetConnector(ctx context.Context, id string) (*repo.Connector, error)

func (*Store) GetCronRun

func (s *Store) GetCronRun(ctx context.Context, id string) (*repo.CronRun, error)

func (*Store) GetDeployment

func (s *Store) GetDeployment(ctx context.Context, id string) (*repo.Deployment, error)

func (*Store) GetDomain

func (s *Store) GetDomain(ctx context.Context, id string) (*repo.Domain, error)

func (*Store) GetDomainByHostPath

func (s *Store) GetDomainByHostPath(ctx context.Context, host, path string) (*repo.Domain, error)

GetDomainByHostPath finds the domain claiming a host+path (nil if free), the plain row before any rule row on it. Used to reject duplicate and cross-tenant host claims before insert: a rule row owns the host+path for its tile as much as a plain one does.

func (*Store) GetEnvironment

func (s *Store) GetEnvironment(ctx context.Context, id string) (*repo.Environment, error)

func (*Store) GetEnvironmentBySlug

func (s *Store) GetEnvironmentBySlug(ctx context.Context, stackID, slug string) (*repo.Environment, error)

func (*Store) GetInvite

func (s *Store) GetInvite(ctx context.Context, id string) (*repo.Invite, error)

func (*Store) GetJoinKey

func (s *Store) GetJoinKey(ctx context.Context, key string) (*repo.JoinKey, error)

func (*Store) GetManagedRegistry

func (s *Store) GetManagedRegistry(ctx context.Context) (*repo.Registry, error)

func (*Store) GetOrg

func (s *Store) GetOrg(ctx context.Context, id string) (*repo.Org, error)

func (*Store) GetOrgBySlug

func (s *Store) GetOrgBySlug(ctx context.Context, slug string) (*repo.Org, error)

func (*Store) GetOrgConfigPlan

func (s *Store) GetOrgConfigPlan(ctx context.Context, id string) (*repo.ConfigPlan, error)

func (*Store) GetOrgMember

func (s *Store) GetOrgMember(ctx context.Context, orgID, userID string) (*repo.OrgMember, error)

func (*Store) GetOrgRegistryCredential

func (s *Store) GetOrgRegistryCredential(ctx context.Context, id string) (*repo.OrgRegistryCredential, error)

func (*Store) GetOrgRegistryCredentialByHash

func (s *Store) GetOrgRegistryCredentialByHash(ctx context.Context, hash string) (*repo.OrgRegistryCredential, error)

func (*Store) GetOrgStorageBySlug added in v0.2.0

func (s *Store) GetOrgStorageBySlug(ctx context.Context, orgID, slug string) (*repo.Storage, error)

func (*Store) GetProvision

func (s *Store) GetProvision(ctx context.Context, id string) (*repo.Provision, error)

func (*Store) GetRegistry

func (s *Store) GetRegistry(ctx context.Context, id string) (*repo.Registry, error)

func (*Store) GetResource

func (s *Store) GetResource(ctx context.Context, id string) (*repo.ManagedResource, error)

func (*Store) GetSecretLinkByHash

func (s *Store) GetSecretLinkByHash(ctx context.Context, tokenHash string) (*repo.SecretLink, error)

func (*Store) GetServer

func (s *Store) GetServer(ctx context.Context, id string) (*repo.Server, error)

func (*Store) GetServerByNodeID

func (s *Store) GetServerByNodeID(ctx context.Context, nodeID string) (*repo.Server, error)

GetServerByNodeID finds the row mirroring one swarm node. Used to reconcile `docker node ls` against the table on every servers-list load.

func (*Store) GetSetting

func (s *Store) GetSetting(ctx context.Context, key string) (string, error)

func (*Store) GetStack

func (s *Store) GetStack(ctx context.Context, id string) (*repo.Stack, error)

func (*Store) GetStackBySlug

func (s *Store) GetStackBySlug(ctx context.Context, orgID, slug string) (*repo.Stack, error)

func (*Store) GetStagedChange

func (s *Store) GetStagedChange(ctx context.Context, id string) (*repo.StagedChange, error)

func (*Store) GetStorage

func (s *Store) GetStorage(ctx context.Context, id string) (*repo.Storage, error)

func (*Store) GetStorageBySlug

func (s *Store) GetStorageBySlug(ctx context.Context, slug string) (*repo.Storage, error)

GetStorageBySlug finds a server pool or share. Org shares are not found here: their slugs are only unique inside one org (GetOrgStorageBySlug).

func (*Store) GetStoragePath

func (s *Store) GetStoragePath(ctx context.Context, id string) (*repo.StoragePath, error)

func (*Store) GetTile

func (s *Store) GetTile(ctx context.Context, id string) (*repo.Tile, error)

func (*Store) GetTileBySlug

func (s *Store) GetTileBySlug(ctx context.Context, envID, slug string) (*repo.Tile, error)

func (*Store) GetUserByEmail

func (s *Store) GetUserByEmail(ctx context.Context, email string) (*repo.User, error)

func (*Store) GetUserByID

func (s *Store) GetUserByID(ctx context.Context, id string) (*repo.User, error)

func (*Store) GetWorkItem

func (s *Store) GetWorkItem(ctx context.Context, id string) (*repo.WorkItem, error)

func (*Store) Health

func (s *Store) Health(ctx context.Context) error

Health checks the database connection.

func (*Store) HomeEnvironment

func (s *Store) HomeEnvironment(ctx context.Context, stackID string) (*repo.Environment, error)

func (*Store) InsertMetric

func (s *Store) InsertMetric(ctx context.Context, m *repo.Metric) error

func (*Store) LatestConfigPlan

func (s *Store) LatestConfigPlan(ctx context.Context, stackID string) (*repo.ConfigPlan, error)

LatestConfigPlan returns the newest plan for a stack (nil if none).

func (*Store) LatestJoinKey

func (s *Store) LatestJoinKey(ctx context.Context, serverID string) (*repo.JoinKey, error)

LatestJoinKey is the newest key issued for a server, so a pending row can show its script again without minting a second one.

func (*Store) LatestSettledConfigPlan added in v0.4.0

func (s *Store) LatestSettledConfigPlan(ctx context.Context, stackID string) (*repo.ConfigPlan, error)

func (*Store) LatestWorkItem

func (s *Store) LatestWorkItem(ctx context.Context, kind, dedupeKey string) (*repo.WorkItem, error)

LatestWorkItem is the newest item of one kind and key, whatever its status. The plan page polls this to find the apply it just asked for without having to remember an id across a redirect.

func (*Store) ListAPIKeys

func (s *Store) ListAPIKeys(ctx context.Context) ([]repo.APIKey, error)

func (*Store) ListAllAuditEvents

func (s *Store) ListAllAuditEvents(ctx context.Context, actor, action string, limit int) ([]repo.AuditEvent, error)

ListAllAuditEvents is the admin view: every secret read and write on the server, newest first, optionally narrowed to one actor or one action.

Server-wide and so admin-only: the per-owner listing above is what a tenant sees, and it is already scoped by the owner they are looking at.

func (*Store) ListAnnotations

func (s *Store) ListAnnotations(ctx context.Context, ownerID string) ([]repo.Annotation, error)

func (*Store) ListAuditEvents

func (s *Store) ListAuditEvents(ctx context.Context, ownerKind, ownerID string, limit int) ([]repo.AuditEvent, error)

rowid rather than created_at, see ListDeploymentsByTile / stacks.go.

func (*Store) ListBackupDestinations

func (s *Store) ListBackupDestinations(ctx context.Context) ([]repo.BackupDestination, error)

func (*Store) ListBackupRuns

func (s *Store) ListBackupRuns(ctx context.Context, backupID string, limit int) ([]repo.BackupRun, error)

rowid rather than created_at, see ListDeploymentsByTile / stacks.go. Display-only: keep-count pruning does NOT read this list (backup.go's prune sorts S3 object keys), so the only consumers are the two limit-10 history views in internal/web/handler.

func (*Store) ListBackups

func (s *Store) ListBackups(ctx context.Context) ([]repo.Backup, error)

func (*Store) ListBackupsByTile

func (s *Store) ListBackupsByTile(ctx context.Context, tileID string) ([]repo.Backup, error)

func (*Store) ListBindingsByResource

func (s *Store) ListBindingsByResource(ctx context.Context, resourceID string) ([]repo.ResourceBinding, error)

func (*Store) ListConfigPlans

func (s *Store) ListConfigPlans(ctx context.Context, stackID string, limit int) ([]repo.ConfigPlan, error)

func (*Store) ListConnectors

func (s *Store) ListConnectors(ctx context.Context) ([]repo.Connector, error)

func (*Store) ListConnectorsByOrg

func (s *Store) ListConnectorsByOrg(ctx context.Context, orgID string) ([]repo.Connector, error)

func (*Store) ListCronRuns

func (s *Store) ListCronRuns(ctx context.Context, ref string, limit int) ([]repo.CronRun, error)

rowid rather than started_at (TEXT, format-sensitive), see LatestConfigPlan in stacks.go. PruneCronRuns below is fine as is: it compares against a bound time.Time, so the driver normalises both sides to one format.

func (*Store) ListDeploymentsByStatus

func (s *Store) ListDeploymentsByStatus(ctx context.Context, status string) ([]repo.Deployment, error)

ListDeploymentsByStatus: every deployment in one state, the CI gate scans waiting_ci rows each tick. Oldest first so grace/timeout fire in order.

func (*Store) ListDeploymentsByTile

func (s *Store) ListDeploymentsByTile(ctx context.Context, tileID string, limit int) ([]repo.Deployment, error)

Newest-first by rowid, i.e. insert order, see the long note over LatestConfigPlan in stacks.go. created_at is TEXT, so ordering by it is a character comparison that only works while every writer agrees on a timestamp format, and one row written by a script or a migration in ISO form pins itself at the top forever. rowid ignores idx_deployments_tile(tile_id, created_at DESC), so this sorts every matching row instead of range-reading LIMIT rows off the index (same in notifications/backups/cron_runs). Fine at these row counts; re-point the index at rowid if a table ever grows enough to feel it.

func (*Store) ListDomainResources

func (s *Store) ListDomainResources(ctx context.Context) ([]repo.DomainResource, error)

ListDomainResources returns every resource, a handful of rows; callers filter by visibility (own stack, its org, the instance).

func (*Store) ListDomains

func (s *Store) ListDomains(ctx context.Context) ([]repo.Domain, error)

func (*Store) ListDomainsByTile

func (s *Store) ListDomainsByTile(ctx context.Context, tileID string) ([]repo.Domain, error)

ListDomainsByTile orders by declaration position first, the primary domain (STACKR_PUBLIC_URL) is the first row.

func (*Store) ListEnvironmentsByStack

func (s *Store) ListEnvironmentsByStack(ctx context.Context, stackID string) ([]repo.Environment, error)

func (*Store) ListGraphGroups

func (s *Store) ListGraphGroups(ctx context.Context, ownerID string) ([]repo.GraphGroup, error)

func (*Store) ListIntended

func (s *Store) ListIntended(ctx context.Context, envID string) ([]repo.Intended, error)

func (*Store) ListInvitesByOrg

func (s *Store) ListInvitesByOrg(ctx context.Context, orgID string) ([]repo.Invite, error)

rowid rather than created_at, see ListDeploymentsByTile / stacks.go.

func (*Store) ListMetrics

func (s *Store) ListMetrics(ctx context.Context, ref string, since time.Time) ([]repo.Metric, error)

func (*Store) ListNodePositions

func (s *Store) ListNodePositions(ctx context.Context, ownerID string) ([]repo.NodePosition, error)

func (*Store) ListNotifications

func (s *Store) ListNotifications(ctx context.Context, userID string, limit int) ([]repo.Notification, error)

rowid rather than created_at, see ListDeploymentsByTile / stacks.go.

func (*Store) ListOpenCronRuns

func (s *Store) ListOpenCronRuns(ctx context.Context) ([]repo.CronRun, error)

ListOpenCronRuns is every run in flight, for the canvas: one query instead of one per cron card.

func (*Store) ListOrgConfigPlans

func (s *Store) ListOrgConfigPlans(ctx context.Context, orgID string, limit int) ([]repo.ConfigPlan, error)

func (*Store) ListOrgMembers

func (s *Store) ListOrgMembers(ctx context.Context, orgID string) ([]repo.OrgMember, error)

func (*Store) ListOrgRegistryCredentials

func (s *Store) ListOrgRegistryCredentials(ctx context.Context, orgID string) ([]repo.OrgRegistryCredential, error)

func (*Store) ListOrgs

func (s *Store) ListOrgs(ctx context.Context) ([]repo.Org, error)

func (*Store) ListOrgsForUser

func (s *Store) ListOrgsForUser(ctx context.Context, userID string) ([]repo.Org, error)

func (*Store) ListOutputs

func (s *Store) ListOutputs(ctx context.Context, resourceID string) ([]repo.ResourceOutput, error)

func (*Store) ListProvisionsByConsumer

func (s *Store) ListProvisionsByConsumer(ctx context.Context, consumerTileID string) ([]repo.Provision, error)

func (*Store) ListProvisionsByEnv

func (s *Store) ListProvisionsByEnv(ctx context.Context, envID string) ([]repo.Provision, error)

func (*Store) ListProvisionsByInstance

func (s *Store) ListProvisionsByInstance(ctx context.Context, instanceTileID string) ([]repo.Provision, error)

func (*Store) ListRegistries

func (s *Store) ListRegistries(ctx context.Context) ([]repo.Registry, error)

func (*Store) ListResourcesByEnv

func (s *Store) ListResourcesByEnv(ctx context.Context, envID string) ([]repo.ManagedResource, error)

func (*Store) ListResourcesByProvider

func (s *Store) ListResourcesByProvider(ctx context.Context, providerTileID string) ([]repo.ManagedResource, error)
func (s *Store) ListSecretLinks(ctx context.Context, ownerKind, ownerID string) ([]repo.SecretLink, error)

ListSecretLinks is the operator's view of one scope, newest first. Dead rows are kept: the row names fields but never holds values, so it is the audit line for the exchange.

func (*Store) ListServers

func (s *Store) ListServers(ctx context.Context) ([]repo.Server, error)

func (*Store) ListStacks

func (s *Store) ListStacks(ctx context.Context) ([]repo.Stack, error)

func (*Store) ListStacksByOrg

func (s *Store) ListStacksByOrg(ctx context.Context, orgID string) ([]repo.Stack, error)

func (*Store) ListStagedByEnv

func (s *Store) ListStagedByEnv(ctx context.Context, envID string) ([]repo.StagedChange, error)

Oldest-first by rowid, i.e. insert order, see the note over LatestConfigPlan in stacks.go for why created_at (TEXT, format-sensitive) cannot order rows. This one is load-bearing, not just display: staging replays these in order and later entries win (stackconf/staging.go), so a mis-sorted row would apply a stale edit over a newer one.

func (*Store) ListStagedByStack

func (s *Store) ListStagedByStack(ctx context.Context, stackID string) ([]repo.StagedChange, error)

func (*Store) ListStorage

func (s *Store) ListStorage(ctx context.Context) ([]repo.Storage, error)

func (*Store) ListStoragePaths

func (s *Store) ListStoragePaths(ctx context.Context, storageID string) ([]repo.StoragePath, error)

func (*Store) ListTiles

func (s *Store) ListTiles(ctx context.Context) ([]repo.Tile, error)

func (*Store) ListTilesByEnv

func (s *Store) ListTilesByEnv(ctx context.Context, envID string) ([]repo.Tile, error)

func (*Store) ListTilesByStack

func (s *Store) ListTilesByStack(ctx context.Context, stackID string) ([]repo.Tile, error)

func (*Store) ListUsers

func (s *Store) ListUsers(ctx context.Context) ([]repo.User, error)

func (*Store) ListVariableNames

func (s *Store) ListVariableNames(ctx context.Context) ([]repo.Variable, error)

ListVariableNames feeds global search: owner + name + secret flag only. value is deliberately not selected, so nothing is decrypted and no secret material ever flows through the search path.

func (*Store) ListVariables

func (s *Store) ListVariables(ctx context.Context, ownerKind, ownerID string) ([]repo.Variable, error)

func (*Store) ListWorkItemsByStatus

func (s *Store) ListWorkItemsByStatus(ctx context.Context, status string) ([]repo.WorkItem, error)

ListWorkItemsByStatus is oldest first: the runner takes them in the order they were asked for, and boot recovery walks the rows a dead process left behind in the same order.

func (*Store) MarkAllNotificationsRead

func (s *Store) MarkAllNotificationsRead(ctx context.Context, userID string) error

func (*Store) MarkInviteUsed

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

func (*Store) OpenCronRun

func (s *Store) OpenCronRun(ctx context.Context, ref string) (*repo.CronRun, error)

OpenCronRun is the newest run of ref that has not finished; nil when there is none. The panel header asks this to know whether a tile is mid-run, tiles.status never says "running" for a cron.

func (*Store) PruneCronRuns

func (s *Store) PruneCronRuns(ctx context.Context, before time.Time) error

func (*Store) PruneMetrics

func (s *Store) PruneMetrics(ctx context.Context, before time.Time) error

func (*Store) PruneNotifications

func (s *Store) PruneNotifications(ctx context.Context, before time.Time) error

func (*Store) RecordTileRun

func (s *Store) RecordTileRun(ctx context.Context, id, status, output string) error

RecordTileRun stores the outcome of one cron-kind tile run on the tile row.

tiles.status is deliberately untouched. It is the tile's lifecycle (idle, building, error from a deploy), and every card that rolls tiles up takes the worst status in the group (graph.WorstStatus), so writing a failed run there reddened the whole environment and stack card for one bad tick. The run outcome lives in last_status/last_output, which is what the cron card's last-run line and the runs list read.

func (*Store) RenameEnvironment

func (s *Store) RenameEnvironment(ctx context.Context, id, name, slug string) error

RenameEnvironment is RenameTile for an environment: same rule, the slug is identity and stays out of the general update.

func (*Store) RenameTile

func (s *Store) RenameTile(ctx context.Context, id, name, slug string) error

UpdateTile writes the whole editable row. Deliberately NOT status: a settings save carries whatever status the form was rendered with, so saving after a deploy finished used to revert the tile to its old state. Status moves only through UpdateTileStatus/RecordTileRun.

shared_net and home_node are out for the same reason: both are infrastructure facts the panel discovers (which db-pool overlay the instance holds, which node its volume is on), not fields any form renders, so a settings save would write back whatever stale value it was rendered with. They move only through SetTileSharedNet and SetTileHomeNode. RenameTile writes the two columns UpdateTile deliberately leaves alone.

Slug is not in UpdateTile for the same reason status is not: it is identity, not settings, and a general save carrying a stale copy of it would rename the tile behind whoever asked. The cost of that was that the config engine's moved: entries set t.Slug and called UpdateTile, so a declared rename tore the service down and then wrote nothing at all.

func (*Store) ReplaceTileVars

func (s *Store) ReplaceTileVars(ctx context.Context, t *repo.Tile) error

ReplaceTileVars projects the blob and drops every non-secret row the blob doesn't declare. Only config apply calls it: the file is the whole truth for a managed tile, so a variable deleted from the file has to disappear from the resolver's view too, that's the drift the config lock exists to prevent. Secret rows survive; they never came from the blob.

goes away with projectEnvVars at R7.

func (*Store) RequeueWorkItem

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

RequeueWorkItem puts a running row back in the queue. Boot recovery uses it for the kinds that are safe to run again from the top.

func (*Store) SaveNodePositions

func (s *Store) SaveNodePositions(ctx context.Context, ownerID string, ps []repo.NodePosition) error

SaveNodePositions writes a whole layout atomically. Validation lives here rather than in each handler: three canvases post to this and the payload is untrusted, so the single choke point is where the rules belong.

func (*Store) SetConfigPlanError

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

func (*Store) SetConfigPlanStatus

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

SetConfigPlanStatus updates a plan's lifecycle state.

func (*Store) SetDomainCert

func (s *Store) SetDomainCert(ctx context.Context, id, certPEM, keyPEM string) error

func (*Store) SetDomainForceHTTPS

func (s *Store) SetDomainForceHTTPS(ctx context.Context, id string, force bool) error

SetDomainForceHTTPS flips the plain-HTTP bounce on its own. Serving TLS and redirecting onto it are two questions; a host that must still answer on http can have a certificate without being redirected.

func (*Store) SetDomainHTTPS

func (s *Store) SetDomainHTTPS(ctx context.Context, id string, https bool) error

func (*Store) SetDomainResourceACME

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

SetDomainResourceACME sets the Let's Encrypt account certificates under this resource are issued on. Blank uses the instance's.

func (*Store) SetEnvironmentNetwork

func (s *Store) SetEnvironmentNetwork(ctx context.Context, envID, name string) error

SetEnvironmentNetwork records the pooled overlay this env holds. Separate from UpdateEnvironment for the same reason as SetEnvironmentProxy: the writer is the pool, not a settings form, and a stale blank here would hand a live network to the next environment.

func (*Store) SetEnvironmentProxy

func (s *Store) SetEnvironmentProxy(ctx context.Context, envID, ip, cidr string) error

SetEnvironmentProxy records where traefik landed on this env's network. Separate from UpdateEnvironment because the writer is the proxy, not the panel: folding it into the general update would let any settings save carry a stale (or zero) address back over it, the same shape as the bug that had UpdateTile reverting tile status.

func (*Store) SetIntended

func (s *Store) SetIntended(ctx context.Context, row *repo.Intended) error

func (*Store) SetOrgConfigPlanError

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

func (*Store) SetOrgConfigPlanStatus

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

func (*Store) SetSetting

func (s *Store) SetSetting(ctx context.Context, key, value string) error

func (*Store) SetStackOrg

func (s *Store) SetStackOrg(ctx context.Context, stackID, orgID string) error

func (*Store) SetTileHomeNode

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

SetTileHomeNode records which swarm node a pinned tile's volume lives on. Deliberately its own writer and absent from UpdateTile: the home node is state, set on first deploy and changed only by a completed volume move, so an unrelated settings save must never carry a stale value over it. Losing the assignment is how swarm schedules a database onto an empty volume (docs/plans/30-docker-swarm.md, addendum).

func (*Store) SetTileImageDigest

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

SetTileImageDigest records what a deploy actually pulled. Deliberately not part of UpdateTile: digests are runtime state like status, a settings save must never carry them.

func (*Store) SetTileLatestDigest

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

SetTileLatestDigest records the newest digest the registry watcher has seen.

func (*Store) SetTileSharedNet

func (s *Store) SetTileSharedNet(ctx context.Context, tileID, name string) error

SetTileSharedNet records the pooled overlay a shared managed instance holds.

func (*Store) SetWorkItemProgress

func (s *Store) SetWorkItemProgress(ctx context.Context, id, step, progress string) error

SetWorkItemProgress writes the coarse step and the progress blob. Called from inside a running job, often, so it touches nothing else on the row.

func (*Store) SupersedePendingOrgPlans

func (s *Store) SupersedePendingOrgPlans(ctx context.Context, orgID string) error

SupersedePendingOrgPlans is SupersedePendingPlans for the org file. Same undecided set: 'clean' and 'error' rows are replaced by a newer plan too, they were not, so a clean run left the previous clean row sitting beside it and a parse failure stayed at the top of the list after the file was fixed. (stack_id holds the ORG id on this table, see the header comment.)

func (*Store) SupersedePendingPlans

func (s *Store) SupersedePendingPlans(ctx context.Context, stackID, envSlug string) error

SupersedePendingPlans marks undecided plans with the same scope superseded (a newer plan replaces them). Env-scoped plans only supersede their own env.

'error' is in the list because a plan that failed to parse is as undecided as a pending one: the operator fixes the file, plans again, and the red row from the broken commit otherwise stays at the top of the list looking current forever. Only 'applied' and 'rejected' are decisions, and those two are history.

func (*Store) SupersedeQueuedWorkItems

func (s *Store) SupersedeQueuedWorkItems(ctx context.Context, kind, dedupeKey, exceptID string) error

SupersedeQueuedWorkItems marks every waiting item of this kind and key superseded, except the one just enqueued. Only queued rows: a running job is already changing containers and databases, and abandoning it halfway is worse than letting it finish and be overwritten by the next one.

Older only, by rowid. "Everything but me" is not the same rule: two enqueues landing together each superseded the other and neither job ever ran, because ids are UUIDs and carry no order. rowid is already the queue order (ListWorkItemsByStatus, LatestWorkItem), so the later row wins and the earlier one is what gets dropped.

func (*Store) SweepStaleRuns

func (s *Store) SweepStaleRuns(ctx context.Context) error

SweepStaleRuns finishes work that died with the previous process. A deployment is only ever moved out of queued/running by the goroutine driving it, so anything still in those states at startup is orphaned; the tile it was building is marked stopped rather than error, and the metrics reconciler promotes it back to running on its next tick if the container is in fact up.

func (*Store) TouchOrgRegistryCredential

func (s *Store) TouchOrgRegistryCredential(ctx context.Context, id string) error
func (s *Store) TouchSecretLink(ctx context.Context, id string, attempts int, openedAt sql.NullTime) error

TouchSecretLink writes back the two fields that move without burning the link: the failed-passphrase count and the first-access stamp. Callers pass the values they read, so "stamp only on first access" is decided in the service, not here.

func (*Store) UpdateBackup

func (s *Store) UpdateBackup(ctx context.Context, b *repo.Backup) error

func (*Store) UpdateBackupDestination

func (s *Store) UpdateBackupDestination(ctx context.Context, d *repo.BackupDestination) error

UpdateBackupDestination rewrites the editable fields. An empty SecretKey keeps the stored one, the form never renders the secret back, so a save that leaves the field blank must not blank the credential.

func (*Store) UpdateBackupRun

func (s *Store) UpdateBackupRun(ctx context.Context, r *repo.BackupRun) error

func (*Store) UpdateConnector

func (s *Store) UpdateConnector(ctx context.Context, cn *repo.Connector) error

func (*Store) UpdateDeployment

func (s *Store) UpdateDeployment(ctx context.Context, d *repo.Deployment) error

func (*Store) UpdateDomainResource

func (s *Store) UpdateDomainResource(ctx context.Context, r *repo.DomainResource) error

func (*Store) UpdateEnvironment

func (s *Store) UpdateEnvironment(ctx context.Context, e *repo.Environment) error

func (*Store) UpdateOrg

func (s *Store) UpdateOrg(ctx context.Context, o *repo.Org) error

func (*Store) UpdateProvision

func (s *Store) UpdateProvision(ctx context.Context, p *repo.Provision) error

func (*Store) UpdateRegistry

func (s *Store) UpdateRegistry(ctx context.Context, r *repo.Registry) error

func (*Store) UpdateResource

func (s *Store) UpdateResource(ctx context.Context, r *repo.ManagedResource) error

func (*Store) UpdateServer

func (s *Store) UpdateServer(ctx context.Context, sv *repo.Server) error

func (*Store) UpdateStack

func (s *Store) UpdateStack(ctx context.Context, st *repo.Stack) error

func (*Store) UpdateStorage

func (s *Store) UpdateStorage(ctx context.Context, st *repo.Storage) error

func (*Store) UpdateTile

func (s *Store) UpdateTile(ctx context.Context, t *repo.Tile) error

func (*Store) UpdateTileStatus

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

func (*Store) UpdateUser

func (s *Store) UpdateUser(ctx context.Context, user *repo.User) error

UpdateUser also writes email and notification preferences, the account screen edits both, and leaving them out silently discarded the change.

func (*Store) UpsertAnnotation

func (s *Store) UpsertAnnotation(ctx context.Context, a *repo.Annotation) error

UpsertAnnotation validates then writes; the cap guards the same abuse the node-position limit does.

func (*Store) UpsertGraphGroup

func (s *Store) UpsertGraphGroup(ctx context.Context, g *repo.GraphGroup) error

UpsertGraphGroup validates then writes; the cap guards the same abuse the annotation limit does.

func (*Store) UpsertNodePosition

func (s *Store) UpsertNodePosition(ctx context.Context, p *repo.NodePosition) error

func (*Store) UpsertOrgMember

func (s *Store) UpsertOrgMember(ctx context.Context, m *repo.OrgMember) error

func (*Store) UpsertOutput

func (s *Store) UpsertOutput(ctx context.Context, o *repo.ResourceOutput) error

func (*Store) UpsertVariable

func (s *Store) UpsertVariable(ctx context.Context, v *repo.Variable) error

UpsertVariable overwrites by (owner, name), same name twice is one row, not the key_2 suffixing the old env blob did.

Jump to

Keyboard shortcuts

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