store

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package store owns the controller's SQLite database (D5).

Writes go through a single connection so they are serialized; reads use a separate pool. Both run in WAL mode.

Index

Constants

View Source
const (
	UserHuman   = "user"
	UserService = "service" // service account: keys and tokens only, no console login
)

User kinds.

View Source
const (
	TempRole   = "role"   // sts assume-role
	TempDevice = "device" // synctl login
	TempShell  = "shell"  // Cloud Shell
)

Kinds of temporary credentials.

View Source
const (
	RunPending   = "pending"
	RunRunning   = "running"
	RunSucceeded = "succeeded"
	RunFailed    = "failed"
	RunTimedOut  = "timed_out"
	RunCancelled = "cancelled"
	RunSkipped   = "skipped"
)

Job run statuses.

View Source
const (
	NodePending  = "pending" // joined, never connected
	NodeReady    = "ready"
	NodeSuspect  = "suspect"   // no heartbeat for 20s
	NodeNotReady = "not_ready" // no heartbeat for 60s
)

Node statuses (§5.6).

View Source
const (
	DefaultGroupName        = "default"
	DefaultGroupDescription = "Services in the same environment can reach each other; all outbound traffic is allowed."
	DefaultGroupInbound     = `[{"protocol":"any","ports":"","peers":["environment:self"],"description":"Services in the same environment"}]`
	DefaultGroupOutbound    = `[{"protocol":"any","ports":"","peers":["any"],"description":"All outbound traffic"}]`
)

Rules of a project's default security group (§8.3), as JSON. The same text is used by the migration for existing projects.

View Source
const (
	SettingSetupTokenHash    = "setup.token_hash"
	SettingSetupTokenExpires = "setup.token_expires"
	SettingBaseDomain        = "domain.base"
	// SettingRecoverySuffixHash lets the setup wizard confirm the user saved the
	// recovery key (they type its last 6 characters).
	SettingRecoverySuffixHash = "recovery.suffix_hash"
	// SettingRecoveryKey is the recovery key, sealed with the master key, so
	// the root user can look it up later.
	SettingRecoveryKey = "recovery.key"
)

Setting keys.

View Source
const (
	TaskPending  = "pending"
	TaskPulling  = "pulling"
	TaskStarting = "starting"
	TaskRunning  = "running"
	TaskExited   = "exited"
	TaskFailed   = "failed"
	TaskStopped  = "stopped"
	TaskLost     = "lost"
)

Task states.

View Source
const (
	DeployInProgress = "in_progress"
	DeploySucceeded  = "succeeded"
	DeployFailed     = "failed"
	DeployRolledBack = "rolled_back"
	DeploySuperseded = "superseded"
)

Deployment statuses.

View Source
const (
	TriggerManual       = "manual"
	TriggerGit          = "git"
	TriggerRollback     = "rollback"
	TriggerAutoRollback = "auto-rollback"
	TriggerVariables    = "variables"
	TriggerRedeploy     = "redeploy"
	TriggerConfig       = "config"
	// TriggerImage: a new push of the service's image tag (auto-deploy or
	// the deploy webhook).
	TriggerImage = "image"
)

Deployment triggers: what started a deployment.

View Source
const DeployCancelled = "cancelled"

DeployCancelled marks a deployment stopped by a user.

View Source
const DeployWaitingHook = "waiting_hook"

Deployment status while a pre-deploy hook runs (§5.11).

View Source
const MaxAccessKeysPerUser = 2

MaxAccessKeysPerUser allows rotation: create the new key, switch, delete the old one (§7.1).

View Source
const MaxDeploymentEvents = 2000

MaxDeploymentEvents bounds one deployment's log (a crash-looping task would otherwise grow it without end).

View Source
const MaxRollbackWindow = 50

MaxRollbackWindow is the most revisions a project may keep images for (task definitions beyond the GC retention are gone anyway).

View Source
const PullDedupWindow = 30 * time.Second

PullDedupWindow merges the manifest requests of one pull.

Variables

View Source
var DefaultRetention = Retention{
	Audit: 365 * 24 * time.Hour, Incidents: 90 * 24 * time.Hour, Deployments: 90 * 24 * time.Hour,
	Builds: 90 * 24 * time.Hour, Usage: 400 * 24 * time.Hour, Revisions: 50,
}

DefaultRetention is what the controller applies unless configured.

View Source
var ErrInUse = errors.New("in use")

ErrInUse means something still refers to the object.

View Source
var ErrLimitReached = errors.New("limit reached")
View Source
var ErrNameTaken = errors.New("name already taken")
View Source
var ErrNotEmpty = errors.New("not empty")

ErrNotEmpty means the resource still has children.

View Source
var ErrNotFound = errors.New("not found")
View Source
var ErrPoolExhausted = errors.New("address pool exhausted")

ErrPoolExhausted means no index is free.

View Source
var ErrSetupDone = errors.New("setup already completed")

Functions

This section is empty.

Types

type APIToken

type APIToken struct {
	ID         string
	UserID     string
	Name       string
	TokenHash  string
	CreatedAt  time.Time
	ExpiresAt  *time.Time
	LastUsedAt *time.Time
	LastUsedIP string
	AllowedIPs []string
}

type AccessKey

type AccessKey struct {
	ID          string
	UserID      string
	SecretEnc   []byte
	Description string
	CreatedAt   time.Time
	LastUsedAt  *time.Time
	LastUsedIP  string
	ExpiresAt   *time.Time
	AllowedIPs  []string // CIDRs; empty: any
}

type AddressRecord

type AddressRecord struct {
	IP         string     `json:"ip"`
	OwnerID    string     `json:"ownerId"`
	Owner      string     `json:"owner"`
	NodeID     string     `json:"nodeId"`
	AssignedAt time.Time  `json:"assignedAt"`
	ReleasedAt *time.Time `json:"releasedAt"`
}

AddressRecord is one assignment of a container address (§8.2).

type AlertChannel

type AlertChannel struct {
	ID        string
	Name      string
	Type      string
	ConfigEnc []byte
	Summary   string
	CreatedAt time.Time
}

type AlertEvent

type AlertEvent struct {
	ID       int64     `json:"id"`
	RuleID   string    `json:"ruleId"`
	RuleName string    `json:"rule"`
	Severity string    `json:"severity"`
	Kind     string    `json:"kind"`
	Key      string    `json:"key"`
	Label    string    `json:"label"`
	Message  string    `json:"message"`
	Value    *float64  `json:"value"`
	Delivery string    `json:"delivery"`
	At       time.Time `json:"at"`
}

AlertEvent is a notification: an alert firing or resolving, or a one-off event (a failed deployment).

type AlertRule

type AlertRule struct {
	ID        string
	Name      string
	Spec      string // JSON
	Enabled   bool
	CreatedAt time.Time
	UpdatedAt time.Time
}

type AlertState

type AlertState struct {
	RuleID  string    `json:"ruleId"`
	Key     string    `json:"key"`
	Label   string    `json:"label"`
	State   string    `json:"state"` // pending | firing
	Since   time.Time `json:"since"`
	Value   *float64  `json:"value"`
	Message string    `json:"message"`
}

AlertState is a rule instance whose condition holds.

type Attachment

type Attachment struct {
	PrincipalType string `json:"principalType"`
	PrincipalID   string `json:"principalId"`
	Policy        string `json:"policy"`
}

type AuditEvent

type AuditEvent struct {
	At        time.Time
	ActorID   string // empty for unauthenticated actions (e.g. failed login)
	Action    string // e.g. "auth:Login", "setup:CreateRoot"
	Resource  string // e.g. "srn:syncloud:user/<id>"
	IP        string
	UserAgent string
	Detail    map[string]any
}

type AuditFilter

type AuditFilter struct {
	ActorID, Action, Resource, Text string
	Since, Until                    time.Time
	BeforeID                        int64 // paging: events older than this ID
}

AuditFilter selects events; empty fields match everything.

type AuditRecord

type AuditRecord struct {
	ID        int64          `json:"id"`
	At        time.Time      `json:"at"`
	ActorID   string         `json:"actorId"`
	Actor     string         `json:"actor"` // email, joined in
	Action    string         `json:"action"`
	Resource  string         `json:"resource"`
	IP        string         `json:"ip"`
	UserAgent string         `json:"userAgent"`
	Detail    map[string]any `json:"detail"`
}

AuditRecord is a stored audit event.

type Build

type Build struct {
	ID        string `json:"id"`
	ServiceID string `json:"serviceId"`
	SHA       string `json:"sha"`
	Ref       string `json:"ref"`
	Trigger   string `json:"trigger"`
	Status    string `json:"status"`
	Image     string `json:"image"`
	RunID     string `json:"runId"`
	Message   string `json:"message"`
	Deployed  bool   `json:"deployed"`
	BaseSHA   string `json:"baseSha"`
	// CheckRunID is the run of the after-build checks (Phase 15b).
	CheckRunID string     `json:"checkRunId,omitempty"`
	CreatedAt  time.Time  `json:"createdAt"`
	StartedAt  *time.Time `json:"startedAt"`
	FinishedAt *time.Time `json:"finishedAt"`
}

type Certificate

type Certificate struct {
	Host          string
	Issuer        string // acme | self-signed
	CertPEM       string
	KeyEnc        []byte
	NotAfter      time.Time
	Status        string // valid | pending | failed | rate_limited
	LastError     string
	Failures      int
	NextAttemptAt time.Time
	UpdatedAt     time.Time
}

type CloudProvider

type CloudProvider struct {
	ID        string
	Name      string
	Type      string
	ConfigEnc []byte
	Summary   string
	CreatedAt time.Time
}

type Database

type Database struct {
	ID            string
	EnvironmentID string
	Project       string // names, joined in
	Environment   string
	Name          string // unique in the cluster
	Engine        string
	Version       string
	Spec          string
	State         string
	Network       string
	Secrets       []byte
	Status        string
	Deleting      bool
	VIPRW, VIPRO  int // 0 = not allocated
	CreatedAt     time.Time
	UpdatedAt     time.Time
}

Database is a managed database (Phase 12). Spec, State and Network are JSON owned by package dbs; Secrets are sealed. A standalone database has no environment (EnvironmentID, Project and Environment are "").

func (Database) ParseNetwork

func (d Database) ParseNetwork() DatabaseNetwork

ParseNetwork returns the database's network settings with defaults.

func (Database) Standalone

func (d Database) Standalone() bool

Standalone reports a database outside any project.

type DatabaseBackup

type DatabaseBackup struct {
	ID         string // the task ID
	DatabaseID string
	NodeID     string
	Member     string
	Trigger    string // schedule | manual
	State      string // running | ok | failed
	Error      string
	StartedAt  time.Time
	FinishedAt *time.Time
}

DatabaseBackup is one base backup run of a PostgreSQL cluster (Phase 13c).

type DatabaseEvent

type DatabaseEvent struct {
	ID         int64     `json:"id"`
	DatabaseID string    `json:"-"`
	At         time.Time `json:"at"`
	Kind       string    `json:"kind"`
	From       string    `json:"from"`
	To         string    `json:"to"`
	Reason     string    `json:"reason"`
	Actor      string    `json:"actor"`
}

DatabaseEvent is a scaling or failover event.

type DatabaseMember

type DatabaseMember struct {
	ID         string
	DatabaseID string
	Kind       string // data | sentinel
	Ordinal    int
	NodeID     string
	Desired    string // running | stopped
	State      string // pending | running | exited | failed | stopped | lost
	IP         string
	Error      string
	SpecHash   string
	CreatedAt  time.Time
	UpdatedAt  time.Time
}

DatabaseMember is one container of a database: a data member or a sentinel.

type DatabaseNetwork

type DatabaseNetwork struct {
	// Access lists the internal peers allowed in. Absent (nil) means the
	// default: a project database's own environment; nothing for a
	// standalone one.
	Access NullList[string] `json:"access"`
	Public DatabasePublic   `json:"public"`
}

DatabaseNetwork is who may reach a database: internal peers (security group peer syntax, fully qualified) and the public endpoint.

type DatabaseOrphan

type DatabaseOrphan struct {
	TaskID    string
	NodeID    string
	Volume    string
	CreatedAt time.Time
}

DatabaseOrphan is a removed database member whose container and volume still have to be removed from its node.

type DatabasePublic

type DatabasePublic struct {
	Enabled bool     `json:"enabled"`
	Allow   []string `json:"allow"` // client CIDRs
	// RequireTLS refuses plain connections on the dedicated ports.
	RequireTLS bool `json:"requireTls,omitempty"`
	// Port and ReadPort are the dedicated read-write and read-only ports,
	// assigned by the controller while the endpoint is on (Phase 18).
	Port     int `json:"port,omitempty"`
	ReadPort int `json:"readPort,omitempty"`
}

DatabasePublic is the endpoint Traefik serves from outside the cluster.

type DeployLock

type DeployLock struct {
	Reason string    `json:"reason"`
	By     string    `json:"by"`
	At     time.Time `json:"at"`
}

DeployLock is why an environment takes no deployments, and since when.

type Deployment

type Deployment struct {
	ID         string     `json:"id"`
	ServiceID  string     `json:"serviceId"`
	FromRev    int        `json:"fromRevision"`
	ToRev      int        `json:"toRevision"`
	Status     string     `json:"status"`
	Failed     int        `json:"failedTasks"`
	Message    string     `json:"message"`
	StartedAt  time.Time  `json:"startedAt"`
	FinishedAt *time.Time `json:"finishedAt"`
	Trigger    string     `json:"trigger"`
	Actor      string     `json:"actor"`
	BuildID    string     `json:"buildId,omitempty"`
	Image      string     `json:"image"`
	Changes    string     `json:"-"` // JSON, decoded by the workload package
}

type DeploymentEvent

type DeploymentEvent struct {
	ID      int64     `json:"id"`
	At      time.Time `json:"at"`
	Kind    string    `json:"kind"`
	Level   string    `json:"level"` // info | warn | error
	Node    string    `json:"node,omitempty"`
	TaskID  string    `json:"taskId,omitempty"`
	Message string    `json:"message"`
}

DeploymentEvent is one step of a deployment's timeline.

type DeploymentFilter

type DeploymentFilter struct {
	EnvironmentID string
	Service       string // name
	Status        string
}

DeploymentFilter narrows ListProjectDeployments.

type DeviceCode

type DeviceCode struct {
	DeviceHash string
	UserCode   string
	CreatedAt  time.Time
	ExpiresAt  time.Time
	ApprovedBy string
	Credential string
}

type Domain

type Domain struct {
	ID        string `json:"id"`
	ServiceID string `json:"serviceId"`
	Host      string `json:"host"`
	// Path is a path prefix ("" = the whole host); several services can
	// share a host by path.
	Path        string    `json:"path"`
	PortName    string    `json:"port"`
	StripPrefix bool      `json:"stripPrefix"`
	RedirectTo  string    `json:"redirectTo"` // answer with a 301 to this host instead
	CreatedAt   time.Time `json:"createdAt"`
}

type Environment

type Environment struct {
	ID        string            `json:"id"`
	ProjectID string            `json:"projectId"`
	Name      string            `json:"name"`
	SharedEnv map[string]string `json:"sharedEnv"`
	CreatedAt time.Time         `json:"createdAt"`
	// AutoDeploy lets builds deploy themselves (Phase 15d; the Git source's
	// own switch applies too).
	AutoDeploy bool `json:"autoDeploy"`
	// Lock, when set, blocks deployments other than rollbacks and cancels.
	Lock     *DeployLock `json:"lock"`
	Deleting bool        `json:"deleting"`
}

type EtcdMember

type EtcdMember struct {
	ID         string
	Ordinal    int
	NodeID     string
	State      string // pending | running | exited | failed | stopped
	IP         string
	Error      string
	SpecHash   string
	Cluster    string // the initial-cluster it was started with
	NewCluster bool   // started with initial-cluster-state new
	MemberID   string // etcd's member ID (hex), once known
	CreatedAt  time.Time
	UpdatedAt  time.Time
}

EtcdMember is one member of the platform etcd (Phase 13).

type Failure

type Failure struct {
	Kind      string // deployment | build | job
	ID        string
	ServiceID string
	JobName   string
	Message   string
	At        time.Time
}

FailedSince lists what failed after t: deployments, builds and job runs, for event alerts. Each item is (kind, id, service ID, message, when).

type FirewallPolicy

type FirewallPolicy struct {
	ID          string         `json:"id"`
	Name        string         `json:"name"`
	Description string         `json:"description"`
	Targets     []string       `json:"targets"`
	Rules       []FirewallRule `json:"rules"`
	CreatedAt   time.Time      `json:"createdAt"`
	UpdatedAt   time.Time      `json:"updatedAt"`
}

func (FirewallPolicy) AppliesTo

func (p FirewallPolicy) AppliesTo(nodeID string) bool

AppliesTo reports whether the policy targets nodeID.

type FirewallRule

type FirewallRule struct {
	Protocol    string   `json:"protocol"`
	Ports       string   `json:"ports"`
	Sources     []string `json:"sources"`
	Description string   `json:"description"`
}

type GCResult

type GCResult map[string]int64

GCResult counts deleted rows per table.

type GCRun

type GCRun struct {
	ID             string     `json:"id"`
	Trigger        string     `json:"trigger"`
	Status         string     `json:"status"`
	Expired        int        `json:"expired"`
	ReclaimedBytes int64      `json:"reclaimedBytes"`
	Message        string     `json:"message"`
	Details        string     `json:"-"`
	StartedAt      time.Time  `json:"startedAt"`
	FinishedAt     *time.Time `json:"finishedAt"`
}

type GitConnection

type GitConnection struct {
	ID         string
	Kind       string // github-app | github | gitlab | gitea
	Name       string
	APIURL     string
	WebURL     string
	Account    string // the user or organization it acts as
	AppID      int64  // GitHub App
	AppSlug    string // GitHub App
	SecretsEnc []byte
	CreatedAt  time.Time
}

GitConnection is a connected Git provider (§5.8).

type GitSource

type GitSource struct {
	ID            string
	ServiceID     string
	URL           string
	Branch        string
	Dockerfile    string
	Context       string
	TokenEnc      []byte
	AutoDeploy    bool
	PollSeconds   int
	WebhookSecret string
	LastSHA       string
	LastCheckedAt *time.Time
	LastError     string
	Failures      int
	CreatedAt     time.Time
	Tags          string            // tag pattern ("" = tags are not watched)
	Paths         []string          // path filters ("!" excludes); empty = any change
	Builder       string            // auto | dockerfile | nixpacks | static
	RefSHAs       map[string]string // last seen commit of each matching ref
	LastWebhookAt *time.Time
	// From a Git connection (§5.8): the connection, the repository's full
	// name, the webhook SynCloud created on it and why creating it failed.
	ConnectionID string
	Repo         string
	HookID       string
	HookError    string
	// BuildSettings is the builds package's JSON (command overrides and
	// after-build checks); BuildVarsEnc its encrypted build-time variables.
	BuildSettings string
	BuildVarsEnc  []byte
}

type IAMGroup

type IAMGroup struct {
	ID          string
	Name        string
	Description string
	Members     []string // user IDs
	CreatedAt   time.Time
}

type IAMPolicy

type IAMPolicy struct {
	ID          string
	Name        string
	Description string
	Document    string
	CreatedAt   time.Time
	UpdatedAt   time.Time
}

type IAMRole

type IAMRole struct {
	ID                string
	Name              string
	Description       string
	Trust             RoleTrust
	MaxSessionSeconds int
	CreatedAt         time.Time
}

type IAMUser

type IAMUser struct {
	User
	Kind        string
	Disabled    bool
	MFAEnabled  bool
	MFASecret   []byte // sealed
	LastLoginAt *time.Time
	Groups      []string // group IDs
}

IAMUser is a user with its IAM fields.

type ImageStats

type ImageStats struct {
	Repository   string     `json:"repository"`
	Digest       string     `json:"digest"`
	Pushes       int        `json:"pushes"`
	Pulls        int        `json:"pulls"`
	LastPushedAt *time.Time `json:"lastPushedAt"`
	LastPulledAt *time.Time `json:"lastPulledAt"`
}

ImageStats are the push and pull counters of one digest.

type ImageWatch added in v0.1.7

type ImageWatch struct {
	ServiceID   string
	AutoDeploy  bool
	PollSeconds int
	// WebhookHash is the sha256 (hex) of the deploy webhook's token; "" = none.
	WebhookHash  string
	CheckedAt    *time.Time
	LastDigest   string
	LastError    string
	LastDeployAt *time.Time
	UpdatedAt    time.Time
}

ImageWatch is a service's auto-deploy of new pushes of its image.

type Incident

type Incident struct {
	ID        string     `json:"id"`
	ServiceID string     `json:"serviceId"`
	State     string     `json:"state"`
	Cause     string     `json:"cause"`
	OpenedAt  time.Time  `json:"openedAt"`
	ClosedAt  *time.Time `json:"closedAt"`
}

type IndexPool

type IndexPool struct {
	Kind     string
	Min, Max int
	// Skip excludes indexes (e.g. ones that map to .0/.255 addresses).
	Skip func(int) bool
	// Prefer is tried first when free (e.g. 1 for the controller node).
	Prefer int
}

IndexPool describes the allocatable indexes of one kind.

type Job

type Job struct {
	ID              string
	EnvironmentID   string
	Project         string
	Environment     string
	Name            string
	Spec            string
	LastScheduledAt *time.Time
	CreatedAt       time.Time
	UpdatedAt       time.Time
}

type JobRun

type JobRun struct {
	ID            string
	JobID         string
	EnvironmentID string
	ServiceID     string
	Revision      int
	Trigger       string
	Attempt       int
	Spec          string
	Status        string
	NodeID        string
	ExitCode      *int
	Message       string
	DeploymentID  string
	CreatedAt     time.Time
	StartedAt     *time.Time
	FinishedAt    *time.Time
}

type JoinToken

type JoinToken struct {
	ID          string
	TokenHash   string
	Description string
	CreatedBy   string
	CreatedAt   time.Time
	ExpiresAt   time.Time
	SingleUse   bool
	Uses        int
	// PoolID puts nodes joining with the token in a pool; NodeName forces
	// their name (servers created by a pool).
	PoolID   string
	NodeName string
}

type LifecyclePolicy

type LifecyclePolicy struct {
	Repository string
	Rules      string // JSON
	UpdatedAt  time.Time
	UpdatedBy  string
}

type Middleware

type Middleware struct {
	ID         string
	ProjectID  string
	Project    string // name, joined in
	Name       string
	Type       string
	Config     string // JSON
	ServiceIDs []string
	CreatedAt  time.Time
	UpdatedAt  time.Time
}

type Node

type Node struct {
	ID         string
	Name       string
	Status     string
	Info       string // JSON
	CertSerial string
	CreatedAt  time.Time
	StatusAt   time.Time
	LastSeenAt *time.Time
	// Schedulable allows new tasks on the node.
	Schedulable bool
	// Draining moves the node's tasks elsewhere.
	Draining bool
	// PoolID is the node pool ("" for none: the default pool).
	PoolID string
	// ScaleInProtected keeps the cluster autoscaler from removing the node.
	ScaleInProtected bool
}

type NodeNetwork

type NodeNetwork struct {
	NodeID      string
	NodeName    string
	MeshIndex   int
	SubnetIndex int
	PublicKey   string
	Endpoint    string
	UpdatedAt   time.Time
}

NodeNetwork is a node's mesh allocation and WireGuard identity.

type NodePool

type NodePool struct {
	ID         string
	Name       string
	Role       string // worker | edge
	ProviderID string // "" for a manual pool
	Spec       string // JSON
	Min, Max   int
	CreatedAt  time.Time
	UpdatedAt  time.Time
}

type NullList added in v0.1.5

type NullList[T any] []T

NullList is a list whose nil means something else than empty (a default, "all"): it encodes as null, even through the API, whose encoder turns other nil lists into [] (api.writeJSON).

func (NullList[T]) MarshalJSON added in v0.1.5

func (l NullList[T]) MarshalJSON() ([]byte, error)

MarshalJSON writes null for nil and the list otherwise.

type PoolEvent

type PoolEvent struct {
	ID      int64     `json:"id"`
	PoolID  string    `json:"poolId"`
	At      time.Time `json:"at"`
	Kind    string    `json:"kind"`
	Message string    `json:"message"`
}

type PoolServer

type PoolServer struct {
	PoolID    string    `json:"poolId"`
	ServerID  string    `json:"serverId"`
	Name      string    `json:"name"`
	State     string    `json:"state"` // creating | joined | failed | deleting
	NodeID    string    `json:"nodeId,omitempty"`
	Message   string    `json:"message,omitempty"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

PoolServer is a server a pool created at its provider.

type PortRouting

type PortRouting struct {
	ServiceID  string
	PortName   string
	Generated  bool     // http: the generated address is served
	Label      string   // http: replaces the generated name ("" = none)
	PublicPort int      // tcp/udp: the public port (0 = not public)
	Allow      []string // tcp/udp: client CIDRs (none = anyone)
}

PortRouting is how one port of a service is reached (Phase 15c).

type Project

type Project struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	// Nodes are the node names the project's workloads may run on (empty = any).
	Nodes []string `json:"nodes"`
	// RollbackWindow is how many of each service's latest revisions keep
	// their images through registry cleanup (Phase 15a).
	RollbackWindow int       `json:"rollbackWindow"`
	CreatedAt      time.Time `json:"createdAt"`
	// Deleting: the project goes once its environments are gone (15d).
	Deleting bool `json:"deleting"`
}

type ProjectDeployment

type ProjectDeployment struct {
	Deployment
	Service     string `json:"service"`
	Environment string `json:"environment"`
}

ProjectDeployment is a deployment with its service's name and environment.

type Quota

type Quota struct {
	ProjectID     string
	EnvironmentID string // "" for the project-wide quota
	Limits        string // JSON
	UpdatedAt     time.Time
}

type RegistryEvent

type RegistryEvent struct {
	ID         int64     `json:"id"`
	EventID    string    `json:"-"`
	At         time.Time `json:"at"`
	Action     string    `json:"action"`
	Repository string    `json:"repository"`
	Tag        string    `json:"tag"`
	Digest     string    `json:"digest"`
	Actor      string    `json:"actor"`
	Addr       string    `json:"addr"`
	UserAgent  string    `json:"userAgent"`
}

RegistryEvent is one manifest push, pull or delete reported by the registry.

type Released

type Released struct {
	Kind       string    `json:"kind"` // mesh | subnet | vip
	Index      int       `json:"index"`
	ReleasedAt time.Time `json:"releasedAt"`
}

Released is an address-pool index in its cool-down.

type Retention

type Retention struct {
	Audit       time.Duration // audit log
	Incidents   time.Duration // closed incidents
	Deployments time.Duration // finished deployments
	Builds      time.Duration // finished builds (the deployed build of a service is kept)
	Usage       time.Duration // daily usage rows
	Revisions   int           // task definitions per service (current, previous and in-flight ones are kept)
}

Retention of history the controller keeps (§Phase 9 GC). Zero keeps forever.

type RoleTrust

type RoleTrust struct {
	Users      []string `json:"users"`  // user IDs
	Groups     []string `json:"groups"` // group IDs
	RequireMFA bool     `json:"requireMfa"`
}

RoleTrust says who may assume a role.

type RunAddress

type RunAddress struct {
	ID, ServiceID, EnvironmentID, IP string
}

RunAddress is an active job run with its container address.

type S3Binding

type S3Binding struct {
	ID         string    `json:"id"`
	ServiceID  string    `json:"serviceId"`
	EndpointID string    `json:"endpointId"`
	Endpoint   string    `json:"endpoint"` // name, joined in
	Bucket     string    `json:"bucket"`
	Prefix     string    `json:"prefix"`
	EnvPrefix  string    `json:"envPrefix"`
	CreatedAt  time.Time `json:"createdAt"`
	// Joined in for listings.
	Project     string `json:"project"`
	Environment string `json:"environment"`
	Service     string `json:"service"`
}

type S3Endpoint

type S3Endpoint struct {
	ID          string
	Name        string
	URL         string
	Region      string
	AccessKeyID string
	SecretEnc   []byte
	PathStyle   bool
	CreatedAt   time.Time
}

type ScalingEvent

type ScalingEvent struct {
	ID        int64     `json:"id"`
	ServiceID string    `json:"-"`
	At        time.Time `json:"at"`
	From      int       `json:"from"`
	To        int       `json:"to"`
	Metric    string    `json:"metric"`
	Value     *float64  `json:"value"` // nil when there was no data (min/max clamp)
	Target    float64   `json:"target"`
	Reason    string    `json:"reason"`
}

ScalingEvent is one autoscaler decision that changed the desired count.

type ScalingPolicy

type ScalingPolicy struct {
	ServiceID        string    `json:"-"`
	Enabled          bool      `json:"enabled"`
	Min              int       `json:"min"`
	Max              int       `json:"max"`
	Metric           string    `json:"metric"`
	Target           float64   `json:"target"`
	ScaleOutCooldown int       `json:"scaleOutCooldown"`
	ScaleInCooldown  int       `json:"scaleInCooldown"`
	ScaleInChecks    int       `json:"scaleInChecks"`
	UpdatedAt        time.Time `json:"updatedAt"`
	UpdatedBy        string    `json:"updatedBy"`
}

ScalingPolicy is a service's target tracking policy (§5.5).

type SecurityGroup

type SecurityGroup struct {
	ID          string
	ProjectID   string
	Project     string // name, joined in
	Name        string
	Description string
	Inbound     string // JSON
	Outbound    string // JSON
	Default     bool
	ServiceIDs  []string
	CreatedAt   time.Time
	UpdatedAt   time.Time
}

type Service

type Service struct {
	ID            string
	EnvironmentID string
	Project       string // names, joined in
	Environment   string
	Name          string
	Revision      int
	DesiredCount  int
	Deleting      bool
	Status        string
	// Held: the first deployment waits on its pre-deploy jobs, so no task
	// runs yet.
	Held      bool
	CreatedAt time.Time
	UpdatedAt time.Time
}

type Session

type Session struct {
	TokenHash  string
	UserID     string
	CreatedAt  time.Time
	ExpiresAt  time.Time
	LastSeenAt time.Time
	IP         string
	UserAgent  string
	MFA        bool // signed in with a TOTP code
}

type Store

type Store struct {
	// W is the single writer connection. Use it for every INSERT/UPDATE/DELETE.
	W *sql.DB
	// R is the read pool.
	R *sql.DB
}

func Open

func Open(ctx context.Context, path string) (*Store, error)

func (*Store) APITokenByHash

func (s *Store) APITokenByHash(ctx context.Context, hash string, now time.Time) (APIToken, error)

APITokenByHash returns ErrNotFound for unknown or expired tokens.

func (*Store) AccessKeyByID

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

func (*Store) ActiveDeployment

func (s *Store) ActiveDeployment(ctx context.Context, serviceID string) (Deployment, error)

ActiveDeployment returns the service's in-progress deployment.

func (*Store) ActiveRunAddresses

func (s *Store) ActiveRunAddresses(ctx context.Context) ([]RunAddress, error)

ActiveRunAddresses lists pending and running runs that have an address.

func (*Store) ActiveRuns

func (s *Store) ActiveRuns(ctx context.Context) ([]JobRun, error)

ActiveRuns returns pending and running runs.

func (*Store) ActiveTasks

func (s *Store) ActiveTasks(ctx context.Context) ([]Task, error)

func (*Store) AddAlertEvent

func (s *Store) AddAlertEvent(ctx context.Context, e AlertEvent) (int64, error)

AddAlertEvent records a notification; events older than 90 days go.

func (*Store) AddDatabaseBackup

func (s *Store) AddDatabaseBackup(ctx context.Context, b DatabaseBackup) error

AddDatabaseBackup records a run that has started, keeping the newest 200.

func (*Store) AddDatabaseEvent

func (s *Store) AddDatabaseEvent(ctx context.Context, e DatabaseEvent) error

func (*Store) AddDatabaseOrphan

func (s *Store) AddDatabaseOrphan(ctx context.Context, o DatabaseOrphan) error

AddDatabaseOrphan records a member volume to remove (idempotent).

func (*Store) AddDeploymentEvent

func (s *Store) AddDeploymentEvent(ctx context.Context, depID string, e DeploymentEvent) error

AddDeploymentEvent appends a step to a deployment's timeline. Past MaxDeploymentEvents steps only terminal ones are kept, after one note that the log was cut.

func (*Store) AddDomain

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

func (*Store) AddPoolEvent

func (s *Store) AddPoolEvent(ctx context.Context, e PoolEvent) error

AddPoolEvent records a decision; 500 are kept per pool.

func (*Store) AddRevision

func (s *Store) AddRevision(ctx context.Context, serviceID, spec, createdBy string, now time.Time) (rev int, changed bool, err error)

AddRevision stores spec as a new revision without making it current. It returns the current revision when spec equals it (nothing to deploy).

func (*Store) AddScalingEvent

func (s *Store) AddScalingEvent(ctx context.Context, e ScalingEvent) error

AddScalingEvent records a decision and keeps the newest 500 per service.

func (*Store) AddUsage

func (s *Store) AddUsage(ctx context.Context, u UsageRow) error

AddUsage adds to a day's totals.

func (*Store) AddressHistory

func (s *Store) AddressHistory(ctx context.Context, ip string, limit int) ([]AddressRecord, error)

AddressHistory lists assignments, newest first; ip filters when set.

func (*Store) AlertChannel

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

func (*Store) AllDatabaseMembers

func (s *Store) AllDatabaseMembers(ctx context.Context) ([]DatabaseMember, error)

AllDatabaseMembers is every member of every database.

func (*Store) AllocateNodeNetwork

func (s *Store) AllocateNodeNetwork(ctx context.Context, nodeID string, mesh, subnet IndexPool, cooldown time.Duration, now time.Time) (NodeNetwork, error)

AllocateNodeNetwork returns the node's allocation, creating one on first use with the lowest free index of each pool.

func (*Store) ApproveDeviceCode

func (s *Store) ApproveDeviceCode(ctx context.Context, hash, userID, credential string) error

ApproveDeviceCode records the approving user and the credential issued.

func (*Store) AssignAddress

func (s *Store) AssignAddress(ctx context.Context, ip, ownerID, owner, nodeID string, at time.Time) error

AssignAddress records that ownerID now holds ip, closing any open record of that address or owner.

func (*Store) Attach

func (s *Store) Attach(ctx context.Context, a Attachment, at time.Time) error

func (*Store) AutoDeployWatches added in v0.1.7

func (s *Store) AutoDeployWatches(ctx context.Context) ([]ImageWatch, error)

AutoDeployWatches lists the watches that watch their registry.

func (*Store) BuildByCheckRun

func (s *Store) BuildByCheckRun(ctx context.Context, runID string) (Build, error)

BuildByCheckRun finds the build whose after-build checks a run is.

func (*Store) BuildByID

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

func (*Store) BuildByRun

func (s *Store) BuildByRun(ctx context.Context, runID string) (Build, error)

func (*Store) BuildCount added in v0.2.7

func (s *Store) BuildCount(ctx context.Context, serviceID, sha string) (int, error)

BuildCount returns how many builds of a commit a service has.

func (*Store) BuildsByStatus

func (s *Store) BuildsByStatus(ctx context.Context, statuses ...string) ([]Build, error)

func (*Store) Close

func (s *Store) Close() error

func (*Store) CloseIncident

func (s *Store) CloseIncident(ctx context.Context, id string, at time.Time) error

func (*Store) ConfirmNodeCert

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

ConfirmNodeCert drops the previous serial once the node uses the current one.

func (*Store) CountUsers

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

func (*Store) CreateAPIToken

func (s *Store) CreateAPIToken(ctx context.Context, t APIToken) error

func (*Store) CreateAccessKey

func (s *Store) CreateAccessKey(ctx context.Context, k AccessKey) error

CreateAccessKey enforces the per-user limit inside the write transaction.

func (*Store) CreateBuild

func (s *Store) CreateBuild(ctx context.Context, b Build) error

CreateBuild records a build.

func (*Store) CreateDatabase

func (s *Store) CreateDatabase(ctx context.Context, d Database) error

CreateDatabase stores a new database. Its name must be free among all databases, and for a project database also among its environment's services (they share DNS names).

func (*Store) CreateDatabaseMember

func (s *Store) CreateDatabaseMember(ctx context.Context, m DatabaseMember) error

func (*Store) CreateDeviceCode

func (s *Store) CreateDeviceCode(ctx context.Context, d DeviceCode) error

func (*Store) CreateEnvironment

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

func (*Store) CreateEtcdMember

func (s *Store) CreateEtcdMember(ctx context.Context, m EtcdMember) error

func (*Store) CreateGCRun

func (s *Store) CreateGCRun(ctx context.Context, r GCRun) error

func (*Store) CreateGitConnection

func (s *Store) CreateGitConnection(ctx context.Context, c GitConnection) error

func (*Store) CreateJoinToken

func (s *Store) CreateJoinToken(ctx context.Context, t JoinToken) error

func (*Store) CreateProject

func (s *Store) CreateProject(ctx context.Context, p Project, env Environment) error

CreateProject creates a project with one environment, in one transaction.

func (*Store) CreateRootUser

func (s *Store) CreateRootUser(ctx context.Context, u User) error

CreateRootUser creates the first account and consumes the setup token in one transaction, so two concurrent setup requests cannot both succeed.

func (*Store) CreateRun

func (s *Store) CreateRun(ctx context.Context, x JobRun) error

func (*Store) CreateService

func (s *Store) CreateService(ctx context.Context, sv Service, spec string, createdBy string) error

CreateService creates a service with its first revision.

func (*Store) CreateSession

func (s *Store) CreateSession(ctx context.Context, ss Session) error

func (*Store) CreateTask

func (s *Store) CreateTask(ctx context.Context, t Task) error

func (*Store) CreateTempCredential

func (s *Store) CreateTempCredential(ctx context.Context, c TempCredential) error

func (*Store) CreateUser

func (s *Store) CreateUser(ctx context.Context, u IAMUser) error

CreateUser adds a user or service account. ErrNameTaken: the email is used.

func (*Store) DatabaseBackupByID

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

DatabaseBackupByID returns one run.

func (*Store) DatabaseBackups

func (s *Store) DatabaseBackups(ctx context.Context, databaseID string, limit int) ([]DatabaseBackup, error)

DatabaseBackups lists a cluster's runs, newest first.

func (*Store) DatabaseByID

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

func (*Store) DatabaseByName

func (s *Store) DatabaseByName(ctx context.Context, name string) (Database, error)

func (*Store) DatabaseEvents

func (s *Store) DatabaseEvents(ctx context.Context, databaseID string, limit int, before string) ([]DatabaseEvent, error)

DatabaseEvents returns the newest events, older than the event before names when set.

func (*Store) DatabaseEventsAfter added in v0.2.0

func (s *Store) DatabaseEventsAfter(ctx context.Context, kind string, afterID int64) ([]DatabaseEvent, error)

DatabaseEventsAfter returns events of a kind with IDs after afterID, oldest first (for alerts).

func (*Store) DatabaseMemberByID

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

func (*Store) DatabaseMembers

func (s *Store) DatabaseMembers(ctx context.Context, databaseID string) ([]DatabaseMember, error)

func (*Store) DatabaseNameTaken

func (s *Store) DatabaseNameTaken(ctx context.Context, environmentID, name string) (bool, error)

DatabaseNameTaken reports whether a database of the environment uses the name (services check it).

func (*Store) DatabaseOrphanByTask

func (s *Store) DatabaseOrphanByTask(ctx context.Context, taskID string) (DatabaseOrphan, error)

DatabaseOrphanByTask returns the orphan of a task.

func (*Store) DefaultSecurityGroup

func (s *Store) DefaultSecurityGroup(ctx context.Context, projectID string) (SecurityGroup, error)

DefaultSecurityGroup returns a project's default group.

func (*Store) DeleteAPIToken

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

func (*Store) DeleteAccessKey

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

DeleteAccessKey deletes a key owned by userID. It returns ErrNotFound otherwise.

func (*Store) DeleteAlertChannel

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

func (*Store) DeleteAlertRule

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

func (*Store) DeleteAlertState

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

func (*Store) DeleteCertificate

func (s *Store) DeleteCertificate(ctx context.Context, host string) error

func (*Store) DeleteCloudProvider

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

func (*Store) DeleteDatabase

func (s *Store) DeleteDatabase(ctx context.Context, id string, now time.Time) error

DeleteDatabase removes a database and its members, releasing its VIPs into the cooldown.

func (*Store) DeleteDatabaseMember

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

func (*Store) DeleteDatabaseOrphan

func (s *Store) DeleteDatabaseOrphan(ctx context.Context, taskID string) error

DeleteDatabaseOrphan forgets an orphan once its node removed it.

func (*Store) DeleteDeviceCode

func (s *Store) DeleteDeviceCode(ctx context.Context, hash string) error

DeleteDeviceCode is called once the CLI has picked up its credential.

func (*Store) DeleteDomain

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

DeleteDomain removes a service's domain by ID, or every route of a host when ref is a host name.

func (*Store) DeleteEnvironment

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

func (*Store) DeleteEtcdMember

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

func (*Store) DeleteExpiredJoinTokens

func (s *Store) DeleteExpiredJoinTokens(ctx context.Context, now time.Time) error

DeleteExpiredJoinTokens removes tokens that can no longer be used.

func (*Store) DeleteExpiredSessions

func (s *Store) DeleteExpiredSessions(ctx context.Context, now time.Time) (int64, error)

func (*Store) DeleteFirewallPolicy

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

func (*Store) DeleteGitConnection

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

DeleteGitConnection removes a connection no source uses.

func (*Store) DeleteGitSource

func (s *Store) DeleteGitSource(ctx context.Context, serviceID string) error

func (*Store) DeleteIAMGroup

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

func (*Store) DeleteIAMPolicy

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

func (*Store) DeleteIAMRole

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

func (*Store) DeleteJob

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

func (*Store) DeleteJoinToken

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

func (*Store) DeleteLifecyclePolicy

func (s *Store) DeleteLifecyclePolicy(ctx context.Context, repo string) error

func (*Store) DeleteMiddleware

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

func (*Store) DeleteNode

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

func (*Store) DeleteNodePool

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

func (*Store) DeletePoolServer

func (s *Store) DeletePoolServer(ctx context.Context, poolID, serverID string) error

func (*Store) DeleteProject

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

DeleteProject removes a project without services.

func (*Store) DeleteQuota

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

func (*Store) DeleteS3Endpoint

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

DeleteS3Endpoint deletes an endpoint no service is bound to.

func (*Store) DeleteScalingPolicy

func (s *Store) DeleteScalingPolicy(ctx context.Context, serviceID string) error

func (*Store) DeleteSecurityGroup

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

func (*Store) DeleteService

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

func (*Store) DeleteSession

func (s *Store) DeleteSession(ctx context.Context, hash string) error

func (*Store) DeleteSetting

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

func (*Store) DeleteTempCredential

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

func (*Store) DeleteUpstreamCredential

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

func (*Store) DeleteUser

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

func (*Store) DeploymentByID

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

func (*Store) DeploymentEvents

func (s *Store) DeploymentEvents(ctx context.Context, depID string) ([]DeploymentEvent, error)

DeploymentEvents returns a deployment's timeline, oldest first.

func (*Store) DeploymentOfRevision added in v0.2.4

func (s *Store) DeploymentOfRevision(ctx context.Context, serviceID string, rev int) (Deployment, error)

DeploymentOfRevision returns the newest deployment that rolled a service out to rev.

func (*Store) DeploymentRuns

func (s *Store) DeploymentRuns(ctx context.Context, depID string) ([]JobRun, error)

DeploymentRuns returns the hook runs of a deployment, oldest first.

func (*Store) Detach

func (s *Store) Detach(ctx context.Context, a Attachment) error

func (*Store) DeviceCodeByHash

func (s *Store) DeviceCodeByHash(ctx context.Context, hash string, now time.Time) (DeviceCode, error)

func (*Store) DeviceCodeByUserCode

func (s *Store) DeviceCodeByUserCode(ctx context.Context, code string, now time.Time) (DeviceCode, error)

func (*Store) DrainNode

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

DrainNode stops new placements on the node and marks it draining.

func (*Store) EndpointS3Bindings

func (s *Store) EndpointS3Bindings(ctx context.Context, endpointID string) ([]S3Binding, error)

func (*Store) EnsureDatabaseVIPs

func (s *Store) EnsureDatabaseVIPs(ctx context.Context, id string, pool IndexPool, cooldown time.Duration, now time.Time) (int, int, error)

EnsureDatabaseVIPs allocates the read-write and read-only VIPs from the same pool as service VIPs.

func (*Store) EnsureServiceVIP

func (s *Store) EnsureServiceVIP(ctx context.Context, serviceID string, pool IndexPool, cooldown time.Duration, now time.Time) (int, error)

EnsureServiceVIP returns the service's VIP index, allocating the lowest free one on first use.

func (*Store) EnvironmentByID

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

func (*Store) EnvironmentByName

func (s *Store) EnvironmentByName(ctx context.Context, projectID, name string) (Environment, error)

func (*Store) EnvironmentContents

func (s *Store) EnvironmentContents(ctx context.Context, id string) (services int, databases []string, err error)

EnvironmentContents counts what is left in an environment.

func (*Store) EtcdMemberByID

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

func (*Store) EtcdMembers

func (s *Store) EtcdMembers(ctx context.Context) ([]EtcdMember, error)

EtcdMembers lists the members by ordinal.

func (*Store) FailRunningGCRuns

func (s *Store) FailRunningGCRuns(ctx context.Context, now time.Time) error

FailRunningGCRuns marks runs interrupted by a controller restart.

func (*Store) FailedSince

func (s *Store) FailedSince(ctx context.Context, t time.Time) ([]Failure, error)

func (*Store) FinishDatabaseBackup

func (s *Store) FinishDatabaseBackup(ctx context.Context, id, state, errText string, at time.Time) (bool, error)

FinishDatabaseBackup ends a running run (no-op when it already ended).

func (*Store) FinishDeployment

func (s *Store) FinishDeployment(ctx context.Context, id, status, message string, now time.Time) error

func (*Store) FinishGCRun

func (s *Store) FinishGCRun(ctx context.Context, r GCRun) error

func (*Store) FirewallPolicy

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

func (*Store) GC

func (s *Store) GC(ctx context.Context, r Retention, now time.Time) (GCResult, error)

GC deletes history older than the retention.

func (*Store) GCRuns

func (s *Store) GCRuns(ctx context.Context, limit int) ([]GCRun, error)

GCRuns returns the latest runs, newest first.

func (*Store) GetSetting

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

GetSetting returns ("", false, nil) when the key is not set.

func (*Store) GitConnection

func (s *Store) GitConnection(ctx context.Context, idOrName string) (GitConnection, error)

func (*Store) GitSourceByID

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

func (*Store) GitSourceByService

func (s *Store) GitSourceByService(ctx context.Context, serviceID string) (GitSource, error)

func (*Store) GitSourcesByConnection

func (s *Store) GitSourcesByConnection(ctx context.Context, connectionID string) ([]GitSource, error)

GitSourcesByConnection returns every source of a connection.

func (*Store) GitSourcesByRepo

func (s *Store) GitSourcesByRepo(ctx context.Context, connectionID, repo string) ([]GitSource, error)

GitSourcesByRepo returns the sources building a connection's repository.

func (*Store) IAMUser

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

func (*Store) ImageStatsFor

func (s *Store) ImageStatsFor(ctx context.Context, repo string) ([]ImageStats, error)

ImageStatsFor returns the counters of every digest of repo ("" = all).

func (*Store) ImageWatch added in v0.1.7

func (s *Store) ImageWatch(ctx context.Context, serviceID string) (ImageWatch, error)

ImageWatch returns a service's image watch; ErrNotFound when it has none.

func (*Store) ImageWatchByWebhook added in v0.1.7

func (s *Store) ImageWatchByWebhook(ctx context.Context, hash string) (ImageWatch, error)

ImageWatchByWebhook finds the watch whose deploy webhook token hashes to hash.

func (*Store) IncDeploymentFailures

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

IncDeploymentFailures counts a failed task of the deployment's revision.

func (*Store) JobByID

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

func (*Store) JobByName

func (s *Store) JobByName(ctx context.Context, environmentID, name string) (Job, error)

func (*Store) JobRuns

func (s *Store) JobRuns(ctx context.Context, jobID string, limit int, before string) ([]JobRun, error)

JobRuns returns a job's newest runs, older than the run before names when set.

func (*Store) JoinNode

func (s *Store) JoinNode(ctx context.Context, tokenHash string, n Node, now time.Time) error

JoinNode consumes a join token and creates the node in one transaction. It returns ErrNotFound if the token is unknown, expired or used up, and ErrNameTaken if the node name exists.

func (*Store) LastDatabaseEventID added in v0.2.0

func (s *Store) LastDatabaseEventID(ctx context.Context) (int64, error)

LastDatabaseEventID is the newest event's ID (0 = none).

func (*Store) LastPoolEvent

func (s *Store) LastPoolEvent(ctx context.Context, poolID, kind string) (PoolEvent, error)

LastPoolEvent returns the newest event of a kind ("" any).

func (*Store) LifecyclePolicy

func (s *Store) LifecyclePolicy(ctx context.Context, repo string) (LifecyclePolicy, error)

func (*Store) ListAPITokens

func (s *Store) ListAPITokens(ctx context.Context, userID string) ([]APIToken, error)

func (*Store) ListAccessKeys

func (s *Store) ListAccessKeys(ctx context.Context, userID string) ([]AccessKey, error)

func (*Store) ListAlertChannels

func (s *Store) ListAlertChannels(ctx context.Context) ([]AlertChannel, error)

func (*Store) ListAlertEvents

func (s *Store) ListAlertEvents(ctx context.Context, limit int, before string) ([]AlertEvent, error)

ListAlertEvents returns the newest events, older than the event before names when set (cursor pagination).

func (*Store) ListAlertRules

func (s *Store) ListAlertRules(ctx context.Context) ([]AlertRule, error)

func (*Store) ListAlertStates

func (s *Store) ListAlertStates(ctx context.Context) ([]AlertState, error)

func (*Store) ListAttachments

func (s *Store) ListAttachments(ctx context.Context) ([]Attachment, error)

func (*Store) ListCertificates

func (s *Store) ListCertificates(ctx context.Context) ([]Certificate, error)

func (*Store) ListCloudProviders

func (s *Store) ListCloudProviders(ctx context.Context) ([]CloudProvider, error)

func (*Store) ListDatabases

func (s *Store) ListDatabases(ctx context.Context) ([]Database, error)

func (*Store) ListDeployments

func (s *Store) ListDeployments(ctx context.Context, serviceID string, limit int, before string) ([]Deployment, error)

ListDeployments returns a service's newest deployments, older than the deployment before names when set.

func (*Store) ListDomains

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

ListDomains returns custom domains of one service ("" = all).

func (*Store) ListEnvironments

func (s *Store) ListEnvironments(ctx context.Context, projectID string) ([]Environment, error)

func (*Store) ListFirewallPolicies

func (s *Store) ListFirewallPolicies(ctx context.Context) ([]FirewallPolicy, error)

func (*Store) ListGitConnections

func (s *Store) ListGitConnections(ctx context.Context) ([]GitConnection, error)

func (*Store) ListGitSources

func (s *Store) ListGitSources(ctx context.Context) ([]GitSource, error)

func (*Store) ListIAMGroups

func (s *Store) ListIAMGroups(ctx context.Context) ([]IAMGroup, error)

func (*Store) ListIAMPolicies

func (s *Store) ListIAMPolicies(ctx context.Context) ([]IAMPolicy, error)

func (*Store) ListIAMRoles

func (s *Store) ListIAMRoles(ctx context.Context) ([]IAMRole, error)

func (*Store) ListIAMUsers

func (s *Store) ListIAMUsers(ctx context.Context) ([]IAMUser, error)

func (*Store) ListIncidents

func (s *Store) ListIncidents(ctx context.Context, serviceID string, openOnly bool, limit int) ([]Incident, error)

ListIncidents returns incidents, newest first (open only when openOnly).

func (*Store) ListJobs

func (s *Store) ListJobs(ctx context.Context) ([]Job, error)

func (*Store) ListJobsIn

func (s *Store) ListJobsIn(ctx context.Context, environmentID string) ([]Job, error)

func (*Store) ListJoinTokens

func (s *Store) ListJoinTokens(ctx context.Context, now time.Time) ([]JoinToken, error)

func (*Store) ListLifecyclePolicies

func (s *Store) ListLifecyclePolicies(ctx context.Context) ([]LifecyclePolicy, error)

func (*Store) ListMiddlewares

func (s *Store) ListMiddlewares(ctx context.Context) ([]Middleware, error)

func (*Store) ListNodeNetworks

func (s *Store) ListNodeNetworks(ctx context.Context) ([]NodeNetwork, error)

func (*Store) ListNodePools

func (s *Store) ListNodePools(ctx context.Context) ([]NodePool, error)

func (*Store) ListNodes

func (s *Store) ListNodes(ctx context.Context) ([]Node, error)

func (*Store) ListPoolEvents

func (s *Store) ListPoolEvents(ctx context.Context, poolID string, limit int, before string) ([]PoolEvent, error)

ListPoolEvents returns the newest events, older than the event before names when set.

func (*Store) ListPoolServers

func (s *Store) ListPoolServers(ctx context.Context, poolID string) ([]PoolServer, error)

func (*Store) ListProjectDeployments

func (s *Store) ListProjectDeployments(ctx context.Context, projectID string, f DeploymentFilter, limit int, before string) ([]ProjectDeployment, error)

ListProjectDeployments returns the newest deployments of every service in a project, older than the deployment before names when set.

func (*Store) ListProjects

func (s *Store) ListProjects(ctx context.Context) ([]Project, error)

func (*Store) ListQuotas

func (s *Store) ListQuotas(ctx context.Context) ([]Quota, error)

func (*Store) ListRegistryEvents

func (s *Store) ListRegistryEvents(ctx context.Context, repo string, limit int, before string) ([]RegistryEvent, error)

ListRegistryEvents returns the newest events, of one repository when repo is set, older than the event before names when set.

func (*Store) ListReleased

func (s *Store) ListReleased(ctx context.Context) ([]Released, error)

func (*Store) ListRouting

func (s *Store) ListRouting(ctx context.Context, serviceID string) ([]PortRouting, error)

ListRouting returns the routing rows of one service ("" = all).

func (*Store) ListS3Endpoints

func (s *Store) ListS3Endpoints(ctx context.Context) ([]S3Endpoint, error)

func (*Store) ListScalingPolicies

func (s *Store) ListScalingPolicies(ctx context.Context) ([]ScalingPolicy, error)

func (*Store) ListSecurityGroups

func (s *Store) ListSecurityGroups(ctx context.Context) ([]SecurityGroup, error)

ListSecurityGroups returns every group, by project and name.

func (*Store) ListServices

func (s *Store) ListServices(ctx context.Context) ([]Service, error)

func (*Store) ListServicesIn

func (s *Store) ListServicesIn(ctx context.Context, environmentID string) ([]Service, error)

func (*Store) ListTaskDefinitions

func (s *Store) ListTaskDefinitions(ctx context.Context, serviceID string) ([]TaskDefinition, error)

func (*Store) ListUpstreamCredentials

func (s *Store) ListUpstreamCredentials(ctx context.Context) ([]UpstreamCredential, error)

func (*Store) ListUsage

func (s *Store) ListUsage(ctx context.Context, project, from, to string) ([]UsageRow, error)

ListUsage returns days in [from, to] (YYYY-MM-DD), optionally for one project.

func (*Store) MarkDatabaseDeleting

func (s *Store) MarkDatabaseDeleting(ctx context.Context, id string, now time.Time) error

func (*Store) MarkEnvironmentDeleting

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

MarkEnvironmentDeleting flags an environment to go once its services are gone; its jobs go at once (no new runs start).

func (*Store) MarkProjectDeleting

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

MarkProjectDeleting flags a project to go once its environments are gone.

func (*Store) MarkServiceDeleting

func (s *Store) MarkServiceDeleting(ctx context.Context, id string, now time.Time) error

MarkServiceDeleting scales the service to zero; the reconciler deletes it once its tasks are gone.

func (*Store) NodeByID

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

func (*Store) NodeByName

func (s *Store) NodeByName(ctx context.Context, name string) (Node, error)

func (*Store) NodeCertSerials

func (s *Store) NodeCertSerials(ctx context.Context, id string) (cur, prev string, err error)

NodeCertSerials returns the accepted serials (current, previous).

func (*Store) NodeDatabaseMembers

func (s *Store) NodeDatabaseMembers(ctx context.Context, nodeID string) ([]DatabaseMember, error)

func (*Store) NodeDatabaseOrphans

func (s *Store) NodeDatabaseOrphans(ctx context.Context, nodeID string) ([]DatabaseOrphan, error)

NodeDatabaseOrphans lists a node's orphans.

func (*Store) NodeNetwork

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

func (*Store) NodeTasks

func (s *Store) NodeTasks(ctx context.Context, nodeID string) ([]Task, error)

func (*Store) OpenIncident

func (s *Store) OpenIncident(ctx context.Context, i Incident) error

func (*Store) ProjectByID

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

func (*Store) ProjectByName

func (s *Store) ProjectByName(ctx context.Context, name string) (Project, error)

func (*Store) PruneRegistryEvents

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

PruneRegistryEvents deletes events older than before.

func (*Store) PruneRuns

func (s *Store) PruneRuns(ctx context.Context, jobID string, keep int) error

PruneRuns keeps the newest keep finished runs of a job.

func (*Store) PruneTasks

func (s *Store) PruneTasks(ctx context.Context, serviceID string, keep int) error

PruneTasks deletes stopped tasks beyond keep per service.

func (*Store) PutAlertChannel

func (s *Store) PutAlertChannel(ctx context.Context, c AlertChannel) error

func (*Store) PutAlertRule

func (s *Store) PutAlertRule(ctx context.Context, r AlertRule) error

func (*Store) PutAlertState

func (s *Store) PutAlertState(ctx context.Context, a AlertState) error

func (*Store) PutCertificate

func (s *Store) PutCertificate(ctx context.Context, c Certificate) error

func (*Store) PutCloudProvider

func (s *Store) PutCloudProvider(ctx context.Context, p CloudProvider) error

func (*Store) PutFirewallPolicy

func (s *Store) PutFirewallPolicy(ctx context.Context, p FirewallPolicy) error

PutFirewallPolicy creates or replaces a policy. It returns ErrNameTaken when another policy has the name.

func (*Store) PutGitSource

func (s *Store) PutGitSource(ctx context.Context, g GitSource) error

func (*Store) PutIAMGroup

func (s *Store) PutIAMGroup(ctx context.Context, g IAMGroup) error

PutIAMGroup creates or updates a group and replaces its members.

func (*Store) PutIAMPolicy

func (s *Store) PutIAMPolicy(ctx context.Context, p IAMPolicy) error

func (*Store) PutIAMRole

func (s *Store) PutIAMRole(ctx context.Context, r IAMRole) error

func (*Store) PutImageWatchSettings added in v0.1.7

func (s *Store) PutImageWatchSettings(ctx context.Context, serviceID string, autoDeploy bool, pollSeconds int, now time.Time) error

PutImageWatchSettings sets a service's auto-deploy and polling interval.

func (*Store) PutJob

func (s *Store) PutJob(ctx context.Context, j Job) error

PutJob creates or updates a job (by environment and name).

func (*Store) PutLifecyclePolicy

func (s *Store) PutLifecyclePolicy(ctx context.Context, p LifecyclePolicy) error

func (*Store) PutMiddleware

func (s *Store) PutMiddleware(ctx context.Context, m Middleware) error

PutMiddleware creates or updates a middleware and replaces its attachments.

func (*Store) PutNodePool

func (s *Store) PutNodePool(ctx context.Context, p NodePool) error

func (*Store) PutPoolServer

func (s *Store) PutPoolServer(ctx context.Context, x PoolServer) error

func (*Store) PutQuota

func (s *Store) PutQuota(ctx context.Context, q Quota) error

func (*Store) PutS3Endpoint

func (s *Store) PutS3Endpoint(ctx context.Context, e S3Endpoint) error

PutS3Endpoint creates or updates an endpoint (by ID).

func (*Store) PutScalingPolicy

func (s *Store) PutScalingPolicy(ctx context.Context, p ScalingPolicy) error

func (*Store) PutSecurityGroup

func (s *Store) PutSecurityGroup(ctx context.Context, g SecurityGroup) error

PutSecurityGroup creates or updates a group and replaces its attachments.

func (*Store) PutUpstreamCredential

func (s *Store) PutUpstreamCredential(ctx context.Context, c UpstreamCredential) error

PutUpstreamCredential creates or replaces the credential for c.Host.

func (*Store) QueryAudit

func (s *Store) QueryAudit(ctx context.Context, f AuditFilter, limit int) ([]AuditRecord, error)

func (*Store) RecentBuilds

func (s *Store) RecentBuilds(ctx context.Context, limit int, before string) ([]Build, error)

RecentBuilds returns the newest builds, older than the build before names when set.

func (*Store) RecordGitCheck

func (s *Store) RecordGitCheck(ctx context.Context, id, sha, errMsg string, now time.Time) error

RecordGitCheck stores a poll result. sha is set only on success.

func (*Store) RecordGitWebhook

func (s *Store) RecordGitWebhook(ctx context.Context, id string, now time.Time) error

RecordGitWebhook notes a webhook delivery (polling then slows down).

func (*Store) RecordImageCheck added in v0.1.7

func (s *Store) RecordImageCheck(ctx context.Context, serviceID, digest, errMsg string, deployed bool, now time.Time) error

RecordImageCheck stores the result of a check of the registry.

func (*Store) RecordRegistryEvents

func (s *Store) RecordRegistryEvents(ctx context.Context, evs []RegistryEvent) (int, error)

RecordRegistryEvents stores events, skipping ones already seen (the registry retries deliveries), and updates the per-digest counters. It returns how many were new.

func (*Store) RejoinTarget

func (s *Store) RejoinTarget(ctx context.Context, tokenHash string, now time.Time) (Node, bool, error)

RejoinTarget is the existing node a join token re-joins, if any: the token is bound to a node name that exists.

func (*Store) ReleaseAddress

func (s *Store) ReleaseAddress(ctx context.Context, ownerID string, at time.Time) error

ReleaseAddress closes ownerID's open record.

func (*Store) ReleaseService

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

ReleaseService lets a held service run its tasks.

func (*Store) RootUser added in v0.2.0

func (s *Store) RootUser(ctx context.Context) (User, error)

RootUser returns the root account (ErrNotFound before setup).

func (*Store) RotateNodeCert

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

RotateNodeCert records a renewed certificate; the current serial becomes the previous one and stays valid until the node connects with the new one.

func (*Store) RunByID

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

func (*Store) RunsIn

func (s *Store) RunsIn(ctx context.Context, environmentID string, limit int) ([]JobRun, error)

func (*Store) S3EndpointByRef

func (s *Store) S3EndpointByRef(ctx context.Context, ref string) (S3Endpoint, error)

S3EndpointByRef finds an endpoint by ID or name.

func (*Store) ScalingEvents

func (s *Store) ScalingEvents(ctx context.Context, serviceID string, limit int) ([]ScalingEvent, error)

func (*Store) ScalingPolicy

func (s *Store) ScalingPolicy(ctx context.Context, serviceID string) (ScalingPolicy, error)

func (*Store) SecurityGroupByName

func (s *Store) SecurityGroupByName(ctx context.Context, projectID, name string) (SecurityGroup, error)

func (*Store) ServiceBuilds

func (s *Store) ServiceBuilds(ctx context.Context, serviceID string, limit int, before string) ([]Build, error)

ServiceBuilds returns a service's newest builds, older than the build before names when set.

func (*Store) ServiceByID

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

func (*Store) ServiceByName

func (s *Store) ServiceByName(ctx context.Context, environmentID, name string) (Service, error)

func (*Store) ServiceS3Bindings

func (s *Store) ServiceS3Bindings(ctx context.Context, serviceID string) ([]S3Binding, error)

func (*Store) ServiceTasks

func (s *Store) ServiceTasks(ctx context.Context, serviceID string, history int) ([]Task, error)

ServiceTasks returns a service's tasks, newest first; history limits stopped ones.

func (*Store) SessionByHash

func (s *Store) SessionByHash(ctx context.Context, hash string, now time.Time) (Session, error)

SessionByHash returns ErrNotFound for unknown or expired sessions.

func (*Store) SetAlertDelivery

func (s *Store) SetAlertDelivery(ctx context.Context, id int64, delivery string) error

func (*Store) SetDatabaseNetwork

func (s *Store) SetDatabaseNetwork(ctx context.Context, id, network string, now time.Time) error

func (*Store) SetDatabaseSpec

func (s *Store) SetDatabaseSpec(ctx context.Context, id, spec string, now time.Time) error

func (*Store) SetDatabaseState

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

func (*Store) SetDatabaseStatus

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

func (*Store) SetDeploymentStatus

func (s *Store) SetDeploymentStatus(ctx context.Context, id, status, message string, finished *time.Time) error

SetDeploymentStatus moves a deployment to status (e.g. from waiting_hook).

func (*Store) SetEnvironmentPolicy

func (s *Store) SetEnvironmentPolicy(ctx context.Context, id string, autoDeploy bool, lock *DeployLock) error

SetEnvironmentPolicy sets an environment's auto-deploy switch and deploy lock (lock nil: unlocked).

func (*Store) SetGitBuildSettings

func (s *Store) SetGitBuildSettings(ctx context.Context, serviceID, settings string, varsEnc []byte) error

SetGitBuildSettings stores a source's build settings and encrypted build-time variables.

func (*Store) SetGitHook

func (s *Store) SetGitHook(ctx context.Context, id, hookID, hookErr string) error

SetGitHook records the webhook created on the repository (or why not).

func (*Store) SetGitRefs

func (s *Store) SetGitRefs(ctx context.Context, id string, refs map[string]string) error

SetGitRefs stores the last seen commit of every watched ref.

func (*Store) SetImageWebhook added in v0.1.7

func (s *Store) SetImageWebhook(ctx context.Context, serviceID, hash string, now time.Time) error

SetImageWebhook sets (or with "" removes) the deploy webhook's token hash.

func (*Store) SetJobScheduled

func (s *Store) SetJobScheduled(ctx context.Context, id string, at time.Time) error

func (*Store) SetMFA

func (s *Store) SetMFA(ctx context.Context, id string, secret []byte, enabled bool) error

SetMFA stores (or clears, with nil) a user's sealed TOTP secret.

func (*Store) SetNodePool

func (s *Store) SetNodePool(ctx context.Context, id, poolID string, protected bool) error

SetNodePool moves a node into a pool ("" for none).

func (*Store) SetNodeSchedulable

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

func (*Store) SetNodeStatus

func (s *Store) SetNodeStatus(ctx context.Context, id, status string, at, lastSeen time.Time) error

SetNodeStatus records a status transition.

func (*Store) SetNodeWireGuard

func (s *Store) SetNodeWireGuard(ctx context.Context, nodeID, publicKey, endpoint string, now time.Time) (bool, error)

SetNodeWireGuard records the node's public key and endpoint. It reports whether anything changed.

func (*Store) SetPassword

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

SetPassword changes any user's password (including root) and ends their sessions.

func (*Store) SetProjectNodes

func (s *Store) SetProjectNodes(ctx context.Context, id string, nodes []string) error

SetProjectNodes sets the nodes a project's workloads may run on (nil = any).

func (*Store) SetRouting

func (s *Store) SetRouting(ctx context.Context, serviceID string, rs []PortRouting) error

SetRouting replaces a service's routing rows in one transaction. ErrNameTaken means a label or public port belongs to another service.

func (*Store) SetRunIP

func (s *Store) SetRunIP(ctx context.Context, id, ip string) (changed bool, err error)

SetRunIP records a job run container's address; changed is false when it was known already.

func (*Store) SetServiceRevision

func (s *Store) SetServiceRevision(ctx context.Context, serviceID string, rev int, now time.Time) error

SetServiceRevision makes rev current.

func (*Store) SetServiceS3Bindings

func (s *Store) SetServiceS3Bindings(ctx context.Context, serviceID string, bs []S3Binding) error

SetServiceS3Bindings replaces a service's bindings.

func (*Store) SetServiceStatus

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

func (*Store) SetSetting

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

func (*Store) SetSharedEnv

func (s *Store) SetSharedEnv(ctx context.Context, envID string, vars map[string]string) error

SetSharedEnv replaces an environment's shared variables.

func (*Store) SetTaskDesired

func (s *Store) SetTaskDesired(ctx context.Context, id, desired, state string, now time.Time) error

SetTaskDesired marks a task to be stopped (or a stopped one's final state).

func (*Store) StartDeployment

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

StartDeployment supersedes any running deployment of the service and records a new one.

func (*Store) TaskByID

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

func (*Store) TaskDefinition

func (s *Store) TaskDefinition(ctx context.Context, serviceID string, revision int) (TaskDefinition, error)

func (*Store) TempCredentialByID

func (s *Store) TempCredentialByID(ctx context.Context, id string, now time.Time) (TempCredential, error)

TempCredentialByID returns ErrNotFound for unknown or expired credentials.

func (*Store) TouchAPIToken

func (s *Store) TouchAPIToken(ctx context.Context, id, ip string, at time.Time) error

func (*Store) TouchAccessKey

func (s *Store) TouchAccessKey(ctx context.Context, id, ip string, at time.Time) error

func (*Store) TouchLogin

func (s *Store) TouchLogin(ctx context.Context, id string, at time.Time) error

func (*Store) TouchSession

func (s *Store) TouchSession(ctx context.Context, hash string, seen, expires time.Time) error

TouchSession extends a session's expiry (sliding expiration).

func (*Store) TouchTempCredential

func (s *Store) TouchTempCredential(ctx context.Context, id string, at time.Time) error

func (*Store) UpdateBuild

func (s *Store) UpdateBuild(ctx context.Context, b Build) error

func (*Store) UpdateDatabaseMember

func (s *Store) UpdateDatabaseMember(ctx context.Context, m DatabaseMember, now time.Time) error

UpdateDatabaseMember saves a member's observed and desired state.

func (*Store) UpdateEtcdMember

func (s *Store) UpdateEtcdMember(ctx context.Context, m EtcdMember, now time.Time) error

UpdateEtcdMember saves a member's observed state and spec.

func (*Store) UpdateIncident

func (s *Store) UpdateIncident(ctx context.Context, id, state, cause string) error

func (*Store) UpdateNodeInfo

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

UpdateNodeInfo stores the NodeInfo from an agent's Hello.

func (*Store) UpdateProjectSettings

func (s *Store) UpdateProjectSettings(ctx context.Context, id, description string, rollbackWindow int) error

UpdateProjectSettings sets a project's description and rollback window.

func (*Store) UpdateRun

func (s *Store) UpdateRun(ctx context.Context, x JobRun) error

UpdateRun writes status fields.

func (*Store) UpdateService

func (s *Store) UpdateService(ctx context.Context, id, spec string, desired int, createdBy string, now time.Time) (int, error)

UpdateService records a new revision when spec differs from the current one, and sets the desired count. It returns the resulting revision.

func (*Store) UpdateTaskStatus

func (s *Store) UpdateTaskStatus(ctx context.Context, t Task) error

UpdateTaskStatus applies an agent report.

func (*Store) UpdateUser

func (s *Store) UpdateUser(ctx context.Context, id, name string, disabled bool, passwordHash string) error

UpdateUser changes a user's name, disabled flag and (when set) password.

func (*Store) UserByEmail

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

func (*Store) UserByID

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

func (*Store) WriteAudit

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

type Task

type Task struct {
	ID          string
	ServiceID   string
	Revision    int
	NodeID      string
	Desired     string // running | stopped
	State       string
	IP          string
	ContainerID string
	Health      string
	ExitCode    int
	Error       string
	CreatedAt   time.Time
	StartedAt   *time.Time
	FinishedAt  *time.Time
	UpdatedAt   time.Time
}

type TaskDefinition

type TaskDefinition struct {
	ServiceID string
	Revision  int
	Spec      string // JSON
	CreatedAt time.Time
	CreatedBy string
}

type TempCredential

type TempCredential struct {
	ID         string
	Kind       string
	UserID     string
	RoleID     string
	SecretEnc  []byte
	TokenHash  string
	MFA        bool
	SourceIP   string
	CreatedAt  time.Time
	ExpiresAt  time.Time
	LastUsedAt *time.Time
}

type UpstreamCredential

type UpstreamCredential struct {
	ID          string    `json:"id"`
	Host        string    `json:"host"`
	Username    string    `json:"username"`
	PasswordEnc []byte    `json:"-"`
	CreatedAt   time.Time `json:"createdAt"`
	UpdatedAt   time.Time `json:"updatedAt"`
}

type UsageRow

type UsageRow struct {
	Project          string  `json:"project"`
	Environment      string  `json:"environment"`
	Day              string  `json:"day"`
	CPUReservedHours float64 `json:"cpuReservedHours"`
	MemReservedHours float64 `json:"memReservedGiBHours"`
	CPUUsedHours     float64 `json:"cpuUsedHours"`
	MemUsedHours     float64 `json:"memUsedGiBHours"`
	NetOutBytes      int64   `json:"netOutBytes"`
	LogBytes         int64   `json:"logBytes"`
	BuildSeconds     int64   `json:"buildSeconds"`
}

UsageRow is one project-environment-day of metered usage.

type User

type User struct {
	ID           string
	Email        string
	Name         string
	PasswordHash string
	IsRoot       bool
	CreatedAt    time.Time
}

Jump to

Keyboard shortcuts

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