Documentation
¶
Overview ¶
Package appsvc is what a person does to an application (#2411), the one implementation the manage_application tool and the portal routes share: create it, edit its record and parts, release it, roll it back, and read where it stands. It holds the rules: everyone signed in reads an application; its owner and administrators edit it; a part is added by someone who owns that part (a webhook source, which only administrators manage, by an administrator); and only administrators release and roll back, because a release changes the code behind a public endpoint and runs migrations on the target database.
Index ¶
- type Assets
- type RefusedError
- type Schema
- type Scripts
- type Service
- func (s *Service) AddPart(ctx context.Context, actor application.Actor, ref, kind, id string) (*application.Application, error)
- func (s *Service) Create(ctx context.Context, actor application.Actor, a application.Application) (*application.Application, error)
- func (s *Service) Delete(ctx context.Context, actor application.Actor, ref string) error
- func (s *Service) Find(ctx context.Context, ref string) (*application.Application, error)
- func (s *Service) Release(ctx context.Context, actor application.Actor, ref, note string) (*application.Release, error)
- func (s *Service) ReleaseAs(ctx context.Context, actor application.Actor, ref, note, action string) (*application.Release, error)
- func (s *Service) RemovePart(ctx context.Context, actor application.Actor, ref, kind, id string) (*application.Application, error)
- func (s *Service) Rollback(ctx context.Context, actor application.Actor, ref string, to int) (*application.Release, error)
- func (s *Service) StatusOf(ctx context.Context, ref string) (*Status, error)
- func (s *Service) Update(ctx context.Context, actor application.Actor, ref, description, owner string) (*application.Application, error)
- type Sources
- type Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RefusedError ¶
type RefusedError struct{ Msg string }
RefusedError is an operation refused for a reason the caller can act on.
func (*RefusedError) Error ¶
func (e *RefusedError) Error() string
type Schema ¶
type Schema interface {
State(ctx context.Context, connection, schema string) (*appschema.State, error)
Release(ctx context.Context, connection, schema, actor string) (*appschema.Applied, error)
Rollback(ctx context.Context, connection, schema, actor string, to int) (*appschema.Reverted, error)
}
Schema is what a release does to the application's schema.
type Scripts ¶
type Scripts interface {
GetByID(ctx context.Context, id string) (*script.Script, error)
GetVersion(ctx context.Context, scriptID string, version int) (*script.Version, error)
}
Scripts reads scripts and their versions.
type Service ¶
type Service struct {
Store application.Store
Scripts Scripts
Assets Assets
AssetVersions portaldomain.VersionReader
Sources Sources
Schema Schema
// HasConnection reports whether an application database connection
// (kind appdb) is named so; nil checks nothing.
HasConnection func(name string) bool
}
Service is the application operations.
func (*Service) AddPart ¶
func (s *Service) AddPart(ctx context.Context, actor application.Actor, ref, kind, id string) (*application.Application, error)
AddPart adds a part the actor owns.
func (*Service) Create ¶
func (s *Service) Create(ctx context.Context, actor application.Actor, a application.Application) (*application.Application, error)
Create makes an application owned by the actor.
func (*Service) Delete ¶
Delete removes an application; its parts stay and run their newest versions again.
func (*Service) Find ¶
func (s *Service) Find(ctx context.Context, ref string) (*application.Application, error)
Find reads an application by id or name.
func (*Service) Release ¶
func (s *Service) Release(ctx context.Context, actor application.Actor, ref, note string) (*application.Release, error)
Release applies the application's pending migrations and pins every script and asset part at its newest version. A part that cannot be pinned, or a migration that fails, refuses the release and changes nothing.
func (*Service) ReleaseAs ¶
func (s *Service) ReleaseAs(ctx context.Context, actor application.Actor, ref, note, action string) (*application.Release, error)
ReleaseAs is Release recorded as action: an import's release is recorded as one.
func (*Service) RemovePart ¶
func (s *Service) RemovePart(ctx context.Context, actor application.Actor, ref, kind, id string) (*application.Application, error)
RemovePart removes a part; it runs or serves its newest version again.
func (*Service) Rollback ¶
func (s *Service) Rollback(ctx context.Context, actor application.Actor, ref string, to int) (*application.Release, error)
Rollback restores the pins of an earlier release — to, or the release before the current one when to is 0 — and reverts the migrations applied since when each has a down migration; the rollback records which it reverted, or why it reverted none.
func (*Service) Update ¶
func (s *Service) Update(ctx context.Context, actor application.Actor, ref, description, owner string) (*application.Application, error)
Update writes the description and, for an administrator, the owner.
type Status ¶
type Status struct {
Application *application.Application `json:"application"`
Current *application.Release `json:"current_release"`
// Pending is the parts whose newest version differs from the current
// release's pin.
Pending []application.PinChange `json:"pending"`
// Migrations is where the schema's migrations stand; nil for an
// application with no schema.
Migrations *appschema.State `json:"migrations,omitempty"`
// Problems are parts a release would refuse: deleted, or unreadable.
Problems []string `json:"problems"`
}
Status is where an application stands: its record, its current release, and what a release now would change.