siteenv

package
v1.162.2 Latest Latest
Warning

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

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

Documentation

Overview

Package siteenv carries out the operations on a site's environments that came after the core service (#2648): what an environment answers (online, offline, redirect, #2631, #2632), renaming and removing one (#2630), the check of a new site's name (#2636), reading one file for the portal's viewer (#2629), and the rule that an agent's move of an environment people use waits on a person (#2643). It works through internal/site/sitesvc's exported surface, so the core service stays the size it was.

Index

Constants

View Source
const (
	MovePromote  = "promote"
	MoveRollback = "rollback"
	MovePublic   = "public_domain"
)

The kinds of move an agent's request names.

View Source
const (
	StatusDone             = sitesvc.StatusDone
	StatusAwaitingApproval = sitesvc.StatusAwaitingApproval
)

StatusDone and StatusAwaitingApproval are the statuses a change answers.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentMove

type AgentMove struct {
	Kind      string `json:"kind"`
	SiteID    string `json:"-"`
	Site      string `json:"site"`
	Target    string `json:"environment"`
	Release   int    `json:"release,omitempty"`
	ReleaseID string `json:"-"`
	Digest    string `json:"-"`
	Hostname  string `json:"hostname,omitempty"`
	// Stamp is a public domain's access stamp, which its approval names.
	Stamp string `json:"-"`
	// Current is the release the environment serves now.
	Current int `json:"current_release,omitempty"`
	// DevAddress is where the person looks at the release first.
	DevAddress string `json:"dev_address,omitempty"`
	// Changed is what the move changes for the environment's visitors.
	Changed *sitesvc.Comparison `json:"changed,omitempty"`
	Reason  string              `json:"-"`
}

AgentMove is one move an agent asked for, as the person is asked about it.

func (AgentMove) Key

func (m AgentMove) Key() string

Key names the move exactly: an answer or approval for one release, target or hostname never carries out another. A retry whose state moved since the question is asked again.

func (AgentMove) Question

func (m AgentMove) Question() string

Question is what the person is asked.

type DomainResult

type DomainResult struct {
	*sitesvc.DomainResult
	DecidedBy string `json:"decided_by,omitempty"`
}

DomainResult is a domain change with whose decision made an agent's domain public (#2643).

type FileBytes

type FileBytes struct {
	Release     int
	Path        string
	ContentType string
	Key         string
	Size        int64
	// Text is a rendered file's body, in place of an object.
	Text []byte
}

FileBytes is where one site file's bytes are, for the content route the portal's viewer reads (#2629): the object to read by range, or, for the _redirects and _headers files, the text they are rendered as.

type NameCheck

type NameCheck struct {
	Input string `json:"input" example:"My Website"`
	Name  string `json:"name" example:"my-website"`
	// Addresses is where dev and prod would answer on the pages domain, ""
	// with no pages domain.
	Addresses map[string]string `json:"addresses"`
	// EnvironmentNameRoom is the longest environment name the site can add.
	EnvironmentNameRoom int `json:"environment_name_room" example:"32"`
	// Refusal is why the name cannot be created, absent when it can.
	Refusal string `json:"refusal,omitempty"`
}

NameCheck is what the text a person typed for a new site's name becomes (#2636): the name, the addresses its two environments get, how long an environment name it leaves room for, and the reason it is refused, if it is. The rule lives on the server alone; the portal's New site dialog asks it.

type Ops

type Ops struct{ *sitesvc.Service }

Ops is the operations over one service.

func New

func New(svc *sitesvc.Service) Ops

New is the operations over svc.

func (Ops) AddDomain

func (o Ops) AddDomain(ctx context.Context, actor sitesvc.Actor, req sitesvc.DomainRequest) (*DomainResult, error)

AddDomain is the service's, a public domain an agent adds waiting on a person: it is added private, and making it public is the move the person decides. The agent asking again once the person accepted finds the domain it added and goes on to make it public.

func (Ops) CheckName

func (o Ops) CheckName(ctx context.Context, input string) (NameCheck, error)

CheckName answers what input becomes as a site name, and whether Create would take it, without creating anything.

func (Ops) ContentOf

func (o Ops) ContentOf(ctx context.Context, actor sitesvc.Actor, siteRef, path string, release int) (*FileBytes, error)

ContentOf is one file of dev, or of release when it is not 0, for the viewer. Without a release it reads what the Files tab reads: the source for the people who manage the site, what dev serves for someone dev is shared with. A release's file is read by the people who manage the site, and by anyone else only while an environment they can open serves that release. A path outside the tree is refused, and so is a pruned release.

func (Ops) Promote

func (o Ops) Promote(ctx context.Context, actor sitesvc.Actor, req sitesvc.PromoteRequest) (*sitesvc.Promoted, error)

Promote is the service's promote, an agent's waiting on a person (#2643). Whatever the service would refuse (the wrong environment, nothing to move, no permission) it refuses in its own words, before anyone is asked.

func (Ops) RemoveEnvironment

func (o Ops) RemoveEnvironment(ctx context.Context, actor sitesvc.Actor, ref, name string) (*site.Site, error)

RemoveEnvironment removes an environment between dev and prod (#2630). It is refused while the environment has a domain, holds the main address, is a part of an application, or has a job running, each naming what to do first. Removing one that requires approval takes an approval gate out of the promotion path, so it is an administrator's.

func (Ops) RenameEnvironment

func (o Ops) RenameEnvironment(ctx context.Context, actor sitesvc.Actor, ref, from, to string) (*site.Site, error)

RenameEnvironment renames an environment between dev and prod (#2630). The new name passes the environment-name and address rules, is not dev, prod or the old alias, and is not in use. Every reference to the old name moves in one transaction; the environment answers at <site>--<new> at once, and the old address answers nothing. It is anyone's who may change the environment's settings.

func (Ops) RequestMove

func (o Ops) RequestMove(ctx context.Context, actor sitesvc.Actor, m AgentMove) (*approval.Request, error)

RequestMove files the request a person decides an agent's move by, in the portal's Approvals, when the agent's client cannot ask them. The agent can never decide it (approval.Actor.Agent).

func (Ops) Rollback

func (o Ops) Rollback(ctx context.Context, actor sitesvc.Actor, ref, environment string, to int) (*sitesvc.Promoted, error)

Rollback is the service's rollback, an agent's waiting on a person.

func (Ops) SetDomainAccess

func (o Ops) SetDomainAccess(ctx context.Context, actor sitesvc.Actor, hostname string, public bool, reason string) (*DomainResult, error)

SetDomainAccess is the service's, making a domain public for an agent waiting on a person.

func (Ops) SetEnvironment

func (o Ops) SetEnvironment(ctx context.Context, actor sitesvc.Actor, ref, name string, c sitesvc.EnvironmentChange) (*sitesvc.EnvironmentResult, error)

SetEnvironment is the service's, with agents_may_promote (#2643) set only by an administrator in the portal: a person's decision about the environment, never an agent's. dev has no such setting, since an agent's moves into dev never wait on anyone.

func (Ops) SetStatus

func (o Ops) SetStatus(ctx context.Context, actor sitesvc.Actor, ref, name string, c StatusChange) (*StatusResult, error)

SetStatus takes an environment offline, redirects it, or brings it back online. It is anyone's who manages the site, and it takes effect at once: an outage cannot wait in a queue. The one exception is a redirect on an environment that requires approval, set by someone who is not an administrator: it would send every visitor to a site the platform does not control, so it waits on Approvals, and the environment keeps answering as it does until it is approved and set again. dev is the private working copy and is always online. The release pointer is never touched.

type PersonDecisionError

type PersonDecisionError struct{ Move AgentMove }

PersonDecisionError is a move an agent asked for that waits on the person.

func IsPersonDecision

func IsPersonDecision(err error) (*PersonDecisionError, bool)

IsPersonDecision reports whether err is a move waiting on a person.

func (*PersonDecisionError) Error

func (e *PersonDecisionError) Error() string

type StatusChange

type StatusChange struct {
	// Status is online, offline or redirect.
	Status string
	// Message is an offline environment's message; "" shows the default.
	Message string
	// BackAt is when visitors are told an offline environment is back.
	BackAt *time.Time
	// RedirectTo and KeepPath are a redirect's target and path rule.
	RedirectTo string
	KeepPath   bool
	// Reason goes with a redirect that waits on Approvals.
	Reason string
}

StatusChange is a change to what an environment answers (#2631, #2632).

type StatusResult

type StatusResult struct {
	Site *site.Site `json:"site"`
	// Status is StatusDone or StatusAwaitingApproval.
	Status   string            `json:"status"`
	Approval *approval.Request `json:"approval,omitempty"`
}

StatusResult is what a status change did: the site as it now stands, and the request a redirect waits on where the environment requires approval.

Jump to

Keyboard shortcuts

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