Documentation
¶
Overview ¶
Package derive turns what impulse's reader reports about an application, plus a placement, into the application's infrastructure model: the processes that run, the configuration levels they construct, every environment variable by level with where a running process gets its value, the secrets among them, the auths with their login callback, and the database and schema the migration owns.
Everything in the model names the declaration it comes from (a struct field under the config package, a route, a command), so the rendered stack can say so in a comment.
Index ¶
- Constants
- Variables
- func AdministratorPasswordVariable(auth string) string
- func AdministratorVariable(auth string) string
- func BucketPolicyAddress(bucket string) string
- func BuildArgumentSubstitution(name string) string
- func BuildValueNames() []string
- func CreatePlacement(file string, p *Placement) error
- func HostnameLabelOK(label string) bool
- func HostnameOK(name string) bool
- func IsRelease(v string) bool
- func MarshalPlacement(p *Placement) ([]byte, error)
- func MigrationDirs(a *app.App) ([]string, error)
- func MigrationsDir(a *app.App) (string, error)
- func PathRegex(route string) string
- func RegistrationVariable(auth, registration, suffix string) string
- func SpannerCapacityRule(processingUnits int) string
- func SpannerDatabaseCapacity(processingUnits int) int
- func SpannerRaise(setting string, processingUnits int) string
- func ValidateApplicationCode(code string) error
- func ValidateBranch(field, branch string) error
- func ValidateHostnameLabel(label string) error
- func ValidateRegionName(field, name string) error
- func ValidateRetention(retention string) error
- func VersionVariable(variable, version string) string
- func WritePlacement(file string, p *Placement) error
- type Armor
- type Auth
- type BuildValue
- type Bypass
- type CloudArmor
- type Database
- type DatedSlot
- type Environment
- type FieldExclusion
- type FileRoute
- type FileStore
- type Firestore
- type FirestoreField
- type FirestoreIndex
- type FirestoreIndexField
- type FirestoreSingleFieldIndex
- type HookProgram
- type ImageInputs
- type KnownRuleSet
- type Level
- type Machine
- type MaintenanceWindow
- func (w *MaintenanceWindow) AllReleases() bool
- func (w MaintenanceWindow) MarshalJSON() ([]byte, error)
- func (w *MaintenanceWindow) Opening(now time.Time) (Opening, error)
- func (w *MaintenanceWindow) PassedDates(now time.Time) []DatedSlot
- func (w *MaintenanceWindow) String() string
- func (w *MaintenanceWindow) UnmarshalJSON(data []byte) error
- type Method
- type Model
- func (m *Model) ByLevel(level string) []*Variable
- func (m *Model) ByRoleAtLevel(role Role, level string) *Variable
- func (m *Model) DirectoryMethods() []*Method
- func (m *Model) Level(name string) (Level, bool)
- func (m *Model) MultiSite() bool
- func (m *Model) Personas() []*Method
- func (m *Model) RetirementOutOfReach(s *Secret) string
- func (m *Model) RouterDirs() []string
- func (m *Model) SiteNamed(name string) *Site
- func (m *Model) SiteNames() []string
- type OldestAnswered
- type Opening
- type Outlet
- type Outlier
- type OutlierDetection
- type PersonaPlacement
- type Placement
- func (p *Placement) ApprovalEnvironments() []string
- func (p *Placement) Armor() Armor
- func (p *Placement) BuildArgumentNames() []string
- func (p *Placement) DefaultLabel(site, dir string) string
- func (p *Placement) InProduction() bool
- func (p *Placement) Integration() string
- func (p *Placement) KeepsReleaseBackups(env string) bool
- func (p *Placement) Label(site, dir string) string
- func (p *Placement) Machine() (Machine, bool)
- func (p *Placement) MaintenanceSetting(env string) (MaintenanceWindow, bool)
- func (p *Placement) MaxInstanceCount(env string) (int, bool)
- func (p *Placement) Outlier() Outlier
- func (p *Placement) Pinned() bool
- func (p *Placement) Previous(env string) string
- func (p *Placement) Primary() Region
- func (p *Placement) Production() string
- func (p *Placement) Project(env string) (Project, bool)
- func (p *Placement) ReleaseActor() string
- func (p *Placement) ReleaseBackupEnvironments() []string
- func (p *Placement) Restorable() []string
- func (p *Placement) RestoreKind(env string) string
- func (p *Placement) Retention(env string) string
- func (p *Placement) SeedEnvironments() []string
- func (p *Placement) SiteNameBudget() int
- func (p *Placement) Validate() error
- func (p *Placement) ValidateSiteName(name string) error
- func (p *Placement) VanityDeclared() bool
- type Process
- type Project
- type Region
- type RegistrationSetting
- type ReleaseFile
- type ReleaseOutlet
- type ReleaseProgram
- type RequestLogExclusion
- type Role
- type Route
- type RuleSet
- type ScheduledRoute
- type Schema
- type Secret
- type SignInRoute
- type Site
- type SiteHostnames
- type Supply
- type Surface
- type Variable
- type WeeklySlot
- type WorkspaceInputs
Constants ¶
const ( RuleSetScannerDetection = "scannerdetection-v33-stable" RuleSetSQLi = "sqli-v33-stable" RuleSetJSONSQLi = "json-sqli-canary" RuleSetXSS = "xss-v33-stable" RuleSetProtocolAttack = "protocolattack-v33-stable" RuleSetLFI = "lfi-v33-stable" RuleSetRFI = "rfi-v33-stable" RuleSetRCE = "rce-v33-stable" RuleSetMethodEnforcement = "methodenforcement-v33-stable" RuleSetPHP = "php-v33-stable" RuleSetSessionFixation = "sessionfixation-v33-stable" RuleSetJava = "java-v33-stable" RuleSetNodeJS = "nodejs-v33-stable" RuleSetCVE = "cve-canary" )
The preconfigured rule sets' names, as evaluatePreconfiguredWaf takes them.
const ( MinSensitivity = 1 MaxSensitivity = 4 DefaultSensitivity = 1 )
The sensitivities a rule set runs at, and how many of the known sets are the defaults.
const ( FieldHeader = "header" FieldCookie = "cookie" FieldQueryParam = "queryParam" FieldURI = "uri" OperatorEquals = "equals" OperatorStartsWith = "startsWith" OperatorEndsWith = "endsWith" OperatorContains = "contains" OperatorAny = "any" )
The kinds of field an exclusion names, and the operators that name one.
const ( FieldTenantID = "TenantID" FieldTenants = "Tenants" FieldHostedDomain = "HostedDomain" FieldWorkspaces = "Workspaces" FieldClientID = "ClientID" FieldClientSecret = "ClientSecret" FieldRedirectURL = "RedirectURL" FieldGroupPrefix = "GroupPrefix" FieldGroupLookup = "GroupLookup" // FieldIssuer is the issuer URL of a provider the generic OpenID Connect method signs // in through: for the persona method the persona provider's, its one setting beside // the client id and the callback, which the stack derives; for an organization's own // identity provider (an oidc method) the provider itself, a placement variable once // for the organization. FieldIssuer = "Issuer" // The organizations the deployment administers among those the slot admits, whose // sign-ins carry the directory's second factor: tenants by id, Workspaces by domain. FieldAdministeredTenants = "AdministeredTenants" FieldAdministeredWorkspaces = "AdministeredWorkspaces" )
The settings a directory method reads from the environment, by the field of the method's settings struct as impulse renders it (the suffix of the variable under the convention APP_<AUTH>_<REGISTRATION>_<FIELD>).
const ( // BuildValueFirebaseAPIKey is the key string of the Firebase web API key the stack // makes for the application (firestore.tf), the key the browser presents to sign in. BuildValueFirebaseAPIKey = "firebaseApiKey" // BuildValueFirestoreDatabase is the id of the application's Firestore database. BuildValueFirestoreDatabase = "firestoreDatabase" // BuildValueProjectID is the environment project's id. BuildValueProjectID = "projectId" // BuildValueEnvironment is the environment's name (tst, stg, prd). BuildValueEnvironment = "environment" // BuildValueHostname is the service's canonical hostname in the environment. BuildValueHostname = "hostname" )
The values a placement's buildArguments may name: the catalog of what the stack makes or knows in each environment.
const ( LevelCore = "core" LevelData = "data" LevelSite = "site" )
The levels' names, as the skeleton's config package declares them.
const ( FirestoreIndexesFile = "firestore.indexes.json" FirestoreRulesFile = "firestore.rules" )
The two files, by the names the Firebase tooling gives them.
const ( MaintenanceAnytime = "anytime" ReleasesBreaking = "breaking" ReleasesAll = "all" )
The words a maintenance setting is written with: the one-word setting of an environment that takes a window release at any time, and the two values of releases (only a breaking release waits for the window, the default; every release does).
const ( DefaultConsecutiveErrors = 5 DefaultEnforcingConsecutiveErrors = 100 DefaultMaxEjectionPercent = 50 DefaultIntervalSeconds = 1 DefaultBaseEjectionSeconds = 30 )
The thresholds' defaults: five errors in a row eject a region's group, counted every second; every detection ejects (100 percent enforcing); at most half the groups are out at once, so one region of two; and a group is out for thirty seconds the first time.
const ( MachineE2Medium = "E2_MEDIUM" MachineE2Standard2 = "E2_STANDARD_2" MachineE2HighCPU8 = "E2_HIGHCPU_8" MachineE2HighCPU32 = "E2_HIGHCPU_32" )
The machines a placement's buildMachine may name, as options.machineType spells them.
const ( // PlaceholderImage is the image an application's first placement names for every // service and job to be created with before the first deploy (placeholderImage): the // framework's welcome image, this repository's welcome directory, which serves one // page on the port Cloud Run gives it, in HTTP/1.1 and in unencrypted HTTP/2 (a site // on the framework's server gets a container port named h2c, which an image that // speaks HTTP/1.1 alone answers with 502), and reads nothing. It is named by its // digest, the hash of what the registry holds, so a service is created with the image // that was published as PlaceholderVersion and with nothing a tag could be moved to // afterwards. A placement written before this image keeps the one it names, Cloud // Run's public sample. PlaceholderImage = "ghcr.io/impulseframework/welcome@sha256:106eb632ba7ae2857a044cec68c6efd8d647f67b2355f3b37e206b1686fee6aa" // PlaceholderVersion is the version of the welcome image that digest was published // as: the version welcome/VERSION records, or the one before it. A digest exists only // once its image is published, and the image is published by the merge that raises // the version, so a change to the image lands in two steps: the version is raised and // merged, and then its digest is named here. Between the two this names the version // before. The workflow that publishes the image holds the digest to the registry's // for this version at every run (.github/workflows/welcome-image.yml). PlaceholderVersion = "v1" )
const ( RestoreEmpty = "empty" RestoreBackup = "production-backup" )
The two restores a run makes: an empty database the migrations and the seed then fill, and production's most recent backup, for the environment on production's instance whose database is not seeded.
const ( ReleaseThis = "this" OutletAPIKey = "api-key" )
How the release file spells its values: an outlet whose oldest answered release is the server's own, and the kind of an outlet that machines call with an API key.
const ( RequestLogAlways = "always" RequestLogOnEvent = "onEvent" RequestLogSampled = "sampled" RequestLogNever = "never" )
The request log words, as the release file spells them: the entry is written for every request, when a line attached or the request failed, as on event plus a fraction of the quiet requests, or never.
const ( TracesFollowFrontEnd = "followFrontEnd" TracesCapped = "capped" TracesOff = "off" )
The trace settings, as the release file spells them: a surface's spans follow the front end, are capped at a rate, or are off.
const ( SurfacePrefix = "prefix" SurfaceRoute = "route" )
The surface kinds, as the release file spells them: a prefix is matched against the start of the path, a route to its end.
const ( FileRouteUpload = "upload" FileRouteStored = "file" )
The kinds of file route, as the file spells them.
const ( SignInPassword = "password" SignInConfirm = "confirm" SignInCancel = "cancel" )
The kinds of sign-in route: the password method's login, the pending sign-in's confirmation, and its cancel.
const ApplicationCodePattern = `^[a-z][a-z0-9]{0,5}$`
ApplicationCodePattern is the shape of an application code, the one rule for it: one to six lowercase letters and digits starting with a letter, the segment every resource name of the application carries (the Terraform's validations are rendered from it too). The code is the organization's naming decision, declared at registration (bedrock org register) and recorded in the organization's placement and the application's; the repository's name is the module path's and is bound by no such rule.
const BuildArgumentPrefix = "_BUILD_ARG_"
BuildArgumentPrefix starts the trigger substitution that carries a build argument, _BUILD_ARG_<NAME>: the stack renders one per declared argument, the image build reads every substitution so named and passes it as --build-arg NAME=value, and a substitution the application declares in terraform.tfvars may not start with it.
const DefaultRetention = "7d"
DefaultRetention is how far back Spanner keeps an environment's row versions unless the placement says otherwise: seven days, the most Spanner allows.
const FirestoreDir = "firestore"
FirestoreDir is the Firestore directory's name beside the schema migrations directory (schema/firestore): the composite indexes, the time-to-live policies and the security rules of the application's Firestore database, in the two files the Firebase tooling also reads.
const HostnameLabelPattern = `^[a-z]([a-z0-9-]{0,52}[a-z0-9])?$`
HostnameLabelPattern is the one rule for a site's hostname label: a DNS label of lowercase letters, digits and hyphens, starting with a letter and ending with a letter or digit, of at most 54 characters, so that an environment's hostname label, <label>-<env> with an environment name of up to eight characters, fits a DNS label's 63. A pull-request stack's hostname and service are named for the pull request, <app>-pr<N>, not the label.
const HostnameLabelRule = "a DNS label of at most 54 lowercase letters, digits and hyphens, starting with a letter and ending with a letter or digit"
HostnameLabelRule says the rule in words, for the refusals that name it.
const MaintenanceVariable = varMaintenance
MaintenanceVariable is the variable the pipeline sets on a maintenance revision, which the stack declares empty on the service (see varMaintenance).
const ProcfileName = "Procfile"
ProcfileName is the development process file at the application root.
const ReleaseFileName = "zz_gen_release.json"
ReleaseFileName is the generated release file, written by the resource generator beside the generated router (zz_gen_router.go) in the router package's directory. It names every outlet the generator knows and, for each session outlet, the oldest release of the browser application the outlet still answers, as the generator program declares it (OldestAnswered). The deploy reads it from the checkout, never from a binary.
const ScheduledPrefix = "/_scheduled"
ScheduledPrefix is the path the generated router serves the scheduled routes under, each at ScheduledPrefix/<name>, behind the framework's check of Cloud Scheduler's token.
const SchedulerInvokerVariable = "APP_SCHEDULER_INVOKER"
SchedulerInvokerVariable is the variable that names the invoker identity to the service: the email a scheduled call's token must carry. The framework reads it itself, so no configuration level declares it; with it empty every scheduled call is refused.
const SeedDir = "devseed"
SeedDir is the seed directory's name beside the schema migrations directory: the data migrations the migrate command applies with -seed, tracked apart from the schema.
const ( // ServerPackage is the framework's HTTP server, which speaks HTTP/1.1 and unencrypted // HTTP/2 (h2c) on one listener; a site's main package importing it is the // application's declaration that its image speaks h2c, from which the stack names the // service's port h2c and Cloud Run lifts the 32 MiB bounds of HTTP/1 bodies. ServerPackage = "github.com/impulseframework/impulse/resource/server" )
const SiteBundleVariable = "APP_DIST"
SiteBundleVariable is the site-level variable a sites-layout application reads its built browser bundle's directory from, required and without a default, since each site's differs: the Procfile sets it per process in development and the stack per service (RoleSiteBundle). The flat layout names its bundles with a default the image sets instead (BundleRE).
const SiteNamePattern = `^[a-z][a-z0-9]*$`
SiteNamePattern is the rule for a site's name in the sites layout: lowercase letters and digits starting with a letter, the segment every per-site resource name and the default hostname label carry. The length comes from the tightest name the segment enters, the Cloud Run service's (SiteNameBudget).
const SiteProcessName = "app"
SiteProcessName is the served site's process name in the flat layout (its binary is /app) and the runtime identity's name in both layouts: one identity serves every site. A sites-layout site's process is named after the site.
Variables ¶
var BundleRE = regexp.MustCompile(`^([^/]+)/dist/([^/]+)$`)
BundleRE matches the default of a variable naming a built browser bundle, as the skeleton declares them: the browser workspace, dist, the bundle (web/dist/console).
var JobsTemplateVariable = jobsTemplateVariable()
JobsTemplateVariable is the variable the stack sets on the service to the job process's template job, as the Cloud Run API names it (projects/<p>/locations/<l>/jobs/<j>): the framework's job driver (resource/jobs/cloudrun) reads it, with the version the image bakes in, and names the job of this build from the two, the template's name with the version's key, which the pipeline made on this build's image. The served site declares it by embedding the driver's settings in a configuration level, and the name is read off the driver's declaration here, so the stack sets the variable the driver reads however either side is spelled; jobsTemplate holds the declaration to the job process, and its level to the served site.
Functions ¶
func AdministratorPasswordVariable ¶
AdministratorPasswordVariable is the variable an auth's first-administrator password goes under: APP_<AUTH>_ADMINISTRATOR_PASSWORD.
func AdministratorVariable ¶
AdministratorVariable is the environment variable naming an auth's first administrator under the convention: APP_<AUTH>_ADMINISTRATOR.
func BucketPolicyAddress ¶
BucketPolicyAddress is the address of a bucket's IAM policy in the stack from the bucket's own: google_storage_bucket.<resource> becomes google_storage_bucket_iam_policy.<resource>. The pipeline names the file stores' policies this way from the buckets' addresses its trigger carries; an address that is not a bucket's answers "".
func BuildArgumentSubstitution ¶
BuildArgumentSubstitution is the trigger substitution carrying the build argument.
func BuildValueNames ¶
func BuildValueNames() []string
BuildValueNames lists the catalog's names, in its order.
func CreatePlacement ¶
CreatePlacement writes an application's first placement to its JSON file, creating the file's directory when absent, and refuses a file that exists: a placement is the application's from its first write, and nothing overwrites it.
func HostnameLabelOK ¶
HostnameLabelOK reports whether a site's hostname label follows the one rule.
func HostnameOK ¶
HostnameOK reports whether the name is a lowercase hostname or domain, such as example.com or console.example.com: what a vanity hostname and a vanity domain are held to.
func IsRelease ¶
IsRelease reports whether v is a release as the release file and the generator program write one: a semantic version without its v, 1.5.0.
func MarshalPlacement ¶
MarshalPlacement is the placement as its JSON file holds it: the fields in their order, indented the way a person reads it, ending in a newline.
func MigrationDirs ¶
MigrationDirs is the schema migrations directory and the seed directory beside it, root-relative: the two directories the migrate command reads, the guard checks and the renumber moves files in.
func MigrationsDir ¶
MigrationsDir is the root-relative directory of the schema migrations: the file:// source the site generator declares.
func PathRegex ¶
PathRegex is the route or prefix as the RE2 expression Cloud Armor matches the path against and Cloud Logging the request's URL: a parameter in braces matches one segment, a last star the subtree, and a dot matches itself through a class, so the expression carries no backslash to escape in CEL, in a Logging query or in HCL. A route's other characters (letters, digits, dashes, underscores, tildes, slashes) match themselves.
func RegistrationVariable ¶
RegistrationVariable is the environment variable of a directory method's setting under the convention: APP_<AUTH>_<REGISTRATION>_<SUFFIX>, the auth's name and the registration's name in upper case with underscores for hyphens.
func SpannerCapacityRule ¶
SpannerCapacityRule says, for a sentence, why an instance of the processing units holds what it holds: the rule below a node, or the flat hundred from a node on.
func SpannerDatabaseCapacity ¶
SpannerDatabaseCapacity is the databases an instance of the processing units holds.
func SpannerRaise ¶
SpannerRaise is the way out through the instance's size, for a refusal that ends with the other way out, destroying an application: below a node, raising the setting holds more databases; from a node on no raise does, and the sentence says so.
func ValidateApplicationCode ¶
ValidateApplicationCode refuses a code that is not one to six lowercase letters and digits starting with a letter.
func ValidateBranch ¶ added in v0.1.3
ValidateBranch refuses a default branch that is not a name bedrock can write as it is: the workflows hold it between double quotes and in a command line, where a space, a quote, a backslash or a line break would end it or start something else. field is the placement's field, which the refusal names.
func ValidateHostnameLabel ¶
ValidateHostnameLabel holds a site's hostname label to the one rule.
func ValidateRegionName ¶ added in v0.1.3
ValidateRegionName refuses a region's name that is not one: the operations workflow writes the primary region's as a plain word. field is the placement's field, which the refusal names.
func ValidateRetention ¶
ValidateRetention checks a version retention period as Spanner takes one: a whole number of hours (1h to 168h) or days (1d to 7d), between one hour and seven days.
func VersionVariable ¶ added in v0.1.2
VersionVariable is the variable a process receives one version of a versioned secret under: the declared variable, an underscore and the Secret Manager version's number (APP_SECRET_KEY_2 for version 2 of APP_SECRET_KEY).
func WritePlacement ¶
WritePlacement writes the placement to its JSON file, in the fields' order, as bedrock upgrade rewrites it after moving the pin.
Types ¶
type Armor ¶
type Armor struct {
// Leading are the rule sets that run ahead of the bypasses, on every path: the sets
// that read no body.
Leading []RuleSet
// Trailing are the rule sets that run after the bypasses, on the outlets' routes.
Trailing []RuleSet
FieldExclusions []FieldExclusion
Bypasses []Bypass
}
Armor is the policy a stack is rendered with: the placement's, with the defaults where it writes none, the rule sets split by where they run.
type Auth ¶
type Auth struct {
// Name is the auth's name, the package's directory name.
Name string
// Dir is the auth package's root-relative directory.
Dir string
// Methods are the sign-in methods registered on the Auth: the password method and the
// directory methods, each under its registration name.
Methods []Method
// Administrator is the variable naming the auth's first administrator
// (APP_<AUTH>_ADMINISTRATOR, RoleAdministrator), nil when the code declares none: an
// auth whose people hold roles the application assigns has nobody who may do anything
// until a membership exists, so its deployment seeds the administrator role membership
// under this sign-in name while the auth's users table holds no rows. An auth with a
// password method seeds a user with a generated password instead, a secret like any
// other, and declares no sign-in name.
Administrator *Variable
// AdministratorPassword is the generated password of the auth's first administrator
// (APP_<AUTH>_ADMINISTRATOR_PASSWORD), which an auth with a password method declares as
// a generated secret: the migrate command seeds the administrator user with it while the
// users table holds no rows, so it is the one runtime secret the command reads. Nil for
// an auth that declares none.
AdministratorPassword *Variable
}
Auth is one auth: the package, and the sign-in methods registered on the Auth it constructs, in registration order.
type BuildValue ¶
BuildValue is one entry of the catalog: its name, as buildArguments writes it, and what the value is.
func BuildValues ¶
func BuildValues() []BuildValue
BuildValues is the catalog, in the order the messages and the READMEs list it.
type Bypass ¶
type Bypass struct {
// Path is the route as the application mounts it, with its parameters in braces
// (/hooks/registry, /streams/{id}/audio); a last segment of * takes the subtree
// (/streams/*).
Path string `json:"path"`
// Method is the HTTP method the bypass is for; empty, every method.
Method string `json:"method,omitempty"`
// Reason says why the route carries no input the rules can judge, for the rule's
// description.
Reason string `json:"reason"`
}
Bypass is one path the policy allows ahead of the rule sets.
type CloudArmor ¶
type CloudArmor struct {
// RuleSets are the preconfigured rule sets the policy evaluates, in order, each at a
// sensitivity; absent, DefaultRuleSets. A set that reads no body (scanner detection)
// runs ahead of the bypasses, on every path; every other set runs after them, on the
// outlets' routes alone.
RuleSets []RuleSet `json:"ruleSets,omitempty"`
// FieldExclusions are the request fields a rule set does not inspect: a cookie, a
// header, a query parameter or the path, named exactly or by part, for every rule of
// the set or the rules named. For a field whose legitimate values trip a rule, a
// session cookie of random bytes under the cross-site scripting rules, say.
FieldExclusions []FieldExclusion `json:"fieldExclusions,omitempty"`
// Bypasses are the paths the policy allows ahead of the rule sets, beside the
// routes bedrock derives from the generated router (each @upload method's and each
// stored file's): a route whose body is not the application's JSON, such as a
// webhook under the Root hook whose sender signs its own body, or a media stream.
Bypasses []Bypass `json:"bypasses,omitempty"`
}
CloudArmor is a placement's Cloud Armor policy (cloudArmor). Every field is optional: a block left out, or an empty one, is the default rule sets with no exclusion and no bypass of the placement's.
func (*CloudArmor) Clone ¶
func (a *CloudArmor) Clone() *CloudArmor
Clone is a copy that shares nothing with a; nil stays nil.
func (*CloudArmor) Resolved ¶
func (a *CloudArmor) Resolved() Armor
Resolved is the policy with the defaults in place of what the placement leaves out; a nil CloudArmor is the defaults.
func (*CloudArmor) Validate ¶
func (a *CloudArmor) Validate() error
Validate refuses a policy the stack could not render as meant: a rule set bedrock does not know, or listed twice, or at a sensitivity outside 1 to 4; an exclusion for a set the policy does not evaluate, of a field or an operator the API has no spelling for, naming no field or a field under any, or without a reason; and a bypass whose path is not a route's shape, whose method is not one, listed twice, or without a reason.
type Environment ¶
Environment is one environment of the placement with the hostnames it serves.
type FieldExclusion ¶
type FieldExclusion struct {
// RuleSet is the set the exclusion applies to, one of the policy's.
RuleSet string `json:"ruleSet"`
// Field is the kind of field: header, cookie, queryParam or uri.
Field string `json:"field"`
// Operator says how Value names the field: equals (the default), startsWith,
// endsWith, contains, or any, which names every field of the kind and takes no
// Value.
Operator string `json:"operator,omitempty"`
// Value is the field's name, or the part of it Operator reads.
Value string `json:"value,omitempty"`
// Rules are the rules of the set the exclusion is for, by Cloud Armor's rule ids
// (owasp-crs-v030301-id941100-xss); none means every rule of the set.
Rules []string `json:"rules,omitempty"`
// Reason says why, for the rendered policy's comment.
Reason string `json:"reason"`
}
FieldExclusion is one request field a rule set does not inspect.
func (*FieldExclusion) Block ¶
func (e *FieldExclusion) Block() string
Block is the block the Terraform provider takes the field in (request_cookie).
func (*FieldExclusion) OperatorName ¶
func (e *FieldExclusion) OperatorName() string
OperatorName is the operator as the API spells it (EQUALS, EQUALS_ANY).
type FileRoute ¶
type FileRoute struct {
// Kind is FileRouteUpload or FileRouteStored.
Kind string `json:"kind"`
// Method is the HTTP method the route answers: POST for an upload, GET for a stored
// file.
Method string `json:"method"`
// Path is the route as the router mounts it, under its outlet's prefix, with its
// parameters in braces (/api/photos/{id}/file).
Path string `json:"path"`
// Source names the declaration the route comes from: the method's struct
// (AttachPhoto) or the resource and its key column (Photo.Key).
Source string `json:"source"`
}
FileRoute is one route of the release file that carries a file rather than JSON: an @upload method's route, whose body is multipart, or a stored file's read route, whose answer is the object.
func (*FileRoute) Declaration ¶
Declaration says what the route comes from, for a rule's description: the @upload method, the @file column (resource and column, Manifest.Key), or the computed resource that renders its file (Statement).
type FileStore ¶
type FileStore struct {
// Variable is the variable the store is declared by.
Variable *Variable
// Name is the store's name: empty for the default store, else the variable's suffix
// in lower case with hyphens (documents, client-files).
Name string
// Resource is the bucket's resource name in the stack: files for the default store,
// files_<name> with underscores for a named one (files_client_files), since a
// resource name admits no hyphen.
Resource string
// Suffix is the segment the bucket's name ends in before the project number: files
// for the default store, files-<name> for a named one (files-client-files).
Suffix string
}
FileStore is one Cloud Storage bucket the application declares by a file-store variable: APP_FILE_STORE for its default store, APP_FILE_STORE_<NAME> for a named one. The stack creates the bucket, sets the variable to the bucket's gs:// URL, and grants the processes that construct the variable's level on its objects.
func (*FileStore) Address ¶
Address is the bucket's address in the stack: google_storage_bucket.<resource>.
func (*FileStore) Default ¶
Default reports the application's default store, the one APP_FILE_STORE declares.
func (*FileStore) PolicyAddress ¶
PolicyAddress is the address of the bucket's IAM policy in the stack, google_storage_bucket_iam_policy.<resource>. The stack sets the bucket's whole permission list through it, and check and the pipeline's test admit that one authoritative IAM resource per store by this address.
type Firestore ¶
type Firestore struct {
// Dir is the root-relative directory the files are read from.
Dir string
// IndexesFile and RulesFile are the two files, root-relative.
IndexesFile string
RulesFile string
// Indexes are the composite indexes, in the file's order.
Indexes []FirestoreIndex
// Fields are the fields the file settles on their own (its fieldOverrides): a
// time-to-live policy, the single-field indexes, or both; in the file's order.
Fields []FirestoreField
// Rules is the security rules source as the file holds it.
Rules string
}
Firestore is what the stack applies to the application's Firestore database from the files beside the schema migrations: the composite indexes and the field settings of the indexes file, and the security rules.
type FirestoreField ¶
type FirestoreField struct {
// Collection is the collection group, Field the field path.
Collection string
Field string
// TTL reports a time-to-live policy on the field: a document is deleted once the
// timestamp the field holds has passed.
TTL bool
// Indexes are the field's single-field indexes, as the file lists them, and
// HasIndexes whether the file lists them at all: a listed empty set turns the field's
// indexing off, an absent one leaves the database's default indexing.
Indexes []FirestoreSingleFieldIndex
HasIndexes bool
}
FirestoreField is one field the indexes file settles on its own.
func (*FirestoreField) Name ¶
func (f *FirestoreField) Name() string
Name is the field's resource name in the stack: the collection and the field path.
type FirestoreIndex ¶
type FirestoreIndex struct {
// Collection is the collection group the index is on.
Collection string
// QueryScope is the scope queries run at: COLLECTION as a rule.
QueryScope string
// Fields are the indexed fields, in the file's order.
Fields []FirestoreIndexField
}
FirestoreIndex is one composite index.
func (*FirestoreIndex) Name ¶
func (i *FirestoreIndex) Name() string
Name is the index's resource name in the stack: the collection and the field paths, joined by underscores, with anything else a resource name may not carry replaced.
type FirestoreIndexField ¶
type FirestoreIndexField struct {
Path string
// Order is ASCENDING or DESCENDING for an ordered field, and empty for an array
// field, whose ArrayConfig is CONTAINS.
Order string
ArrayConfig string
}
FirestoreIndexField is one field of a composite index: ordered, or an array field.
type FirestoreSingleFieldIndex ¶
type FirestoreSingleFieldIndex struct {
QueryScope string
// Order is ASCENDING or DESCENDING for an ordered index, and empty for an array
// index, whose ArrayConfig is CONTAINS.
Order string
ArrayConfig string
}
FirestoreSingleFieldIndex is one single-field index of a field.
type HookProgram ¶
HookProgram is the application's hooks program: its main package, and the stages its deployhook.Hooks literal implements, in the pipeline's order.
type ImageInputs ¶
type ImageInputs struct {
// RootGo reports Go files in the root package (main.go), test files aside.
RootGo bool
// GoDirs are the top-level directories holding Go packages, test files aside, in
// name order. A directory go build never reads as a package (testdata, a name
// starting with . or _) and a directory that is a module of its own are left out.
GoDirs []string
// Workspaces are the browser workspaces, every directory holding an angular.json, in
// the order found, each with its install files.
Workspaces []WorkspaceInputs
}
ImageInputs is what the seeded Dockerfile copies by name, read from the tree at render time. The Go stage copies go.mod and go.sum, the root package's Go files and each top-level directory holding Go packages, whole: a copy layer is keyed on the files it copies, so the pipeline's per-build files, the git directory and the provider downloads are inputs of no layer. A package directory added later needs a line of its own in the application's Dockerfile; a missing one fails the compile within seconds, naming the package. Each browser workspace's install stage copies the files bun install reads and nothing else, so the stage's layers hold the installed packages alone.
func (*ImageInputs) WorkspaceInputs ¶
func (in *ImageInputs) WorkspaceInputs(dir string) []string
WorkspaceInputs returns the workspace's install files, or the two every install has for a workspace the tree does not hold (the render of a fixture without one).
type KnownRuleSet ¶
type KnownRuleSet struct {
// Name is the set's name in evaluatePreconfiguredWaf.
Name string
// Detects says what the set detects, for the rendered policy and the README.
Detects string
// Leading says the set reads no body, so it runs ahead of the bypasses, on every
// path: a route that carries a file still benefits from it.
Leading bool
}
KnownRuleSet is one preconfigured rule set Cloud Armor offers, as bedrock knows it.
func KnownRuleSets ¶
func KnownRuleSets() []KnownRuleSet
KnownRuleSets lists the preconfigured rule sets a placement may name, the defaults first.
func RuleSetNamed ¶
func RuleSetNamed(name string) (KnownRuleSet, bool)
RuleSetNamed is the set of the name, and whether bedrock knows it.
type Level ¶
type Level struct {
// Name is the level's name: core, data, or site.
Name string
// File is the root-relative file declaring the level's struct.
File string
// Struct is the level's struct.
Struct string
// Description says which processes read the level.
Description string
// Constructor is the function that loads the level, empty when none was found.
Constructor string
}
Level is one configuration level of the config package.
type Machine ¶
Machine is one of the machines Cloud Build's default pool runs a build on, by the name options.machineType takes, with its vCPUs: what a project's default-pool CPU quota is divided by for the number of builds it runs at once.
func Machines ¶
func Machines() []Machine
Machines are the machines a placement's buildMachine may name, in size order: the E2 machines of the Cloud Build API's MachineType enum. The enum's two N1 machines are deprecated there and left out, so a placement never names a machine Cloud Build is retiring; the enum's UNSPECIFIED, the default, is what an absent value means.
type MaintenanceWindow ¶
type MaintenanceWindow struct {
// Anytime says the environment takes a window release at any time: the one-word
// setting, and every environment's default but production's.
Anytime bool
// TimeZone is the IANA zone the slots' times are read in (America/Chicago): the
// client's wall clock, through its daylight-saving changes.
TimeZone string
// Weekly are the slots that open every week; Dates the slots that open once.
Weekly []WeeklySlot
Dates []DatedSlot
// Releases says which releases wait for the window: breaking (the default when
// absent) or all. Maintenance mode is a breaking release's whichever it says.
Releases string
}
MaintenanceWindow is one environment's maintenance setting: the window in which the environment takes a release that interrupts service. Written as the word "anytime", or as an object naming the client's time zone, its weekly slots, its dated slots (a one-off the client agreed to) and which releases wait for it.
func (*MaintenanceWindow) AllReleases ¶
func (w *MaintenanceWindow) AllReleases() bool
AllReleases reports whether every release waits for the window, not only a breaking one.
func (MaintenanceWindow) MarshalJSON ¶
func (w MaintenanceWindow) MarshalJSON() ([]byte, error)
MarshalJSON writes the setting as the placement spells it: the word for anytime, the object otherwise.
func (*MaintenanceWindow) Opening ¶
func (w *MaintenanceWindow) Opening(now time.Time) (Opening, error)
Opening says whether the window is open at now and, when it is not, when it next opens. The slots are read on the client's wall clock in the setting's zone, so a weekly slot keeps its hour across a daylight-saving change; a weekly slot whose to is not after its from ends the next day. Among slots open at once, the one that closes last is answered; among slots ahead, the first to open.
func (*MaintenanceWindow) PassedDates ¶
func (w *MaintenanceWindow) PassedDates(now time.Time) []DatedSlot
PassedDates lists the dated slots that have passed by now: a one-off that is over and may be removed.
func (*MaintenanceWindow) String ¶
func (w *MaintenanceWindow) String() string
String spells the setting for a log line: anytime, or the slots in their zone.
func (*MaintenanceWindow) UnmarshalJSON ¶
func (w *MaintenanceWindow) UnmarshalJSON(data []byte) error
UnmarshalJSON reads the word or the object; any other word, and any other field, is refused.
type Method ¶
type Method struct {
// Auth is the auth's name.
Auth string
// Name is the registration name: the segment of the method's routes
// (user/<name>/callback) and of its variables.
Name string
// Kind is the method: password, azure, google, oidc (an organization's own identity
// provider), or persona.
Kind string
// Authority is who owns role membership for a directory method: directory or
// application (app.AuthorityDirectory, app.AuthorityApplication).
Authority string
// Tenants is the tenant shape a Microsoft registration builds (app.TenantsOne,
// app.TenantsListed, app.TenantsAny, app.TenantsPersonal), read from the slot
// function impulse add method writes, and PersonalAccounts whether it admits Microsoft
// personal accounts, alone or beside the tenants. Tenants is empty for another kind;
// a Microsoft registration whose slot the scan did not read is refused (tenantSlot).
Tenants string
PersonalAccounts bool
// Variables are the registration's settings the data level reads from the
// environment, by field (FieldClientID), each under
// APP_<AUTH>_<REGISTRATION>_<FIELD>; nil for the password method.
Variables map[string]*Variable
// Outlet is the outlet the auth is bound to, whose routes the callback is among, and
// Site the site serving that outlet, whose hostname the redirect URL is built on.
Outlet string
Site string
// Callback is the route the browser returns to after the directory sign-in; Logout
// the front-channel logout route of a Microsoft registration, which the app
// registration names too. Both empty for the password method.
Callback Route
Logout Route
// GroupPrefixDefault is the group prefix the development environment template sets,
// or empty; GroupLookupDefault how far the groups read reaches, direct or nested:
// what the template sets, or direct. Both empty for a registration that reads no
// role groups.
GroupPrefixDefault string
GroupLookupDefault string
// CastFile is the root-relative cast of a persona method (pkg/auth/<auth>/cast.json):
// the personas the migrate command seeds and the pipeline registers with the persona
// provider for each deployment. Empty for another kind.
CastFile string
}
Method is one sign-in method registered on an Auth: the password method, which the stack carries nothing for, or a directory method, with the registration's variables found by the convention and the callback the generated router registers for it.
func (*Method) Directory ¶
Directory reports a method whose people sign in through a directory, Microsoft Entra, Google, or an organization's own identity provider through the generic OpenID Connect method (an Okta, a Keycloak, or Google used as a plain OpenID Connect provider): the stack carries the registration's placement variables, its client secret and a hand step for the registration at the directory. The persona method is none: its provider is configured by the placement alone.
func (*Method) Fields ¶
func (m *Method) Fields() []RegistrationSetting
Fields lists the registration's settings in the stack's order (registrationFields), each with its variable: those the registration declares, among the settings a method of its kind reads.
func (*Method) FrontChannelLogout ¶
FrontChannelLogout reports a method whose registration names a front-channel logout route: the Microsoft one.
func (*Method) Persona ¶
Persona reports the persona method: the sign-in of the test environments through the persona provider the placement names, registered where the stack sets its issuer.
func (*Method) Provider ¶
Provider names who the browser is sent to: Microsoft, Google, the identity provider (an organization's own, in impulse's words for it), or the persona provider.
type Model ¶
type Model struct {
// App is the application code: the segment every resource name carries.
App string
// Label is the first site's hostname label under the apps domain (Site.Label), the
// first label of every hostname and of a pull-request stack's service name: the one
// the placement declares for the site (Placement.Hostnames), else the code. The
// other sites of the sites layout carry their own.
Label string
// Module is the application's module path.
Module string
// Repository is the application's repository URL, or empty when the module path does
// not name a GitHub repository.
Repository string
// ConfigDir is the root-relative directory of the config package.
ConfigDir string
// ConfigPackage is the config package's name, as its importers qualify it.
ConfigPackage string
// EnvTemplate is the root-relative development environment template, or empty.
EnvTemplate string
// Levels are the configuration levels in order, lowest first.
Levels []Level
// Variables are the environment variables the code reads, in declaration order.
Variables []Variable
// Secrets are the variables that hold a credential, in declaration order.
Secrets []Secret
// Database is the struct that identifies the database and its three variables.
Database Database
// Sites are the served sites in the generators' order: one in the flat layout, one
// per directory under apps/ in the sites layout, each a Cloud Run service of its own
// behind the shared image (Site). MultiSite reports more than one.
Sites []Site
// Migrate is the migration process, or nil when the application has no migrate
// command.
Migrate *Process
// Jobs is the job process, the application's own code as a Cloud Run job, or nil
// when the application has no cmd/jobs.
Jobs *Process
// Hooks are the stages the application commits a hook script for
// (infrastructure/hooks/<stage>.sh), in the pipeline's order, and HookProgram its hooks
// program (cmd/deployment/hooks) with the stages it implements, when it has one: the
// pipeline has a step for each stage either implements.
Hooks []hook.Stage
HookProgram *HookProgram
// Auths are the auths, sorted by name.
Auths []Auth
// Schema is what the migration owns.
Schema Schema
// RouterDir is the first site's generated router package directory (Site.RouterDir),
// root-relative: where the resource generator writes the release file the deploy
// reads for the maintenance window; empty when the site generator declares none.
RouterDir string
// Scheduled are the routes the code declares with @schedule, read from every site's
// release file in site then path order, each naming its site: the stack gives each
// a Cloud Scheduler job per environment on its site's hostname (scheduler.tf). None
// when the code declares none.
Scheduled []ScheduledRoute
// FileRoutes are the routes that carry a file rather than JSON, read from every
// site's release file in site then path order, a route listed once: each @upload
// method's route and each stored file's read route. Cloud Armor, where an
// environment turns it on, matches each ahead of its rules (cloud-armor.tf). None
// when the code declares neither.
FileRoutes []FileRoute
// Surfaces are the first site's surfaces, the ones the code declares a request log
// word or a trace setting for, in prefix order, and RequestLog the request log's
// exclusion the stack renders from their words (logging.tf): nil when no surface's
// word excludes an entry, and then the stack renders none. A sites-layout
// application's other sites carry their own (Site.Surfaces, Site.RequestLog), each
// scoped to its services and backend.
Surfaces []Surface
RequestLog *RequestLogExclusion
// ShippedPrograms are the command programs the generator programs declare on a
// machine outlet, read from every site's release file, by directory: the image build
// compiles each for its platforms into the image (the Dockerfile's PROGRAMS build
// argument), and the outlet serves the binaries to the installed copies. None when
// the code ships none.
ShippedPrograms []ReleaseProgram
// Outlets are the sites' router outlets as the generator programs declare them, the
// first site's first and the default of each first, a prefix listed once: the URL
// spaces the routes carrying JSON input live under, which Cloud Armor's rule sets
// are scoped to.
Outlets []Outlet
// SignInRoutes are the generated router's routes that take a sign-in credential by
// POST, read from every site's outlets in site then outlet order, a route listed
// once (signin.go): each session outlet's password login, where its auth registers
// the password method, and its pending sign-in's confirmation and cancel. Cloud
// Armor, where an environment turns it on, throttles each by client address
// (cloud-armor.tf). None when no outlet binds an auth.
SignInRoutes []SignInRoute
// Firestore is what the application's Firestore database carries beyond the
// database itself (the composite indexes, the time-to-live policies and the security
// rules the files beside the schema migrations declare), or nil when the code
// declares no database.
Firestore *Firestore
// FileStores are the Cloud Storage buckets the file-store variables declare, in
// declaration order: the default store (APP_FILE_STORE) and the named ones
// (APP_FILE_STORE_<NAME>); none when the code declares no store.
FileStores []FileStore
// ImageInputs is what the seeded Dockerfile copies into its build stages by name:
// the Go package directories and each browser workspace's install files.
ImageInputs ImageInputs
// Environments are the placement's environments, with the hostnames every site
// serves in each, the first site's first and each site's canonical first
// (Site.Environments has one site's).
Environments []Environment
// Placement is the placement the model was derived for.
Placement *Placement
}
Model is the infrastructure model of one application in one placement.
func (*Model) ByRoleAtLevel ¶
ByRoleAtLevel is the variable in the role at the level, or nil.
func (*Model) DirectoryMethods ¶
DirectoryMethods lists every directory method of every auth, auths by name, methods in registration order.
func (*Model) MultiSite ¶
MultiSite reports a sites-layout application with more than one site: every per-site resource carries the site's name, and the pipeline deploys each site's service.
func (*Model) Personas ¶
Personas lists every persona method of every auth, auths by name, methods in registration order.
func (*Model) RetirementOutOfReach ¶ added in v0.1.2
RetirementOutOfReach says why no version of the versioned secret can be retired, empty when one can. A retirement has the migrate command rewrite every stored value that names the version, at the levels that command constructs: the stack hands it the versioned secrets declared at those levels and grants the deploy identity, which runs it, their containers alone. A versioned secret declared at another level never reaches the command, which holds nothing written under it to rewrite or to confirm.
func (*Model) RouterDirs ¶
RouterDirs lists the sites' generated router package directories, in site order, a site without one left out: where the release files are.
type OldestAnswered ¶
type OldestAnswered struct {
// Release is the release, as the file writes it (1.5.0); empty when This is set.
Release string
// This says the outlet answers the server's own release alone.
This bool
// Outlet is the outlet that declares it.
Outlet string
}
OldestAnswered is the newest value over the session outlets of what each outlet answers at the oldest: the one the maintenance window is decided by, with the outlet that declares it.
func (OldestAnswered) Newer ¶
func (o OldestAnswered) Newer(b OldestAnswered) bool
Newer reports whether o answers a newer release at the oldest than b: across the sites of an application, the newest decides whether a release is breaking.
func (OldestAnswered) String ¶
func (o OldestAnswered) String() string
String says what the outlet answers, for a log line.
type Opening ¶
type Opening struct {
Open bool
From time.Time
To time.Time
// Slot names the slot: the weekly one with its zone, the date of a dated one, or
// anytime.
Slot string
}
Opening is what a window says at one moment: open now, in a slot that runs from From to To, or closed, with the next slot's bounds (zero when no slot lies ahead).
type Outlet ¶
Outlet is one router outlet of the site: its name and the prefix its routes live under (api, portal/api).
type Outlier ¶
type Outlier struct {
ConsecutiveErrors int
EnforcingConsecutiveErrors int
MaxEjectionPercent int
IntervalSeconds int
BaseEjectionSeconds int
}
Outlier is the thresholds a backend service is rendered with: the placement's where it sets them, the defaults elsewhere.
func DefaultOutlier ¶
func DefaultOutlier() Outlier
DefaultOutlier is the thresholds of a placement that sets none.
type OutlierDetection ¶
type OutlierDetection struct {
// ConsecutiveErrors is how many errors in a row (a 5xx answer, or a request that
// gets none) eject a region's endpoint group: at least 1, default 5.
ConsecutiveErrors *int `json:"consecutiveErrors,omitempty"`
// EnforcingConsecutiveErrors is the chance, in percent, that a group that reaches
// ConsecutiveErrors is ejected: 1 to 100, default 100, every detection.
EnforcingConsecutiveErrors *int `json:"enforcingConsecutiveErrors,omitempty"`
// MaxEjectionPercent is the most of the backend's groups out at once, in percent: 1
// to 100, default 50, one region of two.
MaxEjectionPercent *int `json:"maxEjectionPercent,omitempty"`
// IntervalSeconds is how often, in seconds, the load balancer looks at the counts,
// ejecting groups and returning those whose time is up: at least 1, default 1.
IntervalSeconds *int `json:"intervalSeconds,omitempty"`
// BaseEjectionSeconds is how long, in seconds, a group stays out the first time;
// each further ejection multiplies it by the number of times the group was ejected:
// at least 1, default 30.
BaseEjectionSeconds *int `json:"baseEjectionSeconds,omitempty"`
}
OutlierDetection is a placement's outlier detection thresholds (outlierDetection): each field the placement leaves out takes its default, and a field written is a whole number that keeps detection on (none may be zero, which would turn the ejection off).
func (*OutlierDetection) Clone ¶
func (o *OutlierDetection) Clone() *OutlierDetection
Clone is a copy that shares nothing with o; nil stays nil.
func (*OutlierDetection) Resolved ¶
func (o *OutlierDetection) Resolved() Outlier
Resolved is the thresholds with the defaults in place of every field left out; a nil OutlierDetection is the defaults.
func (*OutlierDetection) Validate ¶
func (o *OutlierDetection) Validate() error
Validate refuses a threshold written outside what keeps detection on: a count or a time below 1, a percentage outside 1 to 100. Nothing written is the defaults.
type PersonaPlacement ¶
PersonaPlacement is the persona provider's place in the application: the provider's issuer URL, where the browser is sent to sign in as a persona, and the application's client ID root at the provider, which each deployment's client ID is built from.
func (*PersonaPlacement) Validate ¶
func (p *PersonaPlacement) Validate() error
Validate checks the block: an https issuer URL with a host and no query or fragment, and a client ID root in its shape. A nil block is valid: no persona provider.
type Placement ¶
type Placement struct {
// Prefix is the organization's naming prefix: every resource name starts with
// <prefix>-<env>.
Prefix string `json:"prefix"`
// Code is the application's code: the segment every resource name of the
// application carries, one to six lowercase letters and digits starting with a
// letter (ApplicationCodePattern), declared at registration (bedrock org register)
// and the organization's naming decision. A placement written before the code was
// recorded names none: the repository's name stands in for it, the two having
// coincided then, and bedrock upgrade writes it.
Code string `json:"code,omitempty"`
// Hostnames are what the application's sites answer on, by site name (the directory
// under apps/ in impulse's sites layout, the module path's last element in the flat
// layout): the site's label under the apps domain, one DNS label
// (HostnameLabelPattern) the stack serves as <label>-<env> below production, the bare
// <label> in production, <label>-next for the next revision and <label>-pr<N> for a
// pull-request stack, whose Cloud Run service carries the same name; and, per
// environment, the hostnames the site answers on besides, on a vanity domain the
// organization declares (SiteHostnames.Vanity). Written
// as the label alone ("console": "pp-console") or as an object with the label and the
// vanity hostnames. A site left out keeps the default label, the code (in the sites
// layout the code, a hyphen and the site's name), so the code is in a URL by default
// alone and stays the identifier every resource name carries. The organization
// records the hostnames the stack serves and refuses one another application has or
// one under no domain it declares (bedrock org register --next, bedrock org
// hostnames).
Hostnames map[string]SiteHostnames `json:"hostnames,omitempty"`
// Environments are the environments the application is placed in, in promotion
// order, a prefix of the organization's: the first is where pull requests deploy, and
// the release line ends at the last.
Environments []string `json:"environments"`
// ProductionEnvironment is the organization's production environment, the last of
// its promotion order: the one the hostnames' bare label belongs to, and the one the
// environments between the first and it restore their databases from. The application
// is placed there when Environments ends with it. Absent, the last of Environments, as
// a placement written before an application could be placed in a prefix reads.
ProductionEnvironment string `json:"productionEnvironment,omitempty"`
// Regions are the Cloud Run regions; the first is primary.
Regions []Region `json:"regions"`
// AppsDomain is the domain the applications' hostnames hang under.
AppsDomain string `json:"appsDomain"`
// HostedDomain is the Google Workspace domain the directory auths restrict logins to.
HostedDomain string `json:"hostedDomain"`
// StateBucket is the state bucket every backend block names.
StateBucket string `json:"stateBucket"`
// PlaceholderImage is the image every service and job is created with, before the
// first deploy.
PlaceholderImage string `json:"placeholderImage"`
// DefaultBranch is the branch pull requests target.
DefaultBranch string `json:"defaultBranch"`
// Repository is the application repository's name, the module path's last segment
// (a module under github.com is its repository), for the source_repo label.
Repository string `json:"repository"`
// ReleaseApp is the slug of the GitHub App that cuts the releases (release-please
// runs as it): the pipeline accepts a release tag only from a GitHub Release it
// authored, and the repository's rules let it alone create one; not even an admin
// may bypass them.
ReleaseApp string `json:"releaseApp"`
// BedrockVersion is the bedrock the pipeline and the stack's triggers run, one of two
// kinds of pin. A release (v0.4.0: the tag v0.4.0 of
// github.com/impulseframework/bedrock) comes with BedrockSHA256, the SHA-256, in hex, of that
// release's linux/amd64 binary, which both download and verify before running it. A
// commit pin (v0.0.0-lab.1.0.20260928222237-58b211dce544: the pseudo-version the Go
// module proxy gives a pushed commit of the bedrock module) comes with no checksum:
// both build it with go install, and Go's checksum database verifies it. The one place
// a bedrock version appears in the application: bedrock upgrade moves the pin, never a
// hand edit in a rendered file. Both empty, the placement is unpinned, which render and
// check refuse.
BedrockVersion string `json:"bedrockVersion"`
BedrockSHA256 string `json:"bedrockSha256"`
// Labels are labels the organization puts on every resource, beside the ones the
// stack derives.
Labels map[string]string `json:"labels,omitempty"`
// Persona names the persona provider the first environment and its pull requests sign
// in through when an auth registers the persona method (impulse add method persona):
// the provider's issuer URL and the application's client ID root, both from the
// provider's registration of the application. The stack sets the issuer on the served site in
// the first environment and its pull requests alone (the method is registered where
// the issuer is set and nowhere else), derives each deployment's client ID from the
// root (<root>-pr<N> for a pull request, <root>-<first environment> for the
// environment) and the callback from the canonical hostname, and the pipeline
// registers each deployment, its callback and its cast with the provider after
// traffic and removes a torn-down pull request's. Absent, no auth may register the
// method; present, one must (render and check refuse the mismatch either way).
Persona *PersonaPlacement `json:"persona,omitempty"`
// Seed lists the environments whose database takes the development seed
// (schema/devseed, as data migrations tracked apart from the schema) at a release
// build, after the schema migrations. Absent, none: a database holding data is
// never seeded unless the placement says so. A pull-request environment is always
// seeded, its database being new; production never.
Seed []string `json:"seed,omitempty"`
// Approvals lists the environments whose version trigger waits for a person's
// approval in Cloud Build before a release runs there. Absent, every environment
// but the first.
Approvals []string `json:"approvals,omitempty"`
// ReleaseBackups lists the environments whose release builds start, before their
// migrations, a Spanner backup of the database as of that moment (the cut), kept
// fourteen days: what bedrock rollback restores when a release goes wrong there, and
// the environments the command serves. Absent, production alone.
ReleaseBackups []string `json:"releaseBackups,omitempty"`
// SpannerRetention is how far back Spanner keeps each environment's row versions, by
// environment name, as Spanner spells a duration ("7d", "36h"): how far back a backup
// as of a moment and a point-in-time rollback can reach, between one hour and seven
// days. An environment it does not name keeps seven days, the most Spanner allows.
SpannerRetention map[string]string `json:"spannerRetention,omitempty"`
// BuildMachine is the Cloud Build machine the pipeline's builds run on, by the name
// cloudbuild.yaml's options.machineType takes (E2_HIGHCPU_8); absent, Cloud Build's
// default. The machine is a build-level option: the whole run is on it, a window
// release's wait included, and no step has a machine of its own. The image step is
// what a larger machine shortens: its compile and its bundle build run fresh in every
// environment, the registry's layer cache holding the downloads alone. The number of
// builds a project runs at once on it is its CPU quota for Cloud Build's default pool
// divided by the machine's vCPUs (Machines), a quota Cloud Build sets per project and
// never raises, so nothing here reads it.
BuildMachine string `json:"buildMachine,omitempty"`
// BuildArguments are the values the stack makes that the image build takes as build
// arguments, by the argument's name as the application's Dockerfile declares it with
// ARG (FIREBASE_API_KEY), each naming one value of the catalog bedrock knows
// (BuildValues: the Firebase web API key, the Firestore database's id, the environment
// project's id, the environment's name, the canonical hostname). The stack carries
// each on its triggers as _BUILD_ARG_<NAME>, from its own resources, and the image
// build passes it as --build-arg NAME=value: a value that exists only once the stack
// is applied, which no person can write per environment. Absent, none.
BuildArguments map[string]string `json:"buildArguments,omitempty"`
// MaxInstances is the most Cloud Run instances the service may run per region, by
// environment name: a cap that bounds what the environment can cost when traffic
// rises. An environment it does not name has no cap of the placement's, and Cloud
// Run's own default applies there. Absent, none has a cap.
MaxInstances map[string]int `json:"maxInstances,omitempty"`
// OutlierDetection is the backend service's outlier detection thresholds, how the
// load balancer takes a failing region out (outlier.go); a field left out, or the
// whole block, takes its default.
OutlierDetection *OutlierDetection `json:"outlierDetection,omitempty"`
// CloudArmor is the Cloud Armor policy the stack renders on its backend services
// (armor.go): the rule sets in order at their sensitivities, the fields a set leaves
// alone, and the paths allowed ahead of the sets beside the ones derived from the
// generated router. An environment turns the policy on in terraform.tfvars; a block
// left out is the default rule sets with no exclusion and no bypass.
CloudArmor *CloudArmor `json:"cloudArmor,omitempty"`
// Maintenance is each environment's maintenance window by environment name: the
// time the environment may take a release that interrupts service (a breaking
// release, whose oldest answered release is newer than the one the environment runs,
// deploys behind the maintenance page inside it; under releases all, every release
// waits for it). Written as "anytime" or as the client's windows (maintenance.go).
// Every environment but production is anytime unless written; production has no
// default, and a breaking release to it is refused until its setting is written.
Maintenance map[string]MaintenanceWindow `json:"maintenance,omitempty"`
// MaintenanceWindow is the application's routine maintenance window as the team
// declares it, a value for the team: when its patch releases are made, by whom and
// under what approval is the team's configuration, never the framework's. bedrock
// carries the value and bedrock patch status prints it; nothing in the framework
// acts on it. (Maintenance, above, is the environments' release windows.)
MaintenanceWindow string `json:"maintenanceWindow,omitempty"`
// Projects are the environment projects by environment, as the organization's
// apply chose them: the id and the number (bedrock org register writes them into the
// first placement from the organization's, and org render prints the block). The
// operations workflow, which starts a restore or a rerun of an environment from
// GitHub, names the environment's workload identity provider and operations identity
// by them; an environment without an entry is not wired for it. Production's serves
// the rerun alone: it is never restored by a run.
Projects map[string]Project `json:"projects,omitempty"`
}
Placement is what the organization decided and the application cannot know: its naming prefix, its environments, its regions, its domains, and the few constants the stack restates.
func ReadPlacement ¶
ReadPlacement reads a placement from its JSON file.
func (*Placement) ApprovalEnvironments ¶
ApprovalEnvironments are the environments a release waits for approval in: Approvals as given, else every environment but the first.
func (*Placement) Armor ¶
Armor is the Cloud Armor policy the stack is rendered with: the placement's, with the defaults where it writes none.
func (*Placement) BuildArgumentNames ¶
BuildArgumentNames are the names of the declared build arguments, sorted.
func (*Placement) DefaultLabel ¶
DefaultLabel is a site's hostname label when the placement declares none: the code for the site at the module root (the flat layout), and the code, a hyphen and the site's name for a site under apps/ (the sites layout).
func (*Placement) InProduction ¶
InProduction reports whether the application is placed in production: its environments end with it. An application placed in a prefix of the promotion order is not, so no hostname of its carries the bare label and nothing restores from production's backups.
func (*Placement) Integration ¶
Integration is the environment pull requests deploy to: the first.
func (*Placement) KeepsReleaseBackups ¶
KeepsReleaseBackups says whether env's release builds start a backup as of the cut.
func (*Placement) Label ¶
Label is the site's hostname label under the apps domain: the one the placement declares for it (Hostnames), else the default.
func (*Placement) Machine ¶
Machine is the build machine the placement names and whether it names one; absent, the pipeline leaves the machine to Cloud Build's default.
func (*Placement) MaintenanceSetting ¶
func (p *Placement) MaintenanceSetting(env string) (MaintenanceWindow, bool)
MaintenanceSetting is env's maintenance setting and whether the placement writes one. Every environment but production is anytime unless its setting is written; production has no default, so a breaking release to production is refused until its setting is written, and "anytime" is a setting to write.
func (*Placement) MaxInstanceCount ¶
MaxInstanceCount is the most instances the service may run per region in env, and whether the placement caps it there; uncapped, Cloud Run's default applies.
func (*Placement) Outlier ¶
Outlier is the outlier detection thresholds the backend service is rendered with: the placement's, with the defaults where it sets none.
func (*Placement) Pinned ¶
Pinned reports whether the placement pins bedrock: a release or a commit.
func (*Placement) Previous ¶
Previous is the environment before env in the promotion order, whose live deployment record a release needs before it runs in env; empty for the first.
func (*Placement) Production ¶
Production is the organization's production environment: the placement's, else the last of the application's environments.
func (*Placement) Project ¶
Project is the environment's project as the placement records it, and whether it records one.
func (*Placement) ReleaseActor ¶
ReleaseActor is the login the release app's releases carry: <slug>[bot].
func (*Placement) ReleaseBackupEnvironments ¶
ReleaseBackupEnvironments are the environments whose release builds start a backup as of the cut, and that bedrock rollback serves: the placement's list, else production alone when the application is placed there, else none.
func (*Placement) Restorable ¶
Restorable lists the environments a run may restore: every one but production.
func (*Placement) RestoreKind ¶
RestoreKind is what a restore run replaces env's database with: production's most recent backup for an environment on production's instance (every one above the first) whose database is not seeded, an empty database otherwise, which the migrations and the seed then fill.
func (*Placement) Retention ¶
Retention is how far back Spanner keeps env's row versions: the placement's value for the environment, else seven days.
func (*Placement) SeedEnvironments ¶
SeedEnvironments are the environments whose database is seeded at a release build: the placement's seed list, none by default.
func (*Placement) SiteNameBudget ¶
SiteNameBudget is the most characters a site's name may take in this placement: what Cloud Run's limit leaves after the service name's other segments at their longest, <prefix>-<env>-<region code>-<code>-<site>-app.
func (*Placement) ValidateSiteName ¶
ValidateSiteName holds a site's name to the rule and the placement's budget.
func (*Placement) VanityDeclared ¶
VanityDeclared reports whether any site declares a vanity hostname in any environment.
type Process ¶
type Process struct {
// Name is the process's short name: app for the site, migrate for the migration.
Name string
// Dir is the root-relative directory of the main package.
Dir string
// Main is how the code names the process: main.go for the site at the root, the
// command directory otherwise.
Main string
// Levels are the configuration levels the process constructs, lowest first.
Levels []string
// H2C reports that the main package imports the framework's server (ServerPackage),
// which speaks HTTP/1.1 and h2c on one listener: for the site, the declaration the
// stack names the service's port h2c from. Another server leaves the port HTTP/1.
H2C bool
}
Process is one deployed process: the served site, the migration or the job process.
type RegistrationSetting ¶
RegistrationSetting is one setting of a directory method with the variable that carries it.
type ReleaseFile ¶
type ReleaseFile struct {
Outlets map[string]ReleaseOutlet `json:"outlets"`
// Scheduled are the routes the code declares with @schedule, in path order; none
// when it declares none.
Scheduled []ScheduledRoute `json:"scheduled,omitempty"`
// FileRoutes are the routes that carry a file rather than JSON, in path order: each
// @upload method's route and each stored file's read route (@file). The stack puts
// each ahead of Cloud Armor's rules (cloud-armor.tf). None when the code declares
// neither.
FileRoutes []FileRoute `json:"fileRoutes,omitempty"`
// Surfaces are the surfaces the code declares a request log word or a trace setting
// for, in prefix order: the application default at /, an outlet at its prefix, a
// prefix the application mounts routes under by hand, or a generated route at the
// path the router mounts it at, each saying which of the two it is (Kind). The stack
// renders the request log's exclusion from the words (logging.tf). None when the
// code declares nothing, and then every request's entry is written.
Surfaces []Surface `json:"surfaces,omitempty"`
}
ReleaseFile is the generated release file: one entry per outlet, keyed by the outlet's name (default for the outlet GenerateRoutes declares, the name given to WithRouterOutlet otherwise), and the scheduled routes.
func ReadReleaseFile ¶
func ReadReleaseFile(dir string) (*ReleaseFile, error)
ReadReleaseFile reads the release file from dir, the router package's directory of a checkout. A missing file is an error wrapping os.ErrNotExist: the application predates the file, or no router is generated there. A file that is not the shape the generator writes is refused naming what is wrong.
func (*ReleaseFile) OldestAnswered ¶
func (f *ReleaseFile) OldestAnswered() (OldestAnswered, bool)
OldestAnswered is the newest oldest-answered release over the session outlets, and whether any declares one: "this" is newer than any release, and among releases the newest wins; an API-key outlet and an outlet that answers every release count for nothing. Outlets are read by name, so equal values name the same outlet every time.
func (*ReleaseFile) Programs ¶
func (f *ReleaseFile) Programs() []ReleaseProgram
Programs lists the file's shipped programs over its outlets, by directory.
type ReleaseOutlet ¶
type ReleaseOutlet struct {
Kind string `json:"kind,omitempty"`
OldestAnswered string `json:"oldestAnswered,omitempty"`
// Programs are the command programs the outlet ships, as the generator program
// declares them: the version build compiles each for its platforms into the image,
// and the outlet serves the binaries to the installed copies, which upgrade
// themselves from it. None when the outlet ships none.
Programs []ReleaseProgram `json:"programs,omitempty"`
}
ReleaseOutlet is one outlet's entry. A session outlet carries its oldest answered release: a release such as 1.5.0, "this" for the server's own, or "" when every release that sends its version is answered. An API-key outlet carries its kind and is never checked against a release; it alone may ship programs.
type ReleaseProgram ¶
type ReleaseProgram struct {
// Name is the program's name, the last element of Dir (corral): the binary is
// served as <name>-<os>-<arch>.
Name string `json:"name"`
// Dir is the root-relative directory of the program's main package (cmd/corral).
Dir string `json:"dir"`
// Platforms are the platforms the program is compiled for, each <os>/<arch> in
// lower case (linux/amd64), at least one.
Platforms []string `json:"platforms"`
}
ReleaseProgram is one shipped program: a main package of the checkout, compiled for each of its platforms.
type RequestLogExclusion ¶
type RequestLogExclusion struct {
// Surfaces are the surfaces whose word excludes an entry, in prefix order: those
// logged on event, sampled or never. A surface logged always, or declaring its
// trace setting alone, has no clause and is not among them.
Surfaces []Surface
// Clause is the surfaces' clause of the filter, as the Logging query language reads
// it: each surface's Clause, excepting the surfaces declared beneath it, the
// several joined with OR inside one pair of parentheses.
Clause string
}
RequestLogExclusion is the request log's exclusion the stack renders for the application (logging.tf): one project-level Cloud Logging exclusion per environment, never in a pull-request stack, whose filter drops the entries the code's request log words say not to write.
Cloud Run and the load balancer each write an entry for every request the service answers, whatever the application's own logger decides, so a surface the code logs on event alone would still cost an entry per quiet request at the edge. The exclusion's filter is the scope AND the Clause here. The scope is the service's own entries, Cloud Run's by the regional services' names and the load balancer's by the backend's, and never the project's: one project holds several applications, and another application's entries are not this stack's to drop. The stack writes the scope, since it names its resources; the clause is derived here.
func NewRequestLogExclusion ¶
func NewRequestLogExclusion(surfaces []Surface) *RequestLogExclusion
NewRequestLogExclusion derives the exclusion from the surfaces, in their order: nil when no surface's word excludes an entry, and then the stack renders none, since every entry is written as it is today. Each surface's clause excepts the surfaces declared beneath it (Excepted), so an entry under a child is the child's own clause's to drop, and kept whole when the child has none, the way the application decides a request's own entry by its nearest declaration.
type Role ¶
type Role string
Role is a variable's part in the framework: the well-known variables every skeleton declares and the directory registration of an auth.
const ( RoleNone Role = "" RoleServiceName Role = "service-name" RoleLoggingProject Role = "logging-project" RoleVersion Role = "version" RoleDatabaseProject Role = "database-project" RoleDatabaseInstance Role = "database-instance" RoleDatabaseName Role = "database-name" RolePort Role = "port" RoleCookieKey Role = "cookie-key" // RoleFileStore hands a file store, a Cloud Storage bucket of the application's own, // to the processes that construct its level as a gs:// URL. RoleFileStore Role = "file-store" // RoleTasksQueue names the task queue to the processes that construct its level. RoleTasksQueue Role = "tasks-queue" // RoleFirestoreProject names the Firestore database's project to the processes that // construct its level: the environment project, where the database is. The Spanner // project is the shared instance's in an environment that shares one, so the // database's project is told on its own. RoleFirestoreProject Role = "firestore-project" // RoleFirestoreDatabase names the Firestore database to the processes that construct // its level. RoleFirestoreDatabase Role = "firestore-database" // RoleFirebaseAPIKey hands the Firebase web API key of the Firestore database to the // processes that construct its level: the key the browser presents to sign in with // the custom token the site mints. RoleFirebaseAPIKey Role = "firebase-api-key" // RoleTraceSampling tells the processes that construct its level which spans to // record: every one in a pull-request stack and in the integration environment, the // edge's choice beyond them. RoleTraceSampling Role = "trace-sampling" // RoleJobsTemplate names the job process's template job to the served site, which // reads it through the job driver's settings (JobsTemplateVariable): the stack sets // it on the service alone, and jobsTemplate holds it to the job process and its // level to the served site. RoleJobsTemplate Role = "jobs-template" // RoleSiteBundle is the sites layout's bundle variable (SiteBundleVariable): the // directory of the site's built browser bundle, which differs per site, so the stack // sets it per service to where the image holds the site's bundle. RoleSiteBundle Role = "site-bundle" // RolePublicURL hands the application's address as a browser reaches it to the // processes that construct its level: https:// and the site's canonical hostname, // which every link the auths mail (an invitation, an address verification, a // sign-up) opens the login page under; in the sites layout each site's service // carries its own. RolePublicURL Role = "public-url" // RoleMailbox is the Google Workspace mailbox the auths' mail is sent as // (APP_MAIL_MAILBOX), placed once for the organization: the stack variable // mail_mailbox, empty until the organization names one, when the application // writes its mail to the log and sends nothing. RoleMailbox Role = "mail-mailbox" // RoleMailFrom is the address the auths' mail is from when it is not the mailbox // (APP_MAIL_FROM): an alias of the mailbox's account, since Google issues no login // to an alias while the relay accepts any From address in the organization's // domains with the account's login. Placed once for the organization: the stack // variable mail_from, empty to send from the mailbox. RoleMailFrom Role = "mail-from" // RoleMailAppPassword is the mailbox's app password (APP_MAIL_APP_PASSWORD, // secret:"true"), the relay's login: a pinned secret like any other, which the // migrate command reads too, since the data level opens the sender when it is // constructed. RoleMailAppPassword Role = "mail-app-password" // The directory registration of an OIDC auth, keyed as the auth package's Directory // struct names them. RoleClientID Role = "client-id" RoleClientSecret Role = "client-secret" RoleRedirectURL Role = "redirect-url" RoleHostedDomain Role = "hosted-domain" RoleGroupPrefix Role = "group-prefix" RoleGroupLookup Role = "group-lookup" // The organization slot of a directory registration besides the hosted domain: the // Entra tenant a Microsoft registration admits, by id, or its listed tenants; the // listed Workspaces of a Google registration. RoleTenantID Role = "tenant-id" RoleTenants Role = "tenants" RoleWorkspaces Role = "workspaces" // The organizations the deployment administers among those a registration admits // (tenants by id, Workspaces by domain), whose sign-ins carry the directory's second // factor and are not asked for the sign-in code; empty where the deployment // administers none. RoleAdministeredTenants Role = "administered-tenants" RoleAdministeredWorkspaces Role = "administered-workspaces" // RoleIssuer is the persona provider's issuer URL (APP_<AUTH>_<REGISTRATION>_ISSUER // of a persona method), the stack's to set: the placement's issuer in the first // environment and its pull requests, where the persona method is registered, and // empty everywhere else, where it is not. RolePersonaClientID is the deployment's // client ID at the provider (the persona method's _CLIENT_ID): the placement's client // ID root with the pull request or the environment appended, which the stack derives, // unlike a directory registration's client ID, which the placement names per // environment. RoleIssuer Role = "issuer" RolePersonaClientID Role = "persona-client-id" // RoleProviderIssuer is the issuer URL of an organization's own identity provider // (APP_<AUTH>_<REGISTRATION>_ISSUER of an oidc method: an Okta, a Keycloak, or Google // used as a plain OpenID Connect provider), a placement variable once for the // organization, unlike the persona provider's issuer, which the stack derives. It // names the provider the way a Google registration's hosted domain or a Microsoft // registration's tenant names the directory: the provider's configuration is read // under it and every sign-in's token carries it, so another issuer is another provider, // whose people no link made so far knows. The registration refuses a missing or // malformed issuer when it is made, at construction, so every process that constructs // the level carries it. RoleProviderIssuer Role = "provider-issuer" // RoleAdministrator is the sign-in name of an auth's first administrator // (APP_<AUTH>_ADMINISTRATOR), placed per environment: the deployment's migrate command // seeds the administrator role membership under it while the auth's users table holds // no rows, so the first person to sign in through the directory holds the role. RoleAdministrator Role = "administrator" // RoleAdministratorPassword is the generated password of an auth's first administrator // (APP_<AUTH>_ADMINISTRATOR_PASSWORD, secret:"generated"): the deployment's migrate // command seeds the administrator user with it while the auth's users table holds no // rows, so the migrate command reads it, alone among the runtime secrets, and the stack // grants the deploy identity accessor on its container and on no other. RoleAdministratorPassword Role = "administrator-password" )
The roles.
func (Role) ConstructionTime ¶
ConstructionTime reports a directory role the session library reads when the method is registered on the Auth, at construction (the organization slot it validates, an identity provider's issuer whose shape it checks, the group prefix role synchronization needs), so every process that constructs the level needs it; the other directory roles are read when someone signs in, which only the served site does.
func (Role) PerEnvironment ¶
PerEnvironment reports a placed role whose value differs per environment (a registration in the environment's project, the person who administers the environment first) rather than once per organization.
type Route ¶
type Route struct {
Method string
Path string
// File is the root-relative file registering the route.
File string
}
Route is one registered route.
type RuleSet ¶
RuleSet is one preconfigured rule set the policy evaluates, by the name Cloud Armor gives it (KnownRuleSets), at a sensitivity from 1 (the rules least likely to misfire) to 4 (every rule).
func DefaultRuleSets ¶
func DefaultRuleSets() []RuleSet
DefaultRuleSets are the rule sets of a placement that writes none: the reference deployment's five, scanner detection, SQL injection, SQL injection in JSON bodies, cross-site scripting and protocol attacks, at sensitivity 1.
type ScheduledRoute ¶
type ScheduledRoute struct {
// Site is the site whose router declares the route, set when the file is read: the
// job calls the route on that site's hostname. Not in the file.
Site string `json:"-"`
// Path is the route, ScheduledPrefix/<name>.
Path string `json:"path"`
// Schedule is the cron expression, five fields (minute, hour, day of the month,
// month, day of the week), as the code declares it.
Schedule string `json:"schedule"`
// TimeZone is the IANA time zone the schedule is read in, UTC when the code names
// none.
TimeZone string `json:"timeZone"`
}
ScheduledRoute is a method the code declares with @schedule: Cloud Scheduler calls it with POST on its schedule, a cron expression read in the time zone.
func (*ScheduledRoute) Name ¶
func (r *ScheduledRoute) Name() string
Name is the route's name, the path's segment after ScheduledPrefix: the method's name in kebab case, which names its Cloud Scheduler job.
type Schema ¶
type Schema struct {
// MigrationsDir is the root-relative directory of the schema migrations.
MigrationsDir string
// MigrateCall names the function the migration calls to apply them, as a reader
// would: <package dir> <function>.
MigrateCall string
// GenerateDir is the root-relative directory holding the //go:generate directive
// that runs the site generator, and GeneratePackage that file's package: where
// bedrock's generate-time step (the migration renumber) goes, in a file that sorts
// before the application's so it runs first. Both empty when no directive runs
// the generator (impulse check reports that).
GenerateDir string
GeneratePackage string
}
Schema is what the migration owns.
type Secret ¶
type Secret struct {
Variable *Variable
// Name is the secret container's name segment: the variable without its APP_ prefix,
// in kebab case.
Name string
// Generated reports a value the tooling makes (secret:"generated" or
// secret:"versioned"): the placement carries the tag's word for it, never a version
// number. Versioned reports the second: every enabled version reaches the processes.
Generated bool
Versioned bool
}
Secret is one variable that holds a credential.
type SignInRoute ¶
type SignInRoute struct {
// Outlet is the outlet whose route it is, and Site the site serving that outlet.
Outlet string
Site string
// Method is the HTTP method the route answers, POST for every sign-in route.
Method string
// Path is the route as the router mounts it, under the outlet's prefix
// (/api/user/password/login).
Path string
// Kind is SignInPassword, SignInConfirm or SignInCancel.
Kind string
}
SignInRoute is one route of the generated router that takes a sign-in credential by POST: a session outlet's password login, or one of its pending sign-in's completion routes. Cloud Armor, where an environment turns it on, throttles each by client address.
func (*SignInRoute) Declaration ¶
func (r *SignInRoute) Declaration() string
Declaration says what the route is, for a rule's description: the outlet's password login, or its pending sign-in's confirmation or cancel.
type Site ¶
type Site struct {
// Name is the site's name: the directory under apps/ in the sites layout, the
// module path's last element in the flat layout. In the sites layout it names the
// process, the binary (/<name>) and the per-site resources.
Name string
// Dir is the root-relative directory of the site's main package: apps/<name>, or "."
// in the flat layout.
Dir string
// Label is the site's hostname label under the apps domain: the one the placement
// declares for it (Placement.Hostnames), else the default, the code alone in the
// flat layout and <code>-<name> in the sites layout.
Label string
// Process is the site as a deployed process: its levels and whether it speaks h2c.
Process
// Outlets are the site's router outlets, the default first: the URL spaces its
// routes carrying JSON input live under.
Outlets []Outlet
// SignInRoutes are the site's sign-in routes, the ones under its session outlets
// that take a credential by POST (signin.go), in outlet order: each session
// outlet's password login and its pending sign-in's completion routes.
SignInRoutes []SignInRoute
// RouterDir is the root-relative directory of the site's generated router package,
// where the release file is; empty when its generator declares none.
RouterDir string
// Scheduled, FileRoutes and Surfaces are the site's, read from its release file;
// RequestLog the exclusion derived from its surfaces, nil when none excludes.
Scheduled []ScheduledRoute
FileRoutes []FileRoute
Surfaces []Surface
RequestLog *RequestLogExclusion
// Environments are the placement's environments with the hostnames the site serves
// in each, the canonical first.
Environments []Environment
// Bundle is the site-level variable the stack sets per service to the directory the
// site serves its built browser bundle from in the sites layout (RoleSiteBundle).
// Nil in the flat layout, where the image sets the bundle variables itself, and for
// a site without a browser workspace; the directories below are empty with it.
Bundle *Variable
// Workspace is the root-relative browser workspace under the site's directory
// (apps/console/web), the directory holding angular.json and package.json: where
// the image installs and builds.
Workspace string
// BundleDir is the root-relative directory the site serves its bundle from, which
// the stack sets Bundle to under the image's working directory
// (apps/console/web/dist/console): the one the site's process line in the Procfile
// sets (ProcfileBundleDir), else the one the workspace's build writes (OutputDir).
// Always under Workspace, since the image copies it out of the workspace's build.
BundleDir string
// ProcfileBundleDir is the directory the site's process line in the Procfile sets
// Bundle to for development, as written; empty when no line sets it.
ProcfileBundleDir string
// OutputDir is the root-relative directory the workspace's build writes the site's
// bundle to, read from angular.json's outputPath (bundleOutput); empty when
// angular.json names no single application project.
OutputDir string
}
Site is one served site: a main package the image builds into a binary of its own and the stack runs as a Cloud Run service per region. A solo application has one, named app as the process; a sites-layout application has one per directory under apps/, each named after its directory (console, portal), and every per-site resource of the stack carries the name as its second segment.
type SiteHostnames ¶
type SiteHostnames struct {
Label string `json:"label,omitempty"`
Vanity map[string][]string `json:"vanity,omitempty"`
}
SiteHostnames is what one site answers on: its hostname label under the apps domain, empty for the default, and the vanity hostnames it serves per environment, on a vanity domain the organization declares (vanityDomains in its placement, delegated to its network project or kept at the customer's DNS provider) and 2-net holds the certificate of: the domain itself for one site of the application, a label of it (console.<domain>) for the others. In an environment that names them, the first declared is the site's canonical hostname there (the sign-in callbacks, the build argument hostname, the scheduler's calls and the pipeline's _HOSTNAME derive from it), and the apps-domain hostname follows and keeps answering; the next revision's -next twin and a pull-request stack's hostname stay on the apps domain, where the wildcard certificate is. Any environment may declare them; in practice production does.
func (SiteHostnames) MarshalJSON ¶
func (h SiteHostnames) MarshalJSON() ([]byte, error)
MarshalJSON writes a site's entry as the label alone when it declares no vanity hostname, so a placement written before vanity hostnames existed reads back as it was.
func (*SiteHostnames) UnmarshalJSON ¶
func (h *SiteHostnames) UnmarshalJSON(data []byte) error
UnmarshalJSON reads a site's entry as the label alone, a string, or as the object.
func (SiteHostnames) VanityHostnames ¶
func (h SiteHostnames) VanityHostnames(env string) []string
VanityHostnames are the site's vanity hostnames in the environment, in the order declared; none when the site declares none there.
type Supply ¶
type Supply int
Supply is where a running process gets a variable's value.
const ( // SupplyDerived is set by the stack from a fact it derives: the service name, the // logging project, the database identity, the login callback. SupplyDerived Supply = iota // SupplyPlacement is set by the stack from a placement variable. SupplyPlacement // SupplySecret is mounted from Secret Manager at a pinned version. SupplySecret // SupplyImage is baked into the image by the Dockerfile. SupplyImage // SupplyPlatform is set by Cloud Run itself. SupplyPlatform // SupplyDefault is left to the code's default. SupplyDefault // SupplyUnknown is a variable with no role, no default, and no other supplier: the // stack cannot say where its value comes from. SupplyUnknown )
The supplies.
type Surface ¶
type Surface struct {
// Prefix is the path as mounted: a prefix such as /beacons/ or /portal/api/, a
// route pattern such as /api/widgets/{id}/content, where a segment in braces stands
// for any one segment, or / for the application default.
Prefix string `json:"prefix"`
// Kind says how the router matches the prefix against a request's path, and so how
// the exclusion's clause matches the request's URL: SurfacePrefix by prefix, so
// everything under /beacons/ is the surface's; SurfaceRoute to the end of the path,
// so /api/widgets/{id}/content is the surface's and /api/widgets/{id}/content-extra
// is not. The application default, an outlet and a hand-mounted prefix are prefixes;
// an annotated method's route is a route. A file written before the surfaces carried
// their kind reads as prefixes throughout, which is how every surface was matched
// then.
Kind string `json:"kind,omitempty"`
// Log is the request log word: RequestLogAlways, RequestLogOnEvent,
// RequestLogSampled or RequestLogNever; empty when the surface declares its trace
// setting alone.
Log string `json:"log,omitempty"`
// Fraction is the share of the quiet requests a sampled surface writes the entry
// for, above 0 and at most 1; set with RequestLogSampled alone.
Fraction float64 `json:"fraction,omitempty"`
// Traces is the trace setting: TracesFollowFrontEnd, TracesCapped or TracesOff;
// empty when the surface declares its request log word alone.
Traces string `json:"traces,omitempty"`
// Rate is the share of the front end's traces a capped surface keeps, above 0 and
// at most 1; set with TracesCapped alone.
Rate float64 `json:"rate,omitempty"`
}
Surface is one declared surface of the release file: a path prefix or a route pattern as the router mounts it, with its request log word, its trace setting, or both. The stack reads the word alone: the trace setting is the tracer's.
func (*Surface) Beneath ¶
Beneath reports whether the surface sits beneath the other: its prefix starts with the other's and is longer, so every request the other's clause matches by its path, this one's matches too. The rule is the router's for a prefix, a plain prefix of the request's path (strings.HasPrefix, in logger.PolicyByPrefix for a hand-mounted prefix and in the generated router's outletRequestLog for one beneath an outlet), held on the prefixes as the release file spells them: an outlet's and a hand-mounted prefix end in a slash, so /api/ is beneath / and /apix/ is not beneath /api/, and a route is beneath the prefix it is mounted under. A surface is not beneath itself.
func (*Surface) Clause ¶
Clause is the surface's clause of the exclusion's filter, by its word, excepting the surfaces given. Every clause matches the request's URL against the surface's prefix as a regular expression anchored after any host (^https://[^/]+<prefix>, urlMatch): the environment's hostnames and the next revision's all reach the same service, and the word is the path's, not the host's. Each excepted surface's match is then negated (AND NOT httpRequest.requestUrl =~ "^https://[^/]+<its prefix>"), in their order, so an entry under it is the excepted surface's own clause's to drop, or kept whole when it has none. On event drops the entry of a request that answered below 400, since the infrastructure cannot know whether a line attached and keeps every failure; sampled drops the same but the declared fraction of them, decided by the entry's insertId; never drops every entry under the prefix. Always has no clause, so the method is not called for it (Excludes).
func (*Surface) Excepted ¶
Excepted lists the surfaces the surface's clause excepts, in the surfaces' order: every surface beneath it that declares a word, whatever the word, since the nearest declaration decides a request's entry and a grandchild's is nearer still. A surface declaring its trace setting alone keeps the word declared above it, so it stays under the clause.
type Variable ¶
type Variable struct {
// Name is the environment variable.
Name string
// Level is the configuration level the variable is declared at.
Level string
// Struct is the struct declaring the field.
Struct string
// Field is the field's name.
Field string
// File and Line locate the field.
File string
Line int
// Type is the field's Go type, as written.
Type string
// Required reports the tag's required option.
Required bool
// Default is the tag's default value; HasDefault reports whether one is set.
Default string
HasDefault bool
// Doc is the field's doc comment, or empty.
Doc string
// Role is the variable's part in the framework, when it has one.
Role Role
// Image reports that the container image sets the variable (a Dockerfile ENV), so no
// deploy step does.
Image bool
// Secret reports that the variable holds a credential: the field carries the
// secret tag, secret:"true", secret:"generated" or secret:"versioned". Generated
// reports the last two: a value the tooling makes (32 random bytes, base64) and nobody
// types, whose versions the pipeline derives at each build. Versioned reports the
// last alone: every enabled version of the secret reaches the processes, each under
// a variable of its own (VersionVariable), where a generated secret's newest alone
// does, under the variable's name. SecretTag is the tag's value as written, or empty.
Secret bool
Generated bool
Versioned bool
SecretTag string
}
Variable is one environment variable the code reads, with where a running process gets its value.
func (*Variable) Declaration ¶
Declaration is the field as a reader of the code would name it: <struct>.<field>.
type WeeklySlot ¶
WeeklySlot is a slot that opens every week: on a day, from a time of day to another. A slot whose to is not after its from crosses midnight and ends the next day.
type WorkspaceInputs ¶
type WorkspaceInputs struct {
Dir string
// Files are the manifest and the lockfile (package.json, bun.lock) always, and the
// install's configuration files (bunfig.toml, .npmrc) when the workspace has them.
Files []string
}
WorkspaceInputs is one browser workspace's install: its root-relative directory and the root-relative files bun install reads there.