Documentation
¶
Overview ¶
Package apprename renames an application (#2875). A rename keeps the application's id, parts, releases, environments, variables, schema and data, and makes and promotes no release. What the name is used for moves with it: the application's own address on the pages domain (the old one stops answering at once), the endpoint its front page serves, the site releases whose _application file names it, and the redirect address its own sign-in gives a provider. Preview says each of those before the rename, in the sentences the portal's dialog, the tool's result and the question an agent's rename puts to the person all show.
The owner and administrators rename. An agent's rename of an application with an environment that requires approval waits on a person (internal/persondecide): the address it moves is one people use.
Index ¶
- Constants
- type Applications
- type Approvals
- type Move
- type PostgresStore
- type Preview
- type Renamer
- func (r *Renamer) Preview(ctx context.Context, actor application.Actor, ref, to string) (*Preview, error)
- func (r *Renamer) Rename(ctx context.Context, actor application.Actor, ref, to, decided string) (*Result, error)
- func (r *Renamer) RequestRename(ctx context.Context, actor application.Actor, m Move, reason string) (*approval.Request, error)
- type Result
- type Store
- type WaitingError
Constants ¶
const KeyPrefix = "app_rename:"
KeyPrefix is what every application rename's key starts with.
const PathCallback = "/_auth/app/callback"
PathCallback is where an application's own sign-in returns to on its page origin (appidentity.PathCallback); it is written here so this package needs nothing of the sign-in's.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Applications ¶
type Applications interface {
Find(ctx context.Context, ref string) (*application.Application, error)
}
Applications finds an application by name or id.
type Approvals ¶
type Approvals interface {
RenameApproved(ctx context.Context, purpose, subjectID, stamp string) bool
SubmitRename(ctx context.Context, actor approval.Actor, in approval.SubmitRename) (*approval.Request, error)
}
Approvals is the queue an agent's rename waits on.
type Move ¶
type Move struct {
AppID, From, To string
// Stamp is approval.RenameStamp of the rename.
Stamp string
Changes []string
}
Move is an agent's rename as the person is asked about it.
type PostgresStore ¶
type PostgresStore struct {
// contains filtered or unexported fields
}
PostgresStore renames applications in the platform's database.
type Preview ¶
type Preview struct {
Application string `json:"application" example:"orders-portal-dev"`
To string `json:"to" example:"orders-portal"`
// Problem is why the rename is refused, "" when it is not.
Problem string `json:"problem,omitempty"`
// AddressNow and AddressAfter are the application's own address before
// and after, "" with no pages domain.
AddressNow string `json:"address_now,omitempty" example:"https://orders-portal-dev.pages.example.net"`
AddressAfter string `json:"address_after,omitempty" example:"https://orders-portal.pages.example.net"`
// Changes are what the rename changes for the people and systems that
// use the application, one sentence each.
Changes []string `json:"changes"`
// Unchanged are what it leaves as it is that a reader may expect it to
// change.
Unchanged []string `json:"unchanged"`
// WaitsOnPerson is true when the caller is an agent and the rename waits
// on a person's decision.
WaitsOnPerson bool `json:"waits_on_person"`
}
Preview is what a rename changes, said before it is made.
type Renamer ¶
type Renamer struct {
Apps Applications
Store Store
// Approvals is the queue an agent's rename waits on; nil refuses an
// agent's rename that would wait.
Approvals Approvals
// PageOrigin is the address an application's pages answer at, "" with
// no pages domain; nil is no pages domain.
PageOrigin func(name string) string
// EndpointScript is the script an endpoint of that name runs, false for
// no endpoint; nil reads none.
EndpointScript func(ctx context.Context, name string) (string, bool)
// Contracts reads what the application's site parts serve; nil reads
// none.
Contracts appsvc.ContractSites
// SignsIn reports whether an application environment signs people in
// through its own provider (#2878); nil is none.
SignsIn func(ctx context.Context, appID, env string) bool
// Audit records each rename; nil records none.
Audit middleware.AuditLogger
// PersonaOf is the persona roles resolve to, which an approval request
// names; nil is none.
PersonaOf func(roles []string) string
// Now is the clock; nil is time.Now.
Now func() time.Time
}
Renamer renames applications.
func (*Renamer) Preview ¶
func (r *Renamer) Preview(ctx context.Context, actor application.Actor, ref, to string) (*Preview, error)
Preview says what renaming ref to to changes for actor, refusing an actor who does not edit the application. A rename that would be refused is answered with its Problem, not an error.
func (*Renamer) Rename ¶
func (r *Renamer) Rename(ctx context.Context, actor application.Actor, ref, to, decided string) (*Result, error)
Rename renames ref to to for actor. decided is the key of the rename the person accepted in their client, "" for none. An agent's rename that waits on a person answers a *WaitingError until the person accepts it or a request for it is approved.
func (*Renamer) RequestRename ¶
func (r *Renamer) RequestRename(ctx context.Context, actor application.Actor, m Move, reason string) (*approval.Request, error)
RequestRename files the request a person decides an agent's rename by, in the portal's Approvals, when the agent's client cannot ask them, with the agent's reason.
type Result ¶
type Result struct {
Application *application.Application `json:"application"`
RenamedFrom string `json:"renamed_from" example:"orders-portal-dev"`
Changes []string `json:"changes"`
}
Result is a rename carried out.
type Store ¶
type Store interface {
// Rename gives the application named from the name to, refusing a name
// an application or a site holds (application.ErrNameTaken) and an
// application renamed meanwhile (application.ErrStale).
Rename(ctx context.Context, id, from, to string) error
// Holder is "application" or "site" for a name one of them holds, ""
// for a free name.
Holder(ctx context.Context, name string) (string, error)
}
Store renames an application and says what holds a name.
type WaitingError ¶
type WaitingError struct{ Move Move }
WaitingError is an agent's rename that waits on the person.
func (*WaitingError) Error ¶
func (e *WaitingError) Error() string
func (*WaitingError) Waiting ¶
func (e *WaitingError) Waiting() persondecide.Move
Waiting is the move, which is how internal/persondecide asks the person.