Documentation
¶
Index ¶
- Constants
- Variables
- func GlobMatch(patterns []string, fileName string) (bool, error)
- type BindingAppUse
- type CertStorage
- func (c *CertStorage) Delete(ctx context.Context, id string) error
- func (c *CertStorage) Exists(ctx context.Context, id string) bool
- func (c *CertStorage) List(ctx context.Context, prefix string, recursive bool) ([]string, error)
- func (c *CertStorage) Load(ctx context.Context, id string) ([]byte, error)
- func (c *CertStorage) Lock(ctx context.Context, id string) error
- func (c *CertStorage) Stat(ctx context.Context, id string) (certmagic.KeyInfo, error)
- func (c *CertStorage) Store(ctx context.Context, id string, value []byte) error
- func (c *CertStorage) Unlock(ctx context.Context, id string) error
- type DbFile
- type DbFileInfo
- type DbFileReader
- type DbFs
- func (d *DbFs) CreateTempSourceDir() (string, error)
- func (d *DbFs) FileHash(excludeGlob []string) (string, error)
- func (d *DbFs) Glob(pattern string) (matches []string, err error)
- func (d *DbFs) Open(name string) (fs.File, error)
- func (d *DbFs) ReadFile(name string) ([]byte, error)
- func (d *DbFs) Reset()
- func (d *DbFs) Stat(name string) (fs.FileInfo, error)
- func (d *DbFs) StatNoSpec(name string) (fs.FileInfo, error)
- func (d *DbFs) StaticFiles() []string
- type FileCache
- func (f *FileCache) AddCache(ctx context.Context, sha string, compressionType string, content []byte) error
- func (f *FileCache) Close() error
- func (f *FileCache) GetCachedFile(ctx context.Context, sha string) ([]byte, string, error)
- func (f *FileCache) VersionUpgrade(config *types.ServerConfig) error
- type FileStore
- func (f *FileStore) AddAppVersionDisk(ctx context.Context, tx types.Transaction, metadata types.AppMetadata, ...) error
- func (f *FileStore) AddAppVersionPrepared(ctx context.Context, tx types.Transaction, metadata types.AppMetadata, ...) error
- func (f *FileStore) GetAppFiles(ctx context.Context, tx types.Transaction) ([]types.AppFile, error)
- func (f *FileStore) GetAppVersion(ctx context.Context, tx types.Transaction, version int) (*types.AppVersion, error)
- func (f *FileStore) GetAppVersions(ctx context.Context, tx types.Transaction) ([]types.AppVersion, error)
- func (f *FileStore) GetFileBySha(sha string) ([]byte, string, error)
- func (f *FileStore) GetFileByShaTx(ctx context.Context, tx types.Transaction, sha string) ([]byte, string, error)
- func (f *FileStore) GetHighestVersion(ctx context.Context, tx types.Transaction, appId types.AppId) (int, error)
- func (f *FileStore) IncrementAppVersion(ctx context.Context, tx types.Transaction, metadata *types.AppMetadata) error
- func (f *FileStore) PrepareAppFiles(ctx context.Context, checkoutDir string) (*PreparedFiles, error)
- func (f *FileStore) PromoteApp(ctx context.Context, tx types.Transaction, prodAppId types.AppId, ...) error
- func (f *FileStore) Reset()
- type LeaderElection
- type LeaderState
- type Metadata
- func (m *Metadata) ActiveJobRuns(ctx context.Context) ([]types.JobRun, error)
- func (m *Metadata) AppsUsingBinding(ctx context.Context, tx types.Transaction, bindingPath string) ([]BindingAppUse, error)
- func (m *Metadata) BeginTransaction(ctx context.Context) (types.Transaction, error)
- func (m *Metadata) CleanupAppVersions(ctx context.Context, app types.AppInfo) error
- func (m *Metadata) CleanupExpiredKV(ctx context.Context) error
- func (m *Metadata) CleanupFiles(ctx context.Context) error
- func (m *Metadata) ClearServiceDefault(ctx context.Context, tx types.Transaction, serviceType, exceptName string) error
- func (m *Metadata) ClearServiceStaging(ctx context.Context, tx types.Transaction, serviceType, staging string) error
- func (m *Metadata) Close()
- func (m *Metadata) CommitTransaction(tx types.Transaction) error
- func (m *Metadata) CountOAuthClients(ctx context.Context) (int, error)
- func (m *Metadata) CountServices(ctx context.Context, tx types.Transaction, serviceType string) (int, error)
- func (m *Metadata) CreateApp(ctx context.Context, tx types.Transaction, app *types.AppEntry) error
- func (m *Metadata) CreateBinding(ctx context.Context, tx types.Transaction, binding *types.Binding) error
- func (m *Metadata) CreateBuilderActivity(ctx context.Context, tx types.Transaction, activity *types.BuilderActivity) error
- func (m *Metadata) CreateBuilderSession(ctx context.Context, tx types.Transaction, session *types.BuilderSession) error
- func (m *Metadata) CreateCredential(ctx context.Context, cred *types.Credential) error
- func (m *Metadata) CreateIdentity(ctx context.Context, identity *types.Identity) error
- func (m *Metadata) CreateJobRun(ctx context.Context, tx types.Transaction, run *types.JobRun) error
- func (m *Metadata) CreateOAuthClient(ctx context.Context, client *OAuthClient) error
- func (m *Metadata) CreateService(ctx context.Context, tx types.Transaction, service *types.Service) error
- func (m *Metadata) CreateSync(ctx context.Context, tx types.Transaction, sync *types.SyncEntry) error
- func (m *Metadata) DBType() system.DBType
- func (m *Metadata) DeleteApp(ctx context.Context, tx types.Transaction, id types.AppId) error
- func (m *Metadata) DeleteBinding(ctx context.Context, tx types.Transaction, path string) error
- func (m *Metadata) DeleteBindingProvider(ctx context.Context, tx types.Transaction, providerType, name string) error
- func (m *Metadata) DeleteBuilderSession(ctx context.Context, tx types.Transaction, id string) error
- func (m *Metadata) DeleteConfigDraft(ctx context.Context) error
- func (m *Metadata) DeleteCredential(ctx context.Context, id string) error
- func (m *Metadata) DeleteJobRunsForApps(ctx context.Context, appIds []types.AppId) ([]types.JobRun, error)
- func (m *Metadata) DeleteKV(ctx context.Context, key string) error
- func (m *Metadata) DeleteKVIfPresent(ctx context.Context, key string) (bool, error)
- func (m *Metadata) DeleteSecretEntry(ctx context.Context, name string) error
- func (m *Metadata) DeleteService(ctx context.Context, tx types.Transaction, name, serviceType string) error
- func (m *Metadata) DeleteSync(ctx context.Context, tx types.Transaction, id string) error
- func (m *Metadata) ExpiredJobRuns(ctx context.Context, now time.Time) ([]types.JobRun, error)
- func (m *Metadata) FetchKV(ctx context.Context, key string) (map[string]any, error)
- func (m *Metadata) FetchKVBlob(ctx context.Context, key string) ([]byte, error)
- func (m *Metadata) FinishJobRun(ctx context.Context, tx types.Transaction, id, status string, exitCode *int, ...) error
- func (m *Metadata) GetAllApps(includeInternal bool) ([]types.AppInfo, error)
- func (m *Metadata) GetAllAppsContext(ctx context.Context, includeInternal bool) ([]types.AppInfo, error)
- func (m *Metadata) GetAppEntry(ctx context.Context, pathDomain types.AppPathDomain) (*types.AppEntry, error)
- func (m *Metadata) GetAppEntryTx(ctx context.Context, tx types.Transaction, pathDomain types.AppPathDomain) (*types.AppEntry, error)
- func (m *Metadata) GetAppsForDomain(domain string) ([]string, error)
- func (m *Metadata) GetBinding(ctx context.Context, tx types.Transaction, path string) (*types.Binding, error)
- func (m *Metadata) GetBindingPathsForService(ctx context.Context, tx types.Transaction, serviceType, serviceName string) ([]string, error)
- func (m *Metadata) GetBindingProvider(ctx context.Context, tx types.Transaction, providerType, name string) (*types.BindingProvider, error)
- func (m *Metadata) GetBuilderSession(ctx context.Context, tx types.Transaction, id string) (*types.BuilderSession, error)
- func (m *Metadata) GetCertStorage() certmagic.Storage
- func (m *Metadata) GetConfig() (*types.DynamicConfig, error)
- func (m *Metadata) GetConfigDraft(ctx context.Context) (*types.ConfigDraft, error)
- func (m *Metadata) GetConfigVersion(ctx context.Context, versionId string) (*types.DynamicConfig, error)
- func (m *Metadata) GetCredentialWithIdentity(ctx context.Context, id string) (*types.Credential, *types.Identity, error)
- func (m *Metadata) GetDefaultService(ctx context.Context, tx types.Transaction, serviceType string) (*types.Service, error)
- func (m *Metadata) GetGrantStartTime(ctx context.Context, grantId string) (time.Time, error)
- func (m *Metadata) GetIdentityByPrincipal(ctx context.Context, principal string) (*types.Identity, error)
- func (m *Metadata) GetJobApps(ctx context.Context) ([]*types.AppEntry, error)
- func (m *Metadata) GetJobRun(ctx context.Context, id string) (*types.JobRun, error)
- func (m *Metadata) GetLinkedApps(ctx context.Context, tx types.Transaction, mainAppId types.AppId) ([]*types.AppEntry, error)
- func (m *Metadata) GetOAuthClient(ctx context.Context, id string) (*OAuthClient, error)
- func (m *Metadata) GetSecretEntry(ctx context.Context, name string) (*types.SecretEntry, error)
- func (m *Metadata) GetService(ctx context.Context, tx types.Transaction, serviceType, name string) (*types.Service, error)
- func (m *Metadata) GetServiceNamesUsingStaging(ctx context.Context, tx types.Transaction, serviceType, staging string) ([]string, error)
- func (m *Metadata) GetSyncEntries(ctx context.Context, tx types.Transaction) ([]*types.SyncEntry, error)
- func (m *Metadata) GetSyncEntry(ctx context.Context, tx types.Transaction, id string) (*types.SyncEntry, error)
- func (m *Metadata) GetVersionUsers() (map[types.AppId]map[int]string, error)
- func (m *Metadata) Health(ctx context.Context) types.MetadataHealthResponse
- func (m *Metadata) InitConfig(ctx context.Context, user string, dynamicConfig *types.DynamicConfig) error
- func (m *Metadata) InsertSecretEntry(ctx context.Context, entry *types.SecretEntry) error
- func (m *Metadata) IsLeader() bool
- func (m *Metadata) ListBindingProviders(ctx context.Context, tx types.Transaction) ([]*types.BindingProvider, error)
- func (m *Metadata) ListBindings(ctx context.Context, tx types.Transaction, source string) ([]*types.Binding, error)
- func (m *Metadata) ListBuilderActivity(ctx context.Context, sessionId, afterId string, limit int) ([]*types.BuilderActivity, error)
- func (m *Metadata) ListBuilderSessions(ctx context.Context, userID string) ([]*types.BuilderSession, error)
- func (m *Metadata) ListConfigHistory(ctx context.Context) ([]types.ConfigHistoryEntry, error)
- func (m *Metadata) ListCredentials(ctx context.Context, principal string) ([]types.ApiKeyInfo, error)
- func (m *Metadata) ListJobRuns(ctx context.Context, appIds []types.AppId, jobName, status string, limit int) ([]types.JobRun, error)
- func (m *Metadata) ListSecretEntries(ctx context.Context, includeValues bool) ([]*types.SecretEntry, error)
- func (m *Metadata) ListServices(ctx context.Context, tx types.Transaction, serviceType, name string) ([]*types.Service, error)
- func (m *Metadata) NotifyAppUpdate(appPathDomains []types.AppPathDomain) error
- func (m *Metadata) NotifyConfigUpdate() error
- func (m *Metadata) NotifyProviderUpdate(providerType, name string, deleted bool) error
- func (m *Metadata) ObserveFederatedIdentity(ctx context.Context, identity *types.Identity) error
- func (m *Metadata) PruneCredentials(ctx context.Context, cutoff time.Time) (int64, error)
- func (m *Metadata) PruneJobRuns(ctx context.Context, appId types.AppId, jobName string, keep int) ([]types.JobRun, error)
- func (m *Metadata) PruneUnusedOAuthClients(ctx context.Context, olderThan time.Time) (int64, error)
- func (m *Metadata) RevokeCredential(ctx context.Context, id string, reason string) error
- func (m *Metadata) RevokeGrantCredentials(ctx context.Context, grantId string, reason string) error
- func (m *Metadata) RollbackTransaction(tx types.Transaction) error
- func (m *Metadata) RotateRefreshToken(ctx context.Context, oldId string, newRefresh, newAccess *types.Credential) error
- func (m *Metadata) ServiceExists(ctx context.Context, tx types.Transaction, serviceType, name string) (bool, error)
- func (m *Metadata) SetConfigDraft(ctx context.Context, draft *types.ConfigDraft) error
- func (m *Metadata) StoreKV(ctx context.Context, key string, value map[string]any, expireAt *time.Time) error
- func (m *Metadata) StoreKVBlob(ctx context.Context, key string, value []byte, expireAt *time.Time) error
- func (m *Metadata) UpdateAppMetadata(ctx context.Context, tx types.Transaction, app *types.AppEntry) error
- func (m *Metadata) UpdateAppSettings(ctx context.Context, tx types.Transaction, app *types.AppEntry) error
- func (m *Metadata) UpdateBinding(ctx context.Context, tx types.Transaction, binding *types.Binding) error
- func (m *Metadata) UpdateBuilderSession(ctx context.Context, tx types.Transaction, session *types.BuilderSession) error
- func (m *Metadata) UpdateConfig(ctx context.Context, user string, oldVersionId string, ...) error
- func (m *Metadata) UpdateCredentialLastUsed(ctx context.Context, id string) error
- func (m *Metadata) UpdateJobRunContainer(ctx context.Context, tx types.Transaction, id, containerName, image string) error
- func (m *Metadata) UpdateJobRunLease(ctx context.Context, id string, leaseUntil time.Time) error
- func (m *Metadata) UpdateKV(ctx context.Context, key string, value map[string]any) error
- func (m *Metadata) UpdateKVBlob(ctx context.Context, key string, value []byte) error
- func (m *Metadata) UpdateSecretEntry(ctx context.Context, entry *types.SecretEntry) error
- func (m *Metadata) UpdateSecretEntryIfUnchanged(ctx context.Context, entry *types.SecretEntry, prevKeyId string, ...) (bool, error)
- func (m *Metadata) UpdateService(ctx context.Context, tx types.Transaction, service *types.Service) error
- func (m *Metadata) UpdateSourceUrl(ctx context.Context, tx types.Transaction, app *types.AppEntry) error
- func (m *Metadata) UpdateSyncStatus(ctx context.Context, tx types.Transaction, id string, ...) error
- func (m *Metadata) UpsertBindingProvider(ctx context.Context, tx types.Transaction, provider *types.BindingProvider) error
- func (m *Metadata) UpsertKVBlob(ctx context.Context, key string, value []byte, expireAt *time.Time) error
- func (m *Metadata) VersionUpgrade(config *types.ServerConfig) error
- type OAuthClient
- type PreparedFiles
Constants ¶
const ( COMPRESSION_THRESHOLD = 0 // files above this size are stored compressed. The chi Compress middleware does not have a threshold, // so the threshold is set to zero here BROTLI_COMPRESSION_LEVEL = 9 // https://paulcalvano.com/2018-07-25-brotli-compression-how-much-will-it-reduce-your-content/ seems )
const CURRENT_DB_VERSION = 28
const CURRENT_FILE_CACHE_VERSION = 1
Variables ¶
var ErrAppNotFound = errors.New("app not found")
ErrAppNotFound is returned when an app entry does not exist in the metadata store.
var ErrBuilderSessionNotFound = errors.New("not found")
ErrBuilderSessionNotFound marks a definitive missing-session lookup, as opposed to a transient query failure. Callers that DELETE state based on a session's absence (the startup state-volume sweep) must match this error specifically - any other error proves nothing about existence
var ErrConfigAlreadyExists = errors.New("config already exists")
var ErrConfigNotFound = errors.New("config not found")
var ErrJobRunConflict = errors.New("job run conflict")
ErrJobRunConflict is returned by CreateJobRun when the run cannot be claimed: the cron tick is already claimed, or the job already has an active run
var ErrJobRunNotFound = errors.New("job run not found")
ErrJobRunNotFound is returned when a run id does not exist
var ErrNoConfigDraft = errors.New("no staged config draft")
var ErrRefreshConsumed = errors.New("refresh token was already consumed")
ErrRefreshConsumed is returned by RotateRefreshToken when the presented refresh token was concurrently consumed by another rotation. Callers treat this exactly like reuse of a rotated token: the grant is compromised
Functions ¶
Types ¶
type BindingAppUse ¶ added in v0.18.15
BindingAppUse is one app row referencing a binding: the app's own id, its main app id (stage/preview rows link to their main app; dev and main apps are their own main) and its path-domain string.
type CertStorage ¶ added in v0.16.11
CertStorage is the database backed storage for the cert info. Implements the certmagic.Storage interface.
func NewCertStorage ¶ added in v0.16.11
func (*CertStorage) Delete ¶ added in v0.16.11
func (c *CertStorage) Delete(ctx context.Context, id string) error
Delete deletes the certificate with the given id.
func (*CertStorage) Exists ¶ added in v0.16.11
func (c *CertStorage) Exists(ctx context.Context, id string) bool
Exists checks if the certificate with the given id exists.
func (*CertStorage) Lock ¶ added in v0.16.11
func (c *CertStorage) Lock(ctx context.Context, id string) error
Lock locks the certificate with the given id.
func (*CertStorage) Stat ¶ added in v0.16.11
Stat returns the information about the certificate with the given id.
type DbFile ¶
type DbFile struct {
// contains filtered or unexported fields
}
type DbFileInfo ¶
type DbFileInfo struct {
// contains filtered or unexported fields
}
func (*DbFileInfo) IsDir ¶
func (fi *DbFileInfo) IsDir() bool
func (*DbFileInfo) ModTime ¶
func (fi *DbFileInfo) ModTime() time.Time
func (*DbFileInfo) Mode ¶
func (fi *DbFileInfo) Mode() fs.FileMode
func (*DbFileInfo) Name ¶
func (fi *DbFileInfo) Name() string
func (*DbFileInfo) Size ¶
func (fi *DbFileInfo) Size() int64
func (*DbFileInfo) Sys ¶
func (fi *DbFileInfo) Sys() any
type DbFileReader ¶
type DbFileReader struct {
// contains filtered or unexported fields
}
func NewDbFileReader ¶
func NewDbFileReader(compressionType string, data []byte) *DbFileReader
func (*DbFileReader) ReadCompressed ¶
func (f *DbFileReader) ReadCompressed() ([]byte, string, error)
type DbFs ¶
func (*DbFs) CreateTempSourceDir ¶
func (*DbFs) FileHash ¶
FileHash returns a hash of the file names and their corresponding sha256 hashes (see appfs.SourceFileHash)
func (*DbFs) StaticFiles ¶
type FileCache ¶ added in v0.14.7
func InitFileCache ¶ added in v0.14.7
func (*FileCache) GetCachedFile ¶ added in v0.14.7
func (*FileCache) VersionUpgrade ¶ added in v0.14.7
func (f *FileCache) VersionUpgrade(config *types.ServerConfig) error
type FileStore ¶
type FileStore struct {
// contains filtered or unexported fields
}
func NewFileStore ¶
func (*FileStore) AddAppVersionDisk ¶
func (f *FileStore) AddAppVersionDisk(ctx context.Context, tx types.Transaction, metadata types.AppMetadata, checkoutDir string) error
AddAppVersionDisk records a new app version and loads the files under checkoutDir into the database, hashing and compressing them while the transaction is held. Callers that can afford it should use PrepareAppFiles before the transaction and AddAppVersionPrepared inside it instead
func (*FileStore) AddAppVersionPrepared ¶ added in v0.19.4
func (f *FileStore) AddAppVersionPrepared(ctx context.Context, tx types.Transaction, metadata types.AppMetadata, prepared *PreparedFiles) error
AddAppVersionPrepared records a new app version and inserts the files prepared by PrepareAppFiles. Only the inserts run inside the transaction; the content of files already present in the files table is not re-sent
func (*FileStore) GetAppFiles ¶
func (*FileStore) GetAppVersion ¶
func (f *FileStore) GetAppVersion(ctx context.Context, tx types.Transaction, version int) (*types.AppVersion, error)
func (*FileStore) GetAppVersions ¶
func (f *FileStore) GetAppVersions(ctx context.Context, tx types.Transaction) ([]types.AppVersion, error)
func (*FileStore) GetFileBySha ¶
func (*FileStore) GetFileByShaTx ¶
func (*FileStore) GetHighestVersion ¶
func (*FileStore) IncrementAppVersion ¶
func (f *FileStore) IncrementAppVersion(ctx context.Context, tx types.Transaction, metadata *types.AppMetadata) error
func (*FileStore) PrepareAppFiles ¶ added in v0.19.4
func (f *FileStore) PrepareAppFiles(ctx context.Context, checkoutDir string) (*PreparedFiles, error)
PrepareAppFiles walks checkoutDir and hashes and compresses its files, with no transaction held. The result is inserted later by AddAppVersionPrepared. The whole compressed source is held in memory until then
func (*FileStore) PromoteApp ¶
func (f *FileStore) PromoteApp(ctx context.Context, tx types.Transaction, prodAppId types.AppId, metadata *types.AppMetadata) error
type LeaderElection ¶ added in v0.16.21
func NewLeaderElection ¶ added in v0.16.21
func NewLeaderElection(logger *types.Logger, metadata *Metadata, config *types.ServerConfig, nodeId string, hostname string) *LeaderElection
func (*LeaderElection) CreateTables ¶ added in v0.16.21
func (l *LeaderElection) CreateTables(ctx context.Context, tx types.Transaction) error
func (*LeaderElection) IsLeader ¶ added in v0.16.21
func (l *LeaderElection) IsLeader() bool
func (*LeaderElection) StartLoop ¶ added in v0.16.21
func (l *LeaderElection) StartLoop(parentCtx context.Context)
func (*LeaderElection) Stop ¶ added in v0.16.21
func (l *LeaderElection) Stop()
type LeaderState ¶ added in v0.16.21
type Metadata ¶
type Metadata struct {
*types.Logger
AppNotifyFunc func(types.AppUpdatePayload)
ConfigNotifyFunc func(types.ConfigUpdatePayload)
ProviderNotifyFunc func(types.ProviderUpdatePayload)
// contains filtered or unexported fields
}
Metadata is the metadata persistence layer
func NewMetadata ¶
NewMetadata creates a new metadata persistence layer
func (*Metadata) ActiveJobRuns ¶ added in v0.19.4
ActiveJobRuns returns every run still executing, across all apps
func (*Metadata) AppsUsingBinding ¶ added in v0.18.15
func (m *Metadata) AppsUsingBinding(ctx context.Context, tx types.Transaction, bindingPath string) ([]BindingAppUse, error)
AppsUsingBinding returns the app rows whose metadata references bindingPath. A stage/prod pair shows up as two rows sharing one MainApp.
func (*Metadata) BeginTransaction ¶
BeginTransaction starts a new Transaction
func (*Metadata) CleanupAppVersions ¶ added in v0.16.22
func (*Metadata) CleanupExpiredKV ¶ added in v0.17.1
func (*Metadata) CleanupFiles ¶ added in v0.16.22
func (*Metadata) ClearServiceDefault ¶ added in v0.17.2
func (m *Metadata) ClearServiceDefault(ctx context.Context, tx types.Transaction, serviceType, exceptName string) error
ClearServiceDefault unsets the is_default flag for any service of the given service_type except for the service with the given name. If exceptName is empty, the default flag is cleared for all services of that type.
func (*Metadata) ClearServiceStaging ¶ added in v0.17.2
func (*Metadata) Close ¶ added in v0.16.21
func (m *Metadata) Close()
Close stops background goroutines owned by Metadata (leader election and the postgres listener) and closes the database connection pools.
func (*Metadata) CommitTransaction ¶
func (m *Metadata) CommitTransaction(tx types.Transaction) error
CommitTransaction commits a transaction
func (*Metadata) CountOAuthClients ¶ added in v0.19.3
CountOAuthClients returns the number of registered clients (DCR quota)
func (*Metadata) CountServices ¶ added in v0.17.2
func (m *Metadata) CountServices(ctx context.Context, tx types.Transaction, serviceType string) (int, error)
CountServices returns the number of services of the given service_type.
func (*Metadata) CreateBinding ¶ added in v0.17.2
func (*Metadata) CreateBuilderActivity ¶ added in v0.18.6
func (m *Metadata) CreateBuilderActivity(ctx context.Context, tx types.Transaction, activity *types.BuilderActivity) error
func (*Metadata) CreateBuilderSession ¶ added in v0.18.6
func (m *Metadata) CreateBuilderSession(ctx context.Context, tx types.Transaction, session *types.BuilderSession) error
func (*Metadata) CreateCredential ¶ added in v0.19.3
CreateCredential inserts a credential row (the secret hash, never the secret)
func (*Metadata) CreateIdentity ¶ added in v0.19.3
CreateIdentity inserts a new identity row. The caller generates the id and ensures the principal does not exist (unique index enforces it)
func (*Metadata) CreateJobRun ¶ added in v0.19.4
CreateJobRun claims and records a new run. The run starts as running, owned by its node; ErrJobRunConflict when the cron tick was already claimed or the job has an active run (unless the run is forced)
func (*Metadata) CreateOAuthClient ¶ added in v0.19.3
func (m *Metadata) CreateOAuthClient(ctx context.Context, client *OAuthClient) error
CreateOAuthClient inserts a registered client row
func (*Metadata) CreateService ¶ added in v0.17.2
func (*Metadata) CreateSync ¶
func (*Metadata) DBType ¶ added in v0.18.15
DBType returns the metadata database type (sqlite or postgres)
func (*Metadata) DeleteBinding ¶ added in v0.17.2
func (*Metadata) DeleteBindingProvider ¶ added in v0.18.7
func (*Metadata) DeleteBuilderSession ¶ added in v0.18.6
func (*Metadata) DeleteConfigDraft ¶ added in v0.18.4
DeleteConfigDraft drops the staged config draft
func (*Metadata) DeleteCredential ¶ added in v0.19.3
DeleteCredential removes a credential row, types.ErrApiKeyNotFound when absent
func (*Metadata) DeleteJobRunsForApps ¶ added in v0.19.4
func (m *Metadata) DeleteJobRunsForApps(ctx context.Context, appIds []types.AppId) ([]types.JobRun, error)
DeleteJobRunsForApps deletes every run of the given app instances (app delete) and returns them so the caller can remove their containers
func (*Metadata) DeleteKVIfPresent ¶ added in v0.18.15
DeleteKVIfPresent deletes the entry and reports whether a row was actually removed. Used as an atomic single-consumer gate: with two concurrent deletes of the same key (e.g. a double-submitted single-use login state), exactly one caller sees deleted=true
func (*Metadata) DeleteSecretEntry ¶ added in v0.18.6
DeleteSecretEntry deletes the secret with the given name, types.ErrSecretNotFound if it does not exist
func (*Metadata) DeleteService ¶ added in v0.17.2
func (*Metadata) DeleteSync ¶
func (*Metadata) ExpiredJobRuns ¶ added in v0.19.4
ExpiredJobRuns returns the active runs whose liveness stamp is older than now: their node stopped renewing it
func (*Metadata) FetchKVBlob ¶ added in v0.15.3
func (*Metadata) FinishJobRun ¶ added in v0.19.4
func (m *Metadata) FinishJobRun(ctx context.Context, tx types.Transaction, id, status string, exitCode *int, message string) error
FinishJobRun records the run's terminal state, releasing its active slot. A run already finished (a cancel racing the owner's own finish) is left as is
func (*Metadata) GetAllApps ¶
func (*Metadata) GetAllAppsContext ¶ added in v0.19.2
func (m *Metadata) GetAllAppsContext(ctx context.Context, includeInternal bool) ([]types.AppInfo, error)
GetAllAppsContext is the cancellable form used by background ownership tasks that must be joined before database shutdown.
func (*Metadata) GetAppEntry ¶ added in v0.18.0
func (*Metadata) GetAppEntryTx ¶ added in v0.18.0
func (m *Metadata) GetAppEntryTx(ctx context.Context, tx types.Transaction, pathDomain types.AppPathDomain) (*types.AppEntry, error)
func (*Metadata) GetAppsForDomain ¶
func (*Metadata) GetBinding ¶ added in v0.17.2
func (*Metadata) GetBindingPathsForService ¶ added in v0.18.20
func (m *Metadata) GetBindingPathsForService(ctx context.Context, tx types.Transaction, serviceType, serviceName string) ([]string, error)
GetBindingPathsForService returns the paths of the bindings provisioned from the given service, ordered by path.
func (*Metadata) GetBindingProvider ¶ added in v0.18.7
func (m *Metadata) GetBindingProvider(ctx context.Context, tx types.Transaction, providerType, name string) (*types.BindingProvider, error)
func (*Metadata) GetBuilderSession ¶ added in v0.18.6
func (m *Metadata) GetBuilderSession(ctx context.Context, tx types.Transaction, id string) (*types.BuilderSession, error)
func (*Metadata) GetCertStorage ¶ added in v0.16.11
GetCertStorage returns the cert storage implementation which persists the cert info to the database.
func (*Metadata) GetConfig ¶ added in v0.14.10
func (m *Metadata) GetConfig() (*types.DynamicConfig, error)
func (*Metadata) GetConfigDraft ¶ added in v0.18.4
GetConfigDraft returns the staged config draft, ErrNoConfigDraft if none
func (*Metadata) GetConfigVersion ¶ added in v0.18.4
func (m *Metadata) GetConfigVersion(ctx context.Context, versionId string) (*types.DynamicConfig, error)
GetConfigVersion returns the full dynamic config snapshot for a history version
func (*Metadata) GetCredentialWithIdentity ¶ added in v0.19.3
func (m *Metadata) GetCredentialWithIdentity(ctx context.Context, id string) (*types.Credential, *types.Identity, error)
GetCredentialWithIdentity returns the credential and its identity row, types.ErrApiKeyNotFound when absent
func (*Metadata) GetDefaultService ¶ added in v0.17.2
func (*Metadata) GetGrantStartTime ¶ added in v0.19.4
GetGrantStartTime returns the creation time of the oldest credential minted under the grant: the consent time, which anchors the absolute grant lifetime (api.grant_max_ttl) that refresh rotation cannot slide past
func (*Metadata) GetIdentityByPrincipal ¶ added in v0.19.3
func (m *Metadata) GetIdentityByPrincipal(ctx context.Context, principal string) (*types.Identity, error)
GetIdentityByPrincipal returns the identity row for a provider:username principal, sql.ErrNoRows wrapped when absent
func (*Metadata) GetJobApps ¶ added in v0.19.4
GetJobApps returns the prod and stage app entries that declare any job, for the scheduler. The metadata JSON is filtered in SQL so apps without jobs are not decoded every minute
func (*Metadata) GetLinkedApps ¶
func (m *Metadata) GetLinkedApps(ctx context.Context, tx types.Transaction, mainAppId types.AppId) ([]*types.AppEntry, error)
GetLinkedApps gets all the apps linked to the given main app (staging and preview apps)
func (*Metadata) GetOAuthClient ¶ added in v0.19.3
GetOAuthClient returns the registered client, sql.ErrNoRows when absent
func (*Metadata) GetSecretEntry ¶ added in v0.18.6
GetSecretEntry returns the secret row for the given name, types.ErrSecretNotFound if it does not exist
func (*Metadata) GetService ¶ added in v0.17.2
func (*Metadata) GetServiceNamesUsingStaging ¶ added in v0.18.20
func (m *Metadata) GetServiceNamesUsingStaging(ctx context.Context, tx types.Transaction, serviceType, staging string) ([]string, error)
GetServiceNamesUsingStaging returns the names of the services of the given type that use the named service as their staging service, ordered by name.
func (*Metadata) GetSyncEntries ¶
func (m *Metadata) GetSyncEntries(ctx context.Context, tx types.Transaction) ([]*types.SyncEntry, error)
GetSyncEntries gets all the sync entries for the given webhook type
func (*Metadata) GetSyncEntry ¶
func (*Metadata) GetVersionUsers ¶ added in v0.18.6
GetVersionUsers returns the user who created each app version, keyed by app id and version. Used to annotate app listings with who performed the last (active version) update, in one query instead of per app
func (*Metadata) Health ¶ added in v0.18.19
func (m *Metadata) Health(ctx context.Context) types.MetadataHealthResponse
Health returns a point-in-time view of metadata connectivity and the database/sql pool. SQLite additionally exposes file sizes and the latest background checkpoint/vacuum measurements.
func (*Metadata) InitConfig ¶ added in v0.14.10
func (*Metadata) InsertSecretEntry ¶ added in v0.18.6
InsertSecretEntry inserts a new secret row, types.ErrSecretExists if a row with the same name is already present
func (*Metadata) IsLeader ¶ added in v0.16.21
IsLeader returns true if the current server is the leader
func (*Metadata) ListBindingProviders ¶ added in v0.18.7
func (m *Metadata) ListBindingProviders(ctx context.Context, tx types.Transaction) ([]*types.BindingProvider, error)
ListBindingProviders returns all installed providers, of every type.
func (*Metadata) ListBindings ¶ added in v0.17.2
func (m *Metadata) ListBindings(ctx context.Context, tx types.Transaction, source string) ([]*types.Binding, error)
ListBindings returns bindings filtered by the optional source. Empty string means no filter.
func (*Metadata) ListBuilderActivity ¶ added in v0.18.6
func (m *Metadata) ListBuilderActivity(ctx context.Context, sessionId, afterId string, limit int) ([]*types.BuilderActivity, error)
ListBuilderActivity returns activity rows for a session in insertion order (activity ids are time-ordered ksuids). afterId returns rows later than the given id, for incremental fetches; limit 0 means no limit
func (*Metadata) ListBuilderSessions ¶ added in v0.18.6
func (m *Metadata) ListBuilderSessions(ctx context.Context, userID string) ([]*types.BuilderSession, error)
ListBuilderSessions returns all sessions, newest first, optionally filtered to one user
func (*Metadata) ListConfigHistory ¶ added in v0.18.4
ListConfigHistory returns the config history entries, newest first
func (*Metadata) ListCredentials ¶ added in v0.19.3
func (m *Metadata) ListCredentials(ctx context.Context, principal string) ([]types.ApiKeyInfo, error)
ListCredentials returns credentials joined with their principal names. principal "" lists all credentials; otherwise only that principal's. Revoked credentials and consumed rotation history are retained in the table as evidence but are dead for use, so the listing excludes them
func (*Metadata) ListJobRuns ¶ added in v0.19.4
func (m *Metadata) ListJobRuns(ctx context.Context, appIds []types.AppId, jobName, status string, limit int) ([]types.JobRun, error)
ListJobRuns returns the runs of the given app instances, newest first, optionally filtered by job name and status
func (*Metadata) ListSecretEntries ¶ added in v0.18.6
func (m *Metadata) ListSecretEntries(ctx context.Context, includeValues bool) ([]*types.SecretEntry, error)
ListSecretEntries returns all secret rows, sorted by name. With includeValues false the ciphertext and nonce columns are not fetched; listing does not need to pull up to 1MiB blobs per row
func (*Metadata) ListServices ¶ added in v0.17.2
func (m *Metadata) ListServices(ctx context.Context, tx types.Transaction, serviceType, name string) ([]*types.Service, error)
ListServices returns services filtered by the optional serviceType and name. Empty string means no filter.
func (*Metadata) NotifyAppUpdate ¶
func (m *Metadata) NotifyAppUpdate(appPathDomains []types.AppPathDomain) error
NotifyAppUpdate sends a notification through the postgres listener that an app has been updated
func (*Metadata) NotifyConfigUpdate ¶ added in v0.15.0
NotifyConfigUpdate sends a notification through the postgres listener that the config has been updated
func (*Metadata) NotifyProviderUpdate ¶ added in v0.18.7
NotifyProviderUpdate broadcasts that a provider was installed, updated or uninstalled, so other replicas reconcile it from the database.
func (*Metadata) ObserveFederatedIdentity ¶ added in v0.19.4
ObserveFederatedIdentity persists groups from a verified interactive login. Concurrent first logins converge on the principal's existing identity; group refreshes must not replace its id, credentials, or disabled status.
func (*Metadata) PruneCredentials ¶ added in v0.19.4
PruneCredentials deletes credential rows past use and past their evidence-retention window: rows revoked before the cutoff, and expired rows of any type (consumed rotation history included) whose expiry is before the cutoff. Rotation replay evidence therefore survives until the whole family is past its expiry window plus the retention grace. Non-expiring, unrevoked PATs are never pruned
func (*Metadata) PruneJobRuns ¶ added in v0.19.4
func (m *Metadata) PruneJobRuns(ctx context.Context, appId types.AppId, jobName string, keep int) ([]types.JobRun, error)
PruneJobRuns deletes the finished runs of a job beyond the newest keep records and returns the deleted runs, so the caller can remove their containers
func (*Metadata) PruneUnusedOAuthClients ¶ added in v0.19.3
PruneUnusedOAuthClients deletes registered clients older than the cutoff that no live (unrevoked) credential references, freeing DCR quota slots
func (*Metadata) RevokeCredential ¶ added in v0.19.3
RevokeCredential revokes one credential (access token or PAT)
func (*Metadata) RevokeGrantCredentials ¶ added in v0.19.3
RevokeGrantCredentials revokes every credential minted under one grant (logout, or refresh-token reuse detection). Consumed rotation history is retained as replay evidence until family expiry
func (*Metadata) RollbackTransaction ¶
func (m *Metadata) RollbackTransaction(tx types.Transaction) error
RollbackTransaction rolls back a transaction
func (*Metadata) RotateRefreshToken ¶ added in v0.19.3
func (m *Metadata) RotateRefreshToken(ctx context.Context, oldId string, newRefresh, newAccess *types.Credential) error
RotateRefreshToken atomically consumes the presented refresh token and inserts its successor plus the new access token in one transaction. Returns types.ErrApiKeyNotFound-style failure via error when the old token was already consumed by a concurrent rotation (the caller treats that as reuse)
func (*Metadata) ServiceExists ¶ added in v0.17.2
func (*Metadata) SetConfigDraft ¶ added in v0.18.4
SetConfigDraft creates or replaces the staged config draft
func (*Metadata) StoreKVBlob ¶ added in v0.15.3
func (*Metadata) UpdateAppMetadata ¶
func (*Metadata) UpdateAppSettings ¶
func (*Metadata) UpdateBinding ¶ added in v0.17.2
func (*Metadata) UpdateBuilderSession ¶ added in v0.18.6
func (m *Metadata) UpdateBuilderSession(ctx context.Context, tx types.Transaction, session *types.BuilderSession) error
func (*Metadata) UpdateConfig ¶ added in v0.14.10
func (*Metadata) UpdateCredentialLastUsed ¶ added in v0.19.3
UpdateCredentialLastUsed stamps the credential's last use time. Callers throttle this (once per verification is acceptable at management API rates)
func (*Metadata) UpdateJobRunContainer ¶ added in v0.19.4
func (m *Metadata) UpdateJobRunContainer(ctx context.Context, tx types.Transaction, id, containerName, image string) error
UpdateJobRunContainer records the container (or Kubernetes Job) name and the image the run uses, before the workload starts
func (*Metadata) UpdateJobRunLease ¶ added in v0.19.4
UpdateJobRunLease renews the run's liveness stamp
func (*Metadata) UpdateKVBlob ¶ added in v0.15.3
func (*Metadata) UpdateSecretEntry ¶ added in v0.18.6
UpdateSecretEntry updates the value (and metadata) of an existing secret, types.ErrSecretNotFound if the name is not present
func (*Metadata) UpdateSecretEntryIfUnchanged ¶ added in v0.18.6
func (m *Metadata) UpdateSecretEntryIfUnchanged(ctx context.Context, entry *types.SecretEntry, prevKeyId string, prevNonce []byte) (bool, error)
UpdateSecretEntryIfUnchanged updates the row only if its current key_id and nonce still match prevKeyId/prevNonce, returning whether a row was updated
func (*Metadata) UpdateService ¶ added in v0.17.2
func (*Metadata) UpdateSourceUrl ¶ added in v0.14.7
func (*Metadata) UpdateSyncStatus ¶
func (m *Metadata) UpdateSyncStatus(ctx context.Context, tx types.Transaction, id string, status *types.SyncJobStatus) error
func (*Metadata) UpsertBindingProvider ¶ added in v0.18.7
func (m *Metadata) UpsertBindingProvider(ctx context.Context, tx types.Transaction, provider *types.BindingProvider) error
UpsertBindingProvider creates or replaces a provider entry. The provider's Type and Name together identify the row.
func (*Metadata) UpsertKVBlob ¶ added in v0.17.1
func (*Metadata) VersionUpgrade ¶
func (m *Metadata) VersionUpgrade(config *types.ServerConfig) error
type OAuthClient ¶ added in v0.19.3
type OAuthClient struct {
Id string `json:"client_id"`
Name string `json:"client_name"`
RedirectUris []string `json:"redirect_uris"`
}
OAuthClient is one dynamically registered OAuth client (public, PKCE only)
type PreparedFiles ¶ added in v0.19.4
type PreparedFiles struct {
// contains filtered or unexported fields
}
PreparedFiles holds an app source directory's files, hashed and compressed by PrepareAppFiles outside of any database transaction, ready to be inserted by AddAppVersionPrepared. The compressed content of every file is kept (files whose sha already exists are not skipped at prepare time), so the insert stays correct even if the orphan file cleanup removed a row between the prepare and the insert
func (*PreparedFiles) Len ¶ added in v0.19.4
func (p *PreparedFiles) Len() int
Len returns the number of prepared files