appstore

package
v1.164.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package appstore is the PostgreSQL store of applications, their parts and their releases (#2411): the tables of migration 000228, and the released_version columns it adds to scripts and portal_assets, which only this store writes.

Index

Constants

View Source
const DefaultEnvironment = "prod"

DefaultEnvironment is the one environment an application created with none named has: its releases go live as they did before environments (#2696).

Variables

This section is empty.

Functions

func NewID

func NewID() string

NewID is a new application id.

Types

type Store

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

Store is the PostgreSQL application store.

func New

func New(db *sql.DB) *Store

New returns a store over db.

func (*Store) AddEnvironment added in v1.164.0

func (s *Store) AddEnvironment(ctx context.Context, applicationID string, e application.Environment, after string) error

AddEnvironment inserts e after the environment named after, "" for first.

func (*Store) AddPart

func (s *Store) AddPart(ctx context.Context, applicationID string, p application.Part) error

AddPart adds a part. A part another application holds is ErrPartTaken.

func (*Store) ClearSchema added in v1.154.2

func (s *Store) ClearSchema(ctx context.Context, applicationID string) error

ClearSchema takes the schema and its run role off the application.

func (*Store) Create

func (s *Store) Create(ctx context.Context, a *application.Application) error

Create inserts the application, giving it an id when it has none.

func (*Store) Delete

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

Delete removes the application, its parts and releases, and clears the released version its parts were held at.

func (*Store) DeleteVariable added in v1.164.0

func (s *Store) DeleteVariable(ctx context.Context, applicationID, environment, name string) error

DeleteVariable removes one variable; removing one that is not set is not an error.

func (*Store) EnvironmentNames added in v1.164.0

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

EnvironmentNames is the environments of the application holding scriptID, in promotion order; empty for a script no application holds.

func (*Store) ForScript added in v1.164.0

func (s *Store) ForScript(ctx context.Context, scriptID, env string) (*appenv.Script, error)

ForScript resolves env ("" for the last) for the application holding scriptID, in one statement: the environment, the version its release pins and its variables over the defaults. A script no application holds answers OK false; an environment the application lacks answers ErrNoEnvironment.

func (*Store) Get

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

Get reads an application by id, with its parts.

func (*Store) GetByName

func (s *Store) GetByName(ctx context.Context, name string) (*application.Application, error)

GetByName reads an application by name, with its parts.

func (*Store) Holding added in v1.154.2

func (s *Store) Holding(ctx context.Context, connection, schema string) (*application.Application, error)

Holding is the application holding schema on connection.

func (*Store) List

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

List reads every application by name, with its parts.

func (*Store) Owning

func (s *Store) Owning(ctx context.Context, kind, id string) (*application.Application, error)

Owning is the application a part belongs to.

func (*Store) Record

func (s *Store) Record(ctx context.Context, applicationID string, r application.Recorded) (*application.Release, error)

Record writes a release and its pins and makes r.Environment (the last when empty) run it, in one transaction; in the last environment the release becomes current and each pinned part is held at its version (#2696). The application row is locked and the environment's release compared with r.After first, so of two releases decided against one release the second fails with ErrStale and changes nothing.

func (*Store) Release

func (s *Store) Release(ctx context.Context, applicationID string, number int) (*application.Release, error)

Release reads one release with its pins.

func (*Store) Releases

func (s *Store) Releases(ctx context.Context, applicationID string) ([]application.Release, error)

Releases reads the application's releases, newest first, with their pins.

func (*Store) RemoveEnvironment added in v1.164.0

func (s *Store) RemoveEnvironment(ctx context.Context, applicationID, name string) error

RemoveEnvironment removes an environment and its variables, closing the gap it leaves.

func (*Store) RemovePart

func (s *Store) RemovePart(ctx context.Context, applicationID, kind, id string) error

RemovePart removes a part and clears the released version it was held at.

func (*Store) RunRoleOf added in v1.154.2

func (s *Store) RunRoleOf(ctx context.Context, applicationID string) (*application.RunRole, error)

RunRoleOf is the application's run role.

func (*Store) SetEnvironmentApproval added in v1.164.0

func (s *Store) SetEnvironmentApproval(ctx context.Context, applicationID, name string, requires bool, by string) error

SetEnvironmentApproval changes whether an agent's move into it waits.

func (*Store) SetEnvironmentRelease added in v1.164.0

func (s *Store) SetEnvironmentRelease(ctx context.Context, applicationID string, m application.Move) error

SetEnvironmentRelease makes m's environment run m.Number, failing with ErrStale when it no longer runs m.Expect.

func (*Store) SetPartMode added in v1.163.0

func (s *Store) SetPartMode(ctx context.Context, applicationID, id, mode string) error

SetPartMode changes a site environment part's release mode (#2679).

func (*Store) SetRunRole added in v1.154.2

func (s *Store) SetRunRole(ctx context.Context, applicationID string, h application.HeldSchema) error

SetRunRole stores the run role of the schema the application holds.

func (*Store) SetSchema added in v1.154.2

func (s *Store) SetSchema(ctx context.Context, applicationID string, h application.HeldSchema) error

SetSchema makes the application hold a schema and stores its run role, in one transaction. An application already holding one is refused with ErrSchemaHeld, as is a schema another application holds.

func (*Store) SetVariable added in v1.164.0

func (s *Store) SetVariable(ctx context.Context, applicationID string, v application.Variable) error

SetVariable writes one variable.

func (*Store) Update

func (s *Store) Update(ctx context.Context, a *application.Application) error

Update writes the description and owner.

func (*Store) Variables added in v1.164.0

func (s *Store) Variables(ctx context.Context, applicationID string) ([]application.Variable, error)

Variables is the application's variables, defaults first.

Jump to

Keyboard shortcuts

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