appsvc

package
v1.154.0 Latest Latest
Warning

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

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

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Assets

type Assets interface {
	Get(ctx context.Context, id string) (*portaldomain.Asset, error)
}

Assets reads portal assets.

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

Create makes an application owned by the actor.

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, actor application.Actor, ref string) error

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) StatusOf

func (s *Service) StatusOf(ctx context.Context, ref string) (*Status, error)

StatusOf reads where an application stands.

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 Sources

type Sources interface {
	Exists(ctx context.Context, name string) (bool, error)
}

Sources reports whether a webhook source exists.

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.

Jump to

Keyboard shortcuts

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