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
- func NewID() string
- type Store
- func (s *Store) AddEnvironment(ctx context.Context, applicationID string, e application.Environment, ...) error
- func (s *Store) AddPart(ctx context.Context, applicationID string, p application.Part) error
- func (s *Store) ClearSchema(ctx context.Context, applicationID string) error
- func (s *Store) Create(ctx context.Context, a *application.Application) error
- func (s *Store) Delete(ctx context.Context, id string) error
- func (s *Store) DeleteVariable(ctx context.Context, applicationID, environment, name string) error
- func (s *Store) EnvironmentNames(ctx context.Context, scriptID string) ([]string, error)
- func (s *Store) ForScript(ctx context.Context, scriptID, env string) (*appenv.Script, error)
- func (s *Store) Get(ctx context.Context, id string) (*application.Application, error)
- func (s *Store) GetByName(ctx context.Context, name string) (*application.Application, error)
- func (s *Store) Holding(ctx context.Context, connection, schema string) (*application.Application, error)
- func (s *Store) List(ctx context.Context) ([]application.Application, error)
- func (s *Store) Owning(ctx context.Context, kind, id string) (*application.Application, error)
- func (s *Store) Record(ctx context.Context, applicationID string, r application.Recorded) (*application.Release, error)
- func (s *Store) Release(ctx context.Context, applicationID string, number int) (*application.Release, error)
- func (s *Store) Releases(ctx context.Context, applicationID string) ([]application.Release, error)
- func (s *Store) RemoveEnvironment(ctx context.Context, applicationID, name string) error
- func (s *Store) RemovePart(ctx context.Context, applicationID, kind, id string) error
- func (s *Store) RunRoleOf(ctx context.Context, applicationID string) (*application.RunRole, error)
- func (s *Store) SetEnvironmentApproval(ctx context.Context, applicationID, name string, requires bool, by string) error
- func (s *Store) SetEnvironmentRelease(ctx context.Context, applicationID string, m application.Move) error
- func (s *Store) SetPartMode(ctx context.Context, applicationID, id, mode string) error
- func (s *Store) SetRunRole(ctx context.Context, applicationID string, h application.HeldSchema) error
- func (s *Store) SetSchema(ctx context.Context, applicationID string, h application.HeldSchema) error
- func (s *Store) SetVariable(ctx context.Context, applicationID string, v application.Variable) error
- func (s *Store) Update(ctx context.Context, a *application.Application) error
- func (s *Store) Variables(ctx context.Context, applicationID string) ([]application.Variable, error)
Constants ¶
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 ¶
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the PostgreSQL application store.
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) ClearSchema ¶ added in v1.154.2
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 ¶
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
DeleteVariable removes one variable; removing one that is not set is not an error.
func (*Store) EnvironmentNames ¶ added in v1.164.0
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
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) RemoveEnvironment ¶ added in v1.164.0
RemoveEnvironment removes an environment and its variables, closing the gap it leaves.
func (*Store) RemovePart ¶
RemovePart removes a part and clears the released version it was held at.
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
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.