org

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 38 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package org renders an organization foundation: the six layers of the CCC provisioning model (the bootstrap, the organization, the shared registry, the shared Spanner instance, the network, and the environments) from an organization placement, the way the application stack is rendered from an application; or, for a root organization (zones.go), the bootstrap and the one layer that holds its DNS zones. The layers' .tf files and their READMEs are owned and rewritten on every render; each layer's terraform.tfvars, the journal and the ignore rules are seeded once and then a person's.

Index

Constants

View Source
const (
	PermissionActions        = "actions"
	PermissionAdministration = "administration"
	PermissionChecks         = "checks"
	PermissionContents       = "contents"
	PermissionDeployments    = "deployments"
	PermissionEnvironments   = "environments"
	PermissionIssues         = "issues"
	PermissionMetadata       = "metadata"
	PermissionPullRequests   = "pull_requests"
	PermissionWorkflows      = "workflows"
	PermissionOrgAdmin       = "organization_administration"
	PermissionOrgVariables   = "organization_actions_variables"
	PermissionOrgRunners     = "organization_self_hosted_runners"
	PermissionOrgSecrets     = "organization_secrets"

	LevelRead  = "read"
	LevelWrite = "write"
)

GitHub's names of the permissions the apps hold, as the app's own record and a manifest carry them, and the two levels.

View Source
const (
	// OwnerRole is the role a project's creator receives on it.
	OwnerRole = "roles/owner"
	// FolderAdminRole is one of the two roles a folder's creator receives on it; the
	// break-glass account keeps it on the organization's folder.
	FolderAdminRole = "roles/resourcemanager.folderAdmin"
	// FolderEditorRole is the other role a folder's creator receives on it.
	FolderEditorRole = "roles/resourcemanager.folderEditor"
	// BigQueryAdminRole is the role the break-glass account keeps on a root
	// organization's root project for the billing export's console step
	// (BreakGlassProjectRoles).
	BigQueryAdminRole = "roles/bigquery.admin"
	// ServiceUsageConsumerRole is the role the break-glass account keeps on a root
	// organization's root project for the quota its checks bill to it
	// (BreakGlassProjectRoles).
	ServiceUsageConsumerRole = "roles/serviceusage.serviceUsageConsumer"
)
View Source
const (
	OnProject = "project"
	OnFolder  = "folder"
)

The two kinds of place a leftover grant sits on.

View Source
const (
	RootEnvironment          = "bedrock"
	InfrastructureKeySecret  = "BEDROCK_INFRASTRUCTURE_APP_KEY" //nolint:gosec // a secret's name, never its value
	ReleaseClientIDOrgSecret = "RELEASE_PLEASE_APP_CLIENT_ID"
	ReleaseKeyOrgSecret      = "RELEASE_PLEASE_APP_PEM"
	ReleaseLoginVariable     = "RELEASE_APP_LOGIN"
	// ReleaseKeyVersionVariable names the Secret Manager version the release app's key
	// was sealed into its organization secret from, in a root organization with a cloud:
	// GitHub never gives a secret's value back, so the version is what the apply compares
	// with the placement's pin.
	ReleaseKeyVersionVariable = "RELEASE_PLEASE_APP_PEM_VERSION"
)

What the engine keeps on GitHub for a root organization's workflows, by the names the workflows read them under. The infrastructure app's private key, in a root organization without a cloud, is a secret of an environment of the root repository, which admits the default branch alone: the root's own workflow mints its token from it, and a workflow on any other branch is never handed it. The release app's client ID and private key are organization secrets the library repositories alone read, from which a library's release workflow mints the token release-please cuts its releases with. The release app's login is an organization variable, the author a release workflow accepts a release from.

View Source
const (
	WorkflowFile = ".github/workflows/bedrock.yml"
	PlanJobName  = "bedrock plan"
	ApplyJobName = "bedrock apply"
	CheckJobName = "bedrock check"
)

The workflow bedrock renders into the repository of a root organization without a cloud, and its jobs by the names a pull request and the ruleset show them under: the plan a pull request must pass, and the apply a merge runs.

View Source
const (
	EntitlementSecretOperator     = "secretOperator"
	EntitlementSpannerAdmin       = "spannerAdmin"
	EntitlementSpannerViewer      = "spannerViewer"
	EntitlementLayerAdministrator = "layerAdministrator"
)

The environments' entitlements, by the key placement.json names each under (entitlementDurations): the secret operator (bedrock secret add and pin), the Spanner admin and viewer of the environment's databases, and the layer administrator, who holds 2-env's apply identity's roles for a recovery (with the layer state entitlement, its slot in the state bucket, for the same longest grant). Each has a default longest grant, and Privileged Access Manager admits a longest grant between 30 minutes and 7 days.

View Source
const (
	RegistrationIdentities = "identities"
	RegistrationGrants     = "grants"
)

The steps of an application's registration (Placement.Registration): identities, while its repository and its identities are declared and its grants and hostnames are not rendered yet; grants, while the grants on its identities are declared too and its hostnames are not. A registration that is complete has no step.

View Source
const (
	ReleaseKind = "release"
	CommitKind  = "commit"
)

The two kinds of pin, which the shape of the triggers' steps follows: a release pin renders the fetch step alone, a commit pin the fetch and build steps.

View Source
const (
	HostingKind = "hosting"
	RootKind    = "root"
)

The kinds of organization a placement describes (Placement.Kind): hosting, the default, which holds applications in its environments; and root, which holds the GitHub Apps' keys, the zones of the domains delegated to it and the records of the hosting organizations it creates.

View Source
const (
	// InfrastructureKey is the infrastructure GitHub App's private key: the secret a
	// root organization's bootstrap creates in its root project, the version its alias
	// points at pinned in that placement.json (githubInfrastructureKeyVersion), from
	// which a run of the triggers in every organization mints its second layer's GitHub
	// token.
	InfrastructureKey = "github-infrastructure-key"
	// DeployerKey is the deployer GitHub App's private key, held the same way
	// (githubDeployerKeyVersion in the root organization), from which the plan trigger's run posts the layers'
	// plans and every application's pipeline talks back on a pull request.
	DeployerKey = "github-deployer-key"
	// ReleaseKey is the release GitHub App's private key, held the same way
	// (githubReleaseKeyVersion), from which each application's release trigger in a
	// hosting organization mints the token release-please cuts the releases with.
	ReleaseKey = "github-release-key"
	// Token is the GitHub Bot Account's token: the secret a root organization's bootstrap
	// creates in its root project (<prefix>-root-gbl-github-token), the version its alias
	// points at pinned in that placement.json (githubTokenVersion), which every Cloud
	// Build connection in every organization authorizes with.
	Token = "github-token"
	// PlacementFile is the organization placement at the repository root.
	PlacementFile = "placement.json"
)

The organization's secrets, by the name the commands take.

View Source
const (
	PlanCommand  = "plan"
	ApplyCommand = "apply"
)

The two commands the triggers end in, and the environment they read the build from.

View Source
const DNSCustomer = "customer"

DNSCustomer is the dns value of a vanity domain kept at the customer's DNS provider.

View Source
const ExportDataset = "billing"

ExportDataset is the dataset in the root project the billing account's export lands in: every charge by project, service, SKU and label, from which cost is reported by application, environment or organization. Google has no API for pointing an account's export at a dataset: a person does, once per billing account, in the Billing console.

View Source
const FirebaseBrowserKey = "Browser key (auto created by Firebase)"

FirebaseBrowserKey is the display name Firebase gives the API key it creates in a project when Identity Platform is initialized there.

View Source
const KeyAlias = "current"

KeyAlias is the version alias every reader of a key names in place of a number (projects/<project>/secrets/<secret>/versions/current): the root organization's placement pins the version it points at, its 0-bootstrap renders it on the secret, and the apply moves it, which switches every reader in every organization at once.

View Source
const (

	// MarkerPrefix is the prefix in the state bucket under which bedrock org apply keeps
	// one marker object per layer run, holding the commit its last successful apply was
	// of: applied/<layer>, or applied/2-env/<env>.
	MarkerPrefix = "applied"
)

The runner identities of the Cloud Build triggers, by the suffix of their account ids in the boot project: the planner runs the plan trigger's builds, the applier the apply trigger's; each impersonates the layer identities of its kind.

View Source
const RecordApex = "@"

RecordApex names the domain itself in a record (records[].name).

View Source
const RecordsDir = "organizations"

RecordsDir is the directory of the root organization's repository that holds the creation records, one directory per hosting organization.

View Source
const RootProjectKey = "root"

RootProjectKey is the key of a root organization's one project in placement.json (projects.root): the root project, which holds the secrets, the zones, the connection, the triggers and the state bucket.

View Source
const SecretPolicyAdminRole = "secretPolicyAdmin"

SecretPolicyAdminRole is the id of the custom role a root organization's bootstrap makes in its root project (projects/<root project>/roles/secretPolicyAdmin): a secret's IAM policy and nothing else, which each created hosting organization's boot identity and the creating identity hold on the shared secrets.

View Source
const (

	// StepsVersion names the shape of the triggers' inline steps this bedrock renders
	// (0-bootstrap/cloud-build.tf): the substitutions they carry and what each step
	// does. The steps also follow the pin's kind (a release pin renders FetchBedrock
	// alone, a commit pin adds BuildBedrock), so what both triggers pass as
	// _BEDROCK_STEPS is StepsShape, this version and the kind, and bedrock org plan and
	// apply compare it with their own, since a trigger's steps lag one apply behind the
	// repository: a change to them is rendered by the new bedrock, planned and applied
	// by a run on the old steps, and the next run is the first on the new ones. It
	// changes when the steps change in a way the commands have to know about.
	StepsVersion = "2"
)

Variables

Keys are the three GitHub Apps' keys, by the name the commands take; Secrets are every organization secret the commands take, the keys and the Bot Account's token.

AppRoles are the three apps, in the order the bootstrap makes them.

View Source
var BootLayerRoles = []string{
	"roles/cloudbuild.builds.editor",
	"roles/cloudbuild.connectionAdmin",
	"roles/iam.serviceAccountAdmin",
	"roles/resourcemanager.folderAdmin",
	"roles/resourcemanager.projectCreator",
	"roles/resourcemanager.projectDeleter",
	"roles/resourcemanager.projectIamAdmin",
	"roles/serviceusage.serviceUsageAdmin",
}

BootLayerRoles are the roles the boot layer identity holds on the organization's folder, and nowhere higher: the list 0-bootstrap's var.boot_layer_roles carries, which the creation grants before the layer's first apply. The template's list and this one say the same; a test holds them together.

View Source
var BootProjectRoles = []string{
	"roles/iam.roleAdmin",
}

BootProjectRoles are the roles the boot layer identity holds on the boot project alone, 0-bootstrap's var.boot_project_roles, which the creation grants with BootLayerRoles: Custom Roles Administrator, for the custom roles the layer makes there, which Google binds on a project or at the organization node and never on a folder.

View Source
var BootstrapRoles = []BootstrapRole{
	{
		Title:       "Organization Administrator",
		Role:        "roles/resourcemanager.organizationAdmin",
		On:          OnOrganization,
		Permissions: []string{"resourcemanager.organizations.getIamPolicy", "resourcemanager.organizations.setIamPolicy"},
		Needs:       "granting the creating identity Folder Creator at the organization node, and the bootstrap its own working grants, which it takes off at the end",
	},
	{
		Title:       "Folder Creator",
		Role:        "roles/resourcemanager.folderCreator",
		On:          OnOrganization,
		Permissions: []string{"resourcemanager.folders.create"},
		Needs:       "the organization's folder, at the organization root; the root project is made under it as its administrator",
	},
	{
		Title:       "Billing Account Administrator",
		Role:        "roles/billing.admin",
		On:          OnBillingAccount,
		Permissions: []string{"billing.accounts.getIamPolicy", "billing.accounts.setIamPolicy", "billing.budgets.create", "billing.budgets.list", "billing.resourceAssociations.create"},
		Needs:       "linking the root project to the billing account, making the account's spend budget, and granting the creating identity the account's administration, with which each hosting organization's identities get their billing grants and its budget is made",
	},
}

BootstrapRoles are the roles bedrock org bootstrap needs the break-glass account to hold, each with the permissions that stand for it: administering the organization's IAM policy, which grants the creating identity Folder Creator at the node and the bootstrap its own working grants; creating the organization's folder at the node; and administering the billing account, which links the root project and grants the creating identity the account's administration. Everything else happens under the folder, where the bootstrap is the creator, and every working grant it makes itself comes off at the end; org check lists what is left.

View Source
var BudgetThresholds = []float64{0.5, 0.9, 1}

BudgetThresholds are the alerts every budget here carries: half, nine tenths and the whole of the amount.

Entitlements are the environments' entitlements in the order the layers declare them.

View Source
var Environments = []string{tstEnvironment, stgEnvironment, prdEnvironment}

Environments are the model's environments in promotion order; pull requests deploy to the first, production is the last.

View Source
var HostingLayers = []string{bootstrapLayer, orgLayer, shrLayer, spnLayer, envLayer, netLayer}

HostingLayers are the hosting model's layers, in apply order: 2-env before 2-net, since 2-net's URL map names tst's pull-request backend, which 2-env tst makes, while nothing in 2-env waits on 2-net (its two load balancer principals are derived from 1-org until 2-net exists, and the apps domain is the placement's). A root organization's are RootLayers (zones.go); Placement.Layers answers by kind.

View Source
var HostingProjectKeys = []string{bootProject, shrProject, netProject, spnProject, tstEnvironment, stgEnvironment, prdEnvironment}

HostingProjectKeys are the hosting model's projects by key, in layer order: the boot project (the seed's, 0-bootstrap's and 1-org's layers run there), the shared projects, then the environment projects. A root organization has the boot project alone (Placement.ProjectKeys).

Kinds are the kinds a placement may name.

View Source
var SignInAPIs = []string{identityToolkitAPI, secureTokenAPI}

SignInAPIs are the services the applications' web API keys admit, the Identity Toolkit API and the Secure Token API, and the ones bedrock org apply restricts Firebase's browser key to: the key is then no more capable than the applications' own.

View Source
var SpannerConfigs = []SpannerConfig{
	{Name: configNam10, ReadWrite: [2]string{usCentral1, usWest3}},
	{Name: configNam6, ReadWrite: [2]string{usCentral1, usEast1}},
	{Name: configNam11, ReadWrite: [2]string{usCentral1, usEast1}},
	{Name: configNam7, ReadWrite: [2]string{usCentral1, usEast4}},
	{Name: configNam12, ReadWrite: [2]string{usCentral1, usEast4}},
	{Name: configNam16, ReadWrite: [2]string{usCentral1, usEast4}},
}

SpannerConfigs are the multi-region configurations bedrock knows, in the order a message lists them.

Functions

func DefaultHostname

func DefaultHostname(appsDomain, app, env string) string

DefaultHostname is the default rule's hostname of an application in an environment: the code under the apps domain, with the environment's suffix below production.

func Fill

func Fill(root, h *Placement) error

Fill puts into the hosting organization's placement what the root organization supplies, and chooses the boot project's suffix when none is chosen yet, so that the record is complete before the creation runs: the Google Cloud organization and its domain, the billing account (the root organization's unless the record names one), the GitHub organization, its Bot Account, default branch and the three apps' ids, the word their names start with and the release app's slug, the Cloud Build authorization (the same connection token, read from the root organization's boot project), the break-glass account, the bedrock pin, and the root organization itself (root). What the person wrote and the root organization does not supply stays. It refuses a record whose prefix is the root organization's or whose values contradict the root organization's.

func HostingBudgetName

func HostingBudgetName(prefix string) string

HostingBudgetName names a hosting organization's budget, the one on its folder.

func IsOrganizationPlacement

func IsOrganizationPlacement(file string) (bool, error)

IsOrganizationPlacement reports whether the file is an organization placement: JSON that names the Google Cloud organization (organizationId), or that says it is a root organization's (kind root), which names none when it has no cloud. A file that is absent, or that is not JSON, is not one: an application's placement beside its stack names no organization, and whatever reads it reports its own faults.

func NextHostname

func NextHostname(host string) string

NextHostname is the hostname of the next revision behind a hostname: its first label with -next, as the application's stack names it.

func PinKind

func PinKind(version string) string

PinKind is the kind of the pin, release or commit: the suffix of StepsShape, and what bedrock upgrade compares across a move, since a pin that changes kind changes the shape of the triggers' steps. No pin is the release kind, as the steps render for it.

func Preflight

func Preflight(ctx context.Context, p *Placement, open PermissionTesterFunc, w io.Writer) bool

Preflight opens the tester, runs the check and writes its answer. It reports whether the caller holds every role; without credentials, or when an API refuses to answer, it says the permissions were not checked and why, and reports false, since a check that did not run passes nothing. A hosting organization has no bootstrap roles to check, since its root organization creates it: the check says so and reports false.

func RandomSuffix

func RandomSuffix() (string, error)

RandomSuffix is four hex characters from the system's randomness: the suffix a root project's id and its bucket's name take at the bootstrap.

func RecordPath

func RecordPath(dir, prefix string) string

RecordPath is the path, under the root organization's repository, of the hosting organization's record: its placement.

func RegionCode

func RegionCode(name string) (string, error)

RegionCode is the three-character code bedrock's names carry for a region, from the region's name: the initial of each word and the number (us-central1: uc1; us-west3: uw3; europe-west4: ew4; northamerica-northeast1: nn1). A name of another shape is refused.

func Render

func Render(p *Placement) ([]render.File, error)

Render renders every file of the organization's repository: the layers' owned files (the layers of its kind), each layer's seeded values, and the root files.

func RenderSeeded

func RenderSeeded(p *Placement, seed *Seed) ([]render.File, error)

RenderSeeded renders the organization with the creation's seed in the seeded tfvars (the folder ids and the boot project the creation made), for the repository the creation pushes; a nil seed renders as Render does.

func RestrictBrowserKeys

func RestrictBrowserKeys(ctx context.Context, client KeyClient, project string, out io.Writer) error

RestrictBrowserKeys restricts every API key in the project named as Firebase names its browser key to the sign-in APIs, saying what it did, or that there was none. The client acts as the environment's layer identity, which holds the project's API key administration (1-org's app role set).

func SortedHosts

func SortedHosts(hosts map[string]string) []string

SortedHosts lists the entries' hostnames in name order, each served hostname followed by its -next twin: the order 2-net's hosts are rendered in.

func StepsShape

func StepsShape(p *Placement) string

StepsShape is what the triggers pass as _BEDROCK_STEPS, and set as BEDROCK_STEPS in the fetch step's environment: StepsVersion and the kind of pin the steps were rendered for (2-release, 2-commit).

func TotalBudgetName

func TotalBudgetName(prefix string) string

TotalBudgetName names a root organization's budget, the one on the whole billing account.

func ValidateSecret

func ValidateSecret(name string) error

ValidateSecret checks that the name is one of the organization's secrets.

Types

type APIKey

type APIKey struct {
	Name        string
	DisplayName string
	APITargets  []string
}

APIKey is one API key of a project: its resource name, its display name, and the services its API restriction admits, none when it carries no API restriction.

type AppIdentity

type AppIdentity struct {
	ID   int64
	Slug string
	Name string
}

AppIdentity is a GitHub App as GitHub describes it to the app itself.

type AppIdentityFunc

type AppIdentityFunc func(ctx context.Context, appID string, pemKey []byte) (*AppIdentity, error)

AppIdentityFunc asks GitHub which app a key signs as, with a JWT issued by appID and signed with the key in PEM; GitHub refuses a key that is not the app's.

type AppManifest

type AppManifest struct {
	Role        AppRole
	Name        string
	Description string
	Permissions map[string]string
}

AppManifest is bedrock's declaration of one of its GitHub Apps: the role, the name, what it is for in a sentence (the app's description on GitHub) and its permissions, by GitHub's name of each to its level.

func (AppManifest) GitHub

func (m AppManifest) GitHub(homepage, redirect, setup string) github.Manifest

GitHub is the manifest as the browser posts it: the app's homepage, where GitHub sends the browser with the code once the app is made (redirect), and where it sends it once the app is installed (setup); no webhook, installable by the owning organization alone.

func (AppManifest) Unneeded added in v0.1.3

func (m AppManifest) Unneeded(permission, held string) string

Unneeded is the finding about a permission the app holds, at the level held, that its declaration does not name: Verify's sentence for it.

func (AppManifest) Verify

func (m AppManifest) Verify(app *github.App, installations []github.Installation, organization string) []string

Verify holds an app to its declaration: owned by the organization, every declared permission held at its level and no other, and installed on the organization for all of its repositories. Each difference is one finding, in a sentence; none means the app is as declared.

type AppRole

type AppRole string

AppRole names one of the three GitHub Apps bedrock acts as.

const (
	// InfrastructureApp administers the organization's repositories: the root
	// organization's apply creates a hosting organization's repository and pushes its
	// render as it, the runs of 1-org configure the applications' repositories as it,
	// and it bypasses the infrastructure repositories' branch rules, which it writes.
	InfrastructureApp AppRole = "infrastructure"
	// DeployerApp is who the plan trigger's run posts a plan as, and who every
	// application's pipeline talks back on a pull request as.
	DeployerApp AppRole = "deployer"
	// ReleaseApp is who release-please cuts an application's releases as: the only actor
	// that creates, moves or deletes a release tag.
	ReleaseApp AppRole = "release"
)

The three apps, in the order the bootstrap makes them.

func (AppRole) Key

func (r AppRole) Key() string

Key is the name of the secret that holds the app's private key (github-<role>-key).

func (AppRole) Title

func (r AppRole) Title() string

Title names the app in a sentence (the infrastructure app).

type Application

type Application struct {
	Code       string `json:"code"`
	Repository string `json:"repository"`
	// Environments are the environments the application is placed in, a prefix of the
	// promotion order: the first alone, the first two, or every environment. Registration
	// creates the application's things there alone, the layers render for it there alone,
	// and its release line ends at the last of them. Absent, every environment, so a
	// placement written before this field reads as it did; bedrock org register
	// --environments writes a prefix and bedrock org place changes it.
	Environments []string `json:"environments,omitempty"`
	// Adopted says the repository existed on GitHub before the application was
	// registered (one made by hand, or left by an organization that was destroyed), so
	// 1-org adopts it on its first apply through an import block instead of making a
	// second one and failing on the name. bedrock org register records it from GitHub.
	Adopted bool `json:"adopted,omitempty"`
}

Application is one registered application: its code, the segment every resource name of the application carries, one to six lowercase letters and digits starting with a letter (derive.ApplicationCodePattern), and its repository's name under the GitHub organization, the last segment of its module path. 1-org creates the repository by its name and names everything else by the code.

func (*Application) UnmarshalJSON

func (a *Application) UnmarshalJSON(data []byte) error

UnmarshalJSON reads an entry as written, or as a placement before the repository was recorded wrote it: the code alone, which named the repository too.

type Binding

type Binding struct {
	Role    string
	Members []string
}

Binding is one role of an IAM policy with its members.

type BootstrapRole

type BootstrapRole struct {
	Title       string
	Role        string
	On          Scope
	Permissions []string
	Needs       string
}

BootstrapRole is one role the break-glass account holds for the bootstrap: its title as the console names it, its id, where it is granted, the permissions tested for it, and what needs them.

type Budget

type Budget struct {
	// Name is the budget's resource name (billingAccounts/B/budgets/ID), empty on one
	// not made yet.
	Name string
	// DisplayName names the budget in the console and in its alerts; the apply tells the
	// budgets it keeps by it.
	DisplayName string
	// Units is the monthly amount in whole units of the billing account's currency, which
	// CurrencyCode names on a budget read back.
	Units        int64
	CurrencyCode string
	// Ancestors are the folders the budget counts (folders/F); none counts every project
	// on the billing account.
	Ancestors []string
	// Thresholds are the fractions of the amount at which an alert is sent, on actual
	// spend.
	Thresholds []float64
}

Budget is one spend budget on the billing account, as Cloud Billing holds it and the apply keeps it.

func HostingBudget

func HostingBudget(prefix string, units int64, folder string) Budget

HostingBudget is a hosting organization's budget: the amount its record names, on its own folder.

func TotalBudget

func TotalBudget(prefix string, units int64) Budget

TotalBudget is a root organization's budget: the amount its placement names, on every project of the billing account.

func (Budget) Same

func (b Budget) Same(o Budget) bool

Same reports whether the other budget says the same amount, counts the same folders and alerts at the same thresholds.

type Delegation

type Delegation struct {
	Organization string   `json:"organization"`
	NameServers  []string `json:"nameServers"`
}

Delegation is where a label is handed: the hosting organization that serves the name (by its prefix) and the four name servers of the zone it serves it from, as Cloud DNS spells them (ns-cloud-a1.googledomains.com., with the trailing dot), read from that zone once its apply has made it, since Cloud DNS assigns them and nothing chooses them in advance.

type Domain

type Domain struct {
	// Labels are the names under the domain handed onward, by label (acme for
	// acme.mydomain.com; a label may carry a dot, as in east.acme, but no label is above
	// or below another), each with the hosting organization and the four name servers of
	// the application's zone there.
	Labels map[string]Delegation `json:"labels,omitempty"`
	// Records are the record sets the zone carries beside the labels' NS records and the
	// owners' verification tokens, declared by the person who knows what the domain
	// needs there: a verification TXT at the apex of a domain delegated whole, the mail
	// records of a Workspace domain (MX, SPF, DKIM, DMARC), a CAA record. The apply
	// writes each as declared and rewrites one the zone holds differently; a record
	// taken out stays until a person deletes it, as the apply deletes no zone.
	Records []Record `json:"records,omitempty"`
}

Domain is one domain a root organization holds a zone for: the labels of it handed onward, by label, each to the zone a hosting organization serves the name from. A domain with no label yet holds its zone alone, so the customer's delegation is made once, at the first application or before it.

type Finding

type Finding struct {
	// Path is the file's path relative to the repository root.
	Path string
	// Missing reports a file the render produces that the repository lacks.
	Missing bool
	// Line is the first differing line (1-based), 0 when Missing or when Reason says
	// what is wrong.
	Line int
	// Want and Got are that line as rendered and as committed.
	Want string
	Got  string
	// Reason, when set, says why the file is refused: a .tf file no render produces, an
	// override file.
	Reason string
}

Finding is one file that is not as the render says it should be: an owned file that differs or is missing, or a file in a layer that no render produces.

type Folder

type Folder struct {
	ID   string
	Name string
}

Folder is one folder under the organization: its numeric id and its display name.

type HostRow

type HostRow struct {
	Key   string
	Value string
}

HostRow is one entry of 2-net's hosts map: the quoted hostname, padded so the entries' equals signs align the way tofu fmt writes them, and its backend service.

type HostingOrganization

type HostingOrganization struct {
	// Prefix is the hosting organization's prefix.
	Prefix string `json:"prefix"`
	// BootProject is its boot project, where its boot identity lives; chosen when the
	// organization is recorded (bedrock org create picks the suffix), so the project's
	// id is known before anything is made.
	BootProject string `json:"bootProject"`
	// Folder is the numeric id of the organization's folder at the organization node,
	// recorded by the creation's hand-off (or by hand, for an organization that stood
	// before the root organization). Empty while the organization is not created yet.
	Folder string `json:"folder,omitempty"`
}

HostingOrganization is a hosting organization under a root organization, in the root organization's placement (hostingOrganizations): one the root organization creates by pull request (bedrock org create; README.md, "Creating a hosting organization"), or one recorded as it stands. Its folder is recorded once the organization is created, and the root organization's grants to its identities render from then on: a grant names an identity that exists.

func (HostingOrganization) BootIdentityMember

func (h HostingOrganization) BootIdentityMember() string

BootIdentityMember is the hosting organization's boot identity as an IAM member, the principal the root organization grants the three secrets' policy administration.

func (HostingOrganization) Created

func (h HostingOrganization) Created() bool

Created reports whether the hosting organization's folder is recorded: the creation has handed it off, and the root organization's grants to its identities render.

type InstanceCapacity

type InstanceCapacity struct {
	// Environment is the environment whose own instance this is; empty for the shared one.
	Environment     string
	Environments    []string
	ProcessingUnits int
	Capacity        int
	Applications    int
	Declared        int
}

InstanceCapacity is one Spanner instance's capacity against the placement: the shared instance (2-spn's) or an environment's own (2-env's), the environments whose databases live on it, its processing units, the databases Google lets an instance of that size hold, the applications placed in at least one of its environments, and the databases they declare there, one for each of its environments an application is placed in.

func IntegrationInstance

func IntegrationInstance(capacities []InstanceCapacity) (InstanceCapacity, bool)

IntegrationInstance is the instance that holds the integration environment's databases, and with them every pull request's: the first environment's own, or the shared one.

func (InstanceCapacity) Exceeded

func (c InstanceCapacity) Exceeded() bool

Exceeded reports a placement that declares more databases than the instance holds.

func (InstanceCapacity) Name

func (c InstanceCapacity) Name() string

Name names the instance for a sentence.

func (InstanceCapacity) Problem

func (c InstanceCapacity) Problem() string

Problem is the sentence for a placement past the instance: what is declared, what the instance holds at its size, and the two ways out.

func (InstanceCapacity) PullRequestRoom

func (c InstanceCapacity) PullRequestRoom(integration string) string

PullRequestRoom is the sentence for the instance that holds the integration environment's databases, where every pull request's stack holds a database of its own unless it shares the environment's: what the applications take, and what is left.

func (InstanceCapacity) Room

func (c InstanceCapacity) Room() int

Room is what the instance has left once the applications' databases are there: the databases pull-request stacks may hold, on the instance that holds the integration environment's.

func (InstanceCapacity) Setting

func (c InstanceCapacity) Setting() string

Setting names the value that grows the instance: 2-spn's processing units for the shared instance, the environment's entry in 2-env's spanner_instances for its own.

func (InstanceCapacity) Shared

func (c InstanceCapacity) Shared() bool

Shared reports the shared instance.

type KeyAccessFunc

type KeyAccessFunc func(ctx context.Context, version string) ([]byte, error)

KeyAccessFunc reads a secret version's payload by its resource name.

type KeyCheckRequest

type KeyCheckRequest struct {
	// Secret is the organization secret's name; Version the version's number.
	Secret  string
	Version string
	// Project and Container are where the version lives.
	Project   string
	Container string
}

KeyCheckRequest is what org secrets check was asked to prove.

type KeyCheckResult

type KeyCheckResult struct {
	Secret    string
	Version   string
	Project   string
	Container string
	// AppID is the App ID the placement records for the key's app, which the JWT was
	// issued by; App is GitHub's answer.
	AppID string
	App   *AppIdentity
	// Pinned is the version the alias points at as placement.json pins it, or empty.
	Pinned string
}

KeyCheckResult is what the check found.

func CheckKey

func CheckKey(ctx context.Context, open secret.ClientFunc, access KeyAccessFunc, identity AppIdentityFunc, p *Placement, req *KeyCheckRequest) (*KeyCheckResult, error)

CheckKey proves the version: it must be enabled, GitHub must answer a JWT signed with it as the app placement.json records, and the answer must be that app. A hosting organization is sent to the root organization that holds the keys; an app not recorded is refused, since there is nothing to sign as.

func (*KeyCheckResult) Write

func (r *KeyCheckResult) Write(w io.Writer)

Write prints what was proven and what moves the alias.

type KeyClient

type KeyClient interface {
	KeyLister
	// RestrictKey sets the key's API restriction to the services, waiting for the
	// change to land.
	RestrictKey(ctx context.Context, name string, services []string) error
}

KeyClient lists a project's API keys and restricts one: what bedrock org apply opens as the environment's layer identity after each apply of 2-env.

func NewKeyClientAs

func NewKeyClientAs(ctx context.Context, identity string) (KeyClient, error)

NewKeyClientAs opens the API Keys client as the identity, impersonated with the process's default credentials: bedrock org apply restricts Firebase's browser key as the environment's layer identity.

type KeyClientAsFunc

type KeyClientAsFunc func(ctx context.Context, identity string) (KeyClient, error)

KeyClientAsFunc opens a KeyClient as an identity the process's credentials may impersonate.

type KeyLister

type KeyLister interface {
	// ProjectKeys is the project's API keys, deleted ones left out.
	ProjectKeys(ctx context.Context, project string) ([]APIKey, error)
	// Close releases the connection.
	Close() error
}

KeyLister lists a project's API keys. NewKeyLister is the real one, over the API Keys API; tests pass a fake.

func NewKeyLister

func NewKeyLister(ctx context.Context) (KeyLister, error)

NewKeyLister opens the API Keys client with Application Default Credentials; without any, the open fails and says so. Each list is billed to the project it reads.

type KeyListerFunc

type KeyListerFunc func(ctx context.Context) (KeyLister, error)

KeyListerFunc opens a KeyLister.

type LayerRun

type LayerRun struct {
	Name        string
	Layer       string
	Environment string
	StatePrefix string
	Apply       string
	Plan        string
}

LayerRun is one run of the triggers: a layer, the environment it is applied in (2-env alone; empty for the rest), the state prefix its init names (2-env alone), and the identities the run impersonates for its tofu: the apply identity on the apply trigger, the plan identity on the plan trigger. Name is the run as the commands and the plan comments call it.

func (LayerRun) Marker

func (r LayerRun) Marker() string

Marker is the marker object bedrock org apply keeps for the run in the state bucket.

func (LayerRun) Unrecorded

func (r LayerRun) Unrecorded() bool

Unrecorded reports whether an identity of the run is under a project the placement does not record yet (REPLACEME).

type Leftover

type Leftover struct {
	// On is where the grant sits: a project or a folder.
	On string
	// Key names the place: a project's key in the placement (boot, tst), a folder's
	// display name.
	Key string
	// ID is the project's id or the folder's numeric id.
	ID string
	// Member is the person, as an IAM member (user:...).
	Member string
	// Role is the role held.
	Role string
	// Outside says the member is a principal outside the organization, on its folder:
	// not the break-glass account, not an identity in one of the organization's
	// projects. The other leftovers are a person's, from a hand apply.
	Outside bool
}

Leftover is one grant a person still holds from a hand apply.

func Leftovers

func Leftovers(ctx context.Context, p *Placement, read PolicyReader) (leftovers []Leftover, unrecorded []string, folderFound bool, err error)

Leftovers lists the grants the setup left behind: on every project the placement records (projects), in its order, each person holding Owner and each other role the break-glass account holds; on the organization's folder, each role the break-glass account holds but Folder Admin, the one it keeps, and each grant to a principal outside the organization (Outside); on each folder under it, each person holding Folder Admin or Folder Editor and each other role the break-glass account holds. Unrecorded names the environments the placement records no project for, which are not read (a root organization has none); a missing organization folder is reported as none found, not as an error, since the check runs before the seed too.

func (Leftover) Place

func (l Leftover) Place() string

Place names where the grant sits, for a line about it.

type Library

type Library struct {
	// Repository is the repository's name in the GitHub organization.
	Repository string `json:"repository"`
	// Public says the repository is public; left out, it is private. The engine brings
	// the repository to it either way.
	Public bool `json:"public,omitempty"`
	// Checks are the checks a pull request into the default branch must pass, each by
	// the name a pull request shows it under: a job's name, or for a job of a reusable
	// workflow the calling job's id, a slash and the called job's name
	// (golang-ci / Run tests and builds). GitHub Actions is the reporter of each. The
	// engine writes no workflow: the names are what the repository's own workflow files
	// report, and a name no pull request reports is a finding, since every pull request
	// would wait for it.
	Checks []string `json:"checks,omitempty"`
	// Adopted says the repository stood before the placement listed it (one transferred
	// into the organization): the engine brings its settings and its ruleset to the
	// placement as it does any library's, reports the rulesets it carries beside the
	// engine's own, and, while the entry names no checks, prints the ones those rulesets
	// require, which become the entry's first list.
	Adopted bool `json:"adopted,omitempty"`
}

Library is one library of a root organization: a repository of the GitHub organization that deploys nowhere.

type PermissionTester

type PermissionTester interface {
	// OrganizationPermissions are the permissions, of those asked, the caller holds on
	// the organization (its numeric id).
	OrganizationPermissions(ctx context.Context, organizationID string, permissions []string) ([]string, error)
	// BillingAccountPermissions are the permissions, of those asked, the caller holds on
	// the billing account (its id, 012345-6789AB-CDEF01).
	BillingAccountPermissions(ctx context.Context, billingAccount string, permissions []string) ([]string, error)
	// Close releases the connections.
	Close() error
}

PermissionTester asks Google which of the permissions the caller holds: on an organization (Cloud Resource Manager's organizations.testIamPermissions) and on a billing account (Cloud Billing's billingAccounts.testIamPermissions). Each answers the subset held. NewPermissionTester is the real one; tests pass a fake.

func NewPermissionTester

func NewPermissionTester(ctx context.Context) (PermissionTester, error)

NewPermissionTester opens the two clients with Application Default Credentials; without any, the open fails and says so.

type PermissionTesterFunc

type PermissionTesterFunc func(ctx context.Context) (PermissionTester, error)

PermissionTesterFunc opens a PermissionTester.

type Placement

type Placement struct {
	// Kind is the kind of organization: hosting, the default when left out, which holds
	// applications in its environments and renders the six layers; or root, which holds
	// the GitHub Apps' keys, the zones of the domains delegated to it and the hosting
	// organizations' records in its root project, without a layer (root.go). A root
	// organization names its domains (Domains) and none of the fields that describe
	// applications or environments.
	Kind string `json:"kind,omitempty"`
	// Prefix is the organization's naming prefix: every resource name starts with
	// <prefix>-<env>.
	Prefix string `json:"prefix"`
	// OrganizationDomain is the Google Cloud organization's domain, which is also the
	// Workspace domain the directory sign-ins restrict logins to.
	OrganizationDomain string `json:"organizationDomain"`
	// OrganizationID is the organization's numeric ID, for the seed steps.
	OrganizationID string `json:"organizationId"`
	// DirectoryCustomerID is the Google Cloud organization's Cloud Identity customer (C and
	// eight lowercase alphanumerics), which 1-org names in the domain-restricted sharing
	// policy: recorded with the seed's values in a root organization (gcloud organizations
	// describe, owner.directoryCustomerId) and copied into each hosting organization's
	// record by bedrock org create, since an identity of an organization holds no read at
	// the organization node to look the organization up with.
	DirectoryCustomerID string `json:"directoryCustomerId,omitempty"`
	// BillingAccount is the billing account projects are linked to.
	BillingAccount string `json:"billingAccount"`
	// MonthlyBudget is the spend budget, in whole units of the billing account's currency
	// a month: a hosting organization's own, on its folder, made by the creation; a root
	// organization's, on the whole billing account, made by the bootstrap; both kept by the
	// root organization's apply, with alerts at half, nine tenths and the whole of it to
	// the billing account's administrators and users. Required: a budget nobody set is
	// what the hand step it replaces existed to prevent.
	MonthlyBudget int64 `json:"monthlyBudget,omitempty"`
	// AppsDomain is the domain the applications' hostnames hang under, never the
	// identity domain. A root organization has none.
	AppsDomain string `json:"appsDomain,omitempty"`
	// Domains are the domains a root organization holds a zone for, by domain, each with
	// the labels of it handed onward to the hosting organizations' zones (Domain). A
	// customer delegates the domain to this organization's zone once, at its registrar or
	// at the DNS provider that serves the domain above it (bedrock domain check prints
	// the records); each application's name under it is then one label here, named at
	// the application's registration with the four name servers of its zone in the
	// hosting organization. The apply makes one zone per domain and one NS record set per
	// label. None for a hosting organization.
	Domains map[string]Domain `json:"domains,omitempty"`
	// VanityDomains are the vanity domains beside the apps domain, by domain, each a
	// client's own domain an application serves on (its brand domain, in production).
	// An empty entry is delegated to the network project: 2-net serves it with a zone, as
	// it serves the apps domain, and bedrock domain check verifies the delegation; a
	// domain that carries other DNS (mail, a website) is refused there, with a label of
	// it to declare instead, or the domain kept. An entry with dns "customer" is kept at
	// the customer's DNS provider, which stays authoritative for it: 2-net renders no
	// zone for it, and the provider carries the records bedrock prints (an A record per
	// hostname declared on the domain, at the load balancer's address, and the
	// certificate's authorization CNAME), which the check verifies instead. Either way
	// 2-net holds a DNS authorization, a managed certificate for the domain and one label
	// below it, and the certificate map's entries; an application declares the hostnames
	// it serves on the domain (hostnames.<site>.vanity in its placement, the domain
	// itself or a label of it), and the organization records them with the others and
	// refuses a hostname under no domain declared here. A delegated vanity domain may be
	// registered here too (registrations in 2-net/terraform.tfvars, bedrock domain add),
	// as the apps domain may; the registration then points at its zone.
	VanityDomains VanityDomains `json:"vanityDomains,omitempty"`
	// ZoneReplacement, while true, renders 2-net's apps zone and its parked zones without
	// prevent_destroy, so the change that makes a zone again (a new appsDomain, a
	// replacement) can be planned and applied; false, the default, renders the rule that
	// refuses it. It is set for the recreation alone and cleared once everything points
	// at the new zone (2-net/README.md, "Making a zone again"), which org check and
	// domain check remind of while it is set.
	ZoneReplacement bool `json:"zoneReplacement,omitempty"`
	// GithubOrganization is the GitHub organization holding the application
	// repositories and this one.
	GithubOrganization string `json:"githubOrganization"`
	// GithubBotAccount is the login of the organization's GitHub Bot Account: a GitHub
	// user with no person behind it, an owner of the organization, whose classic personal
	// access token the Cloud Build connections authorize as (Cloud Build takes a GitHub
	// user's token, never an App's). The bootstrap stores that token as the root
	// organization's Cloud Build token secret, which every connection names.
	GithubBotAccount string `json:"githubBotAccount"`
	// GithubAppPrefix is the word the three GitHub Apps' names start with
	// (<word>-infrastructure, <word>-deployer, <word>-release), when it is not the GitHub
	// organization's login: for a login that would make a name longer than GitHub's 34
	// characters, or names that are taken. A root organization's, which makes the apps; a
	// hosting organization's placement carries its root organization's, filled in with
	// the App IDs when the organization is recorded (Fill), since the apps are the same.
	GithubAppPrefix string `json:"githubAppPrefix,omitempty"`
	// GithubReleaseAppID is the App ID of the release GitHub App, the only actor that
	// creates, moves or deletes a release tag of an application's repository: digits,
	// from the app's settings page. The id, not the slug: a private app cannot be
	// read by its slug with the operator's token.
	GithubReleaseAppID string `json:"githubReleaseAppId"`
	// GithubReleaseAppSlug is the same app's slug, the name in its page's address, which
	// the root organization records when the app is made and a hosting organization copies;
	// (github.com/apps/<slug>): the releases it cuts carry <slug>[bot] as their author,
	// and an application's pipeline accepts a release from that author alone, so each
	// application's placement records it (releaseApp), from here.
	GithubReleaseAppSlug string `json:"githubReleaseAppSlug"`
	// GithubDefaultBranch is the default branch of every application repository, from
	// which alone the operations workflow's Environments deploy, and of this repository,
	// from which alone the apply trigger applies the layers.
	GithubDefaultBranch string `json:"githubDefaultBranch"`
	// GithubInfrastructureAppID is the App ID of the infrastructure GitHub App, whose
	// installation token a run of the triggers mints for 1-org's GitHub provider: digits,
	// from the app's settings page. Empty until the app exists; a run that plans or
	// applies 1-org refuses until it is recorded.
	GithubInfrastructureAppID string `json:"githubInfrastructureAppId,omitempty"`
	// GithubInfrastructureKeyVersion is the number of the Secret Manager version holding
	// the infrastructure app's private key, in the secret a root organization holds in
	// its root project (<prefix>-root-gbl-github-infrastructure-key): the version its
	// alias current points at, which the root organization's apply moves and every
	// reader names, never latest. A root organization's; a hosting organization records none (Keys).
	// Empty until a version was pinned.
	GithubInfrastructureKeyVersion string `json:"githubInfrastructureKeyVersion,omitempty"`
	// GithubDeployerAppID is the App ID of the deployer GitHub App, which the
	// applications' pipelines talk back on a pull request as and the plan trigger's run
	// posts the layers' plans as: digits, from the app's settings page. Empty until the
	// app exists; until then the plans are in the run's log alone.
	GithubDeployerAppID string `json:"githubDeployerAppId,omitempty"`
	// GithubDeployerKeyVersion is the number of the Secret Manager version holding the
	// deployer app's private key, in the secret a root organization holds in its root
	// project (<prefix>-root-gbl-github-deployer-key): the version its alias current
	// points at. A root organization's; empty until a version was pinned.
	GithubDeployerKeyVersion string `json:"githubDeployerKeyVersion,omitempty"`
	// GithubReleaseKeyVersion is the number of the Secret Manager version holding the
	// release GitHub App's private key, in the secret a root organization holds in its
	// root project (<prefix>-root-gbl-github-release-key): the version its alias current
	// points at, from which each application's release trigger in the hosting
	// organizations mints the token release-please cuts the releases with. A root
	// organization's; empty until a version was pinned.
	GithubReleaseKeyVersion string `json:"githubReleaseKeyVersion,omitempty"`
	// GithubTokenVersion is the number of the Secret Manager version holding the GitHub
	// Bot Account's token, in the secret a root organization holds in its root project
	// (<prefix>-root-gbl-github-token): the version its alias current points at, which
	// the root organization's apply moves and every Cloud Build connection in every
	// organization names (cloudBuildTokenSecretVersion). A root organization's; the
	// bootstrap pins the first, bedrock secret pin github-token the next; empty until a
	// version was pinned.
	GithubTokenVersion string `json:"githubTokenVersion,omitempty"`
	// Root is the root organization a hosting organization stands under: the one that
	// holds, for every organization in the Google Cloud organization, the GitHub Apps'
	// private keys and the Cloud Build GitHub authorization's token, by its prefix
	// (root.organization) and its root project (root.project), where those secrets live.
	// Every reader of a key names the alias current of its secret, which that
	// organization's placement pins, and every connection names that organization's
	// token (cloudBuildTokenSecretVersion, the same value as in its placement); nothing
	// about either is recorded here beyond that. A root organization has none: they are
	// its own.
	Root *RootPlace `json:"root,omitempty"`
	// KeyOperators are the members (user:..., group:...) a root organization grants the
	// adding of a version of a GitHub App's key, and the read that proves one, for the
	// rotation (README.md, "The GitHub Apps' keys"). None for a hosting
	// organization.
	KeyOperators []string `json:"keyOperators,omitempty"`
	// HostingOrganizations are the hosting organizations under a root organization,
	// each by its prefix and its boot project, and its folder once created: the ones
	// the root organization creates by pull request (bedrock org create, whose record is
	// the organization's own placement under organizations/<prefix>/), and the ones that
	// stood before it, recorded as they are. For each created one, the root
	// organization's apply grants the boot identity the administration of the shared
	// secrets' policies (secretPolicyAdmin: the three keys and the token), which that
	// organization's layers hand down to the identities that read them. None for a
	// hosting organization.
	HostingOrganizations []HostingOrganization `json:"hostingOrganizations,omitempty"`
	// Libraries are the libraries of a root organization, in the order they were listed:
	// repositories of the GitHub organization that deploy nowhere, each made and kept by
	// the root organization's engine with the ruleset its checks name (Library). A root
	// organization that names no Google Cloud organization (organizationId) holds
	// libraries alone and has no cloud (libraries.go). None for a hosting organization.
	Libraries []Library `json:"libraries,omitempty"`
	// CloudBuildInstallationID is the installation id of the Google Cloud Build GitHub
	// App on the GitHub organization (digits, from the installation's settings page),
	// which every Cloud Build connection names: the root organization's for its runs, a
	// hosting organization's boot project's for the layers and each environment's for
	// the applications. The bootstrap reads it from GitHub with the Bot Account's token
	// and records it in the root organization's placement, from which a hosting
	// organization's record fills it in.
	CloudBuildInstallationID string `json:"cloudBuildInstallationId,omitempty"`
	// CloudBuildTokenSecretVersion is the resource name of the Secret Manager version
	// holding the Bot Account's token the connections authorize with: the alias current
	// of the secret the bootstrap writes into the root project (projects/<root
	// project>/secrets/<prefix>-root-gbl-github-token/versions/current), which the root
	// organization's apply points at the version githubTokenVersion pins, so a rotation
	// there switches every connection at once; a numbered version is taken too (a
	// regional one reads projects/<project>/locations/<region>/secrets/<name>/versions/<n>),
	// never latest. The same value in every organization's placement, filled in from the
	// root organization's.
	CloudBuildTokenSecretVersion string `json:"cloudBuildTokenSecretVersion,omitempty"`
	// BedrockVersion is the bedrock the triggers' runs fetch at their first step and run
	// (bedrock upgrade moves it): a release (v0.5.0), whose linux/amd64 binary
	// BedrockSHA256 is the checksum of, or a commit pin (the pseudo-version the Go
	// module proxy names a commit by), which the run builds with go install and carries
	// no checksum. Empty until recorded, and a run of the triggers stops at its first
	// step saying so.
	BedrockVersion string `json:"bedrockVersion,omitempty"`
	BedrockSHA256  string `json:"bedrockSha256,omitempty"`
	// GithubInfrastructureTeam is the slug of the organization's infrastructure team,
	// whose approval a change to an application's workflow and Cloud Build files
	// needs; empty for none.
	GithubInfrastructureTeam string `json:"githubInfrastructureTeam,omitempty"`
	// ApprovingReviews is how many approving reviews a pull request needs before it
	// merges, on every application repository's default branch and patch lines and on
	// this repository's default branch: one when left out, 0 for none (a writer merges
	// alone once the checks pass). A pointer, so that 0 and left out differ. 1-org
	// renders it into github.tf, an owned file bedrock org check compares with the
	// render, so nobody lowers it in a file of their own.
	ApprovingReviews *int `json:"approvingReviews,omitempty"`
	// CiLargeRunner names the larger runner the applications' CI runs the jobs its
	// //impulse:ci line chooses on (the two test legs and the image build without a
	// line): a runner's name, a runner label or a runner group of the GitHub
	// organization, set once as the organization's Actions variable CI_LARGE_RUNNER,
	// which every application's workflow reads. The GitHub organization's own setting,
	// so a root organization's (its apply sets the variable), declared once for every
	// hosting organization in it; a hosting organization's placement refuses it. Empty
	// for GitHub's standard runner, and no variable.
	CiLargeRunner string `json:"ciLargeRunner,omitempty"`
	// CiLargeRunnerSize, when set, has the apply create the larger runner itself: a
	// GitHub-hosted runner named CiLargeRunner, of this machine size as GitHub lists them
	// (4-core, 8-core, 16-core, 32-core, 64-core, 96-core, or an arm- size), on GitHub's
	// current Ubuntu, in a runner group open to the organization's repositories. Empty
	// when CiLargeRunner names a runner or a group the organization already has.
	CiLargeRunnerSize string `json:"ciLargeRunnerSize,omitempty"`
	// CiLargeRunnerMaximum caps how many of the created runner run at once (GitHub's
	// maximum_runners), the spend's ceiling; 0 leaves GitHub's default.
	CiLargeRunnerMaximum int `json:"ciLargeRunnerMaximum,omitempty"`
	// SourceRepo is this repository's name, the source_repo label every resource carries.
	SourceRepo string `json:"sourceRepo"`
	// StateBucket is the seeded state bucket every backend block names; empty until the
	// seed has run, and REPLACEME is rendered in its place.
	StateBucket string `json:"stateBucket,omitempty"`
	// BreakGlassAccount is the organization's break-glass account: a Google account in
	// the Workspace directory with no person behind it, which runs the root organization's
	// bootstrap and keeps Folder Admin on each organization's folder, and after that is
	// signed into only when the pipeline cannot act (0-bootstrap/README.md, "Recovery, by
	// hand"). One per Google Cloud organization; several organizations in it name the same
	// one.
	BreakGlassAccount string `json:"breakGlassAccount"`
	// TeamGroups are the environments' team groups by environment, each a group's
	// address (team-tst@example.com, with no member prefix: the layers write group: in
	// front). Each person's access to an environment comes from its group: the group
	// holds the release approval where a release waits for one, and its members ask for
	// the environment's entitlements. One per environment; the same address may serve
	// several, but production's group is not the first environment's. A root
	// organization has none.
	TeamGroups map[string]string `json:"teamGroups,omitempty"`
	// EntitlementDurations are the longest grants of the environments' entitlements, by
	// entitlement (Entitlements) as a duration (1h, 90m); an entitlement not named takes
	// its default. Between 30 minutes and 7 days.
	EntitlementDurations map[string]string `json:"entitlementDurations,omitempty"`
	// Regions are the two Cloud Run regions, the primary first; a root organization's
	// one region, where its connection, its triggers and its state bucket are.
	Regions []Region `json:"regions"`
	// Spanner is the shared instance's configuration. A root organization has none.
	Spanner Spanner `json:"spanner,omitzero"`
	// OutlierDetection is the outlier detection thresholds of the backend service 2-env
	// renders for the pull-request environments, and those an application's first
	// placement takes for its own backend service; a field left out, or the whole block,
	// takes its default (derive.OutlierDetection).
	OutlierDetection *derive.OutlierDetection `json:"outlierDetection,omitempty"`
	// CloudArmor is the Cloud Armor policy an application's first placement takes for
	// its backend services: the rule sets in order at their sensitivities, the fields a
	// set leaves alone, and the paths allowed ahead of the sets; a block left out is
	// bedrock's defaults (derive.CloudArmor). An environment turns the policy on in the
	// application's terraform.tfvars; nothing of the organization's carries one.
	CloudArmor *derive.CloudArmor `json:"cloudArmor,omitempty"`
	// ContactDomains are the domains Essential Contacts may belong to, each with its
	// leading @.
	ContactDomains []string `json:"contactDomains"`
	// Applications are the registered applications, in the order they were added, each
	// by its code, its repository's name and the environments it is placed in (every one
	// unless its entry names a prefix of the promotion order); empty for an organization
	// with none yet. bedrock org register adds one, bedrock org place changes where one
	// is placed; the layers' applications.auto.tfvars are rendered from it.
	Applications []Application `json:"applications"`
	// Registration is how far each application's registration has gone, by code and by
	// environment, for the applications whose registration is under way somewhere:
	// RegistrationIdentities, then RegistrationGrants; an environment absent from an
	// application's steps, and an application absent from the map, is registered in
	// full. The layers' values render from it, so the repository matches the render at
	// every step of the sequence bedrock org register prints and bedrock org check
	// passes on every pull request of it: the grants on an application's identities in
	// an environment (1-org's public-invoker tag, 2-shr's registry, 2-spn's databases)
	// are rendered once it is past identities there, its hostnames there (2-net) once
	// its registration there is complete. bedrock org register writes the first step in
	// every environment the application is placed in, bedrock org place in an
	// environment added later, and register --next moves to the following.
	Registration map[string]RegistrationSteps `json:"registration,omitempty"`
	// Teardown says the organization is torn down: bedrock org teardown sets it, and
	// 2-net renders with no hosts and its load balancer's listeners gone (serving =
	// false in applications.auto.tfvars), the address, the certificate and its DNS
	// authorization kept. A person flips it back on a pull request once every
	// application's stack is applied again.
	Teardown bool `json:"teardown,omitempty"`
	// OutOfService lists, by application code, the environments whose hostnames 2-net
	// does not serve while the application's stack there is torn down: bedrock org
	// teardown <app> [<env>...] adds them, the hosts file renders without those
	// hostnames (the listeners and every other application's hosts stay), and bedrock
	// org serve <app> [<env>...] removes them once the stack is applied again, since a
	// host names a backend service that must exist. Each application named is registered
	// in full; each environment is one of the model's, listed once, in promotion order.
	OutOfService map[string][]string `json:"outOfService,omitempty"`
	// Hostnames are the hostnames each application's stack serves, by code and by
	// environment, each with the backend service that serves it, as read from the
	// stack's state (its net_hosts output: every site's hostnames and their -next twins,
	// each mapped to its site's backend) when the registration completed (bedrock org
	// register <app> --next) or when bedrock org hostnames <app> recorded them again
	// after the application changed a site's label in its placement. 2-net's hosts
	// render from them verbatim; an application recorded before hostnames were (no
	// entry) renders by the default rule, its code under the apps domain with one
	// backend. The organization never invents a hostname or a backend: it records what
	// the stack serves and refuses a hostname that is not one label under the apps
	// domain or that another application serves too.
	Hostnames map[string]map[string]map[string]string `json:"hostnames,omitempty"`
	// Projects are the projects by key: boot, the project the seed chose, and shr, net,
	// spn, tst, stg and prd, the ids 1-org's apply chose (its project_ids output). The
	// environment projects are what the applications' identities and backends are named
	// under; every project names the layer identities the triggers' runs impersonate.
	// Absent until the seed or 1-org has run; REPLACEME is rendered in their place.
	Projects map[string]string `json:"projects,omitempty"`
	// ProjectNumbers are the projects' numbers by the same keys: boot from the seed, the
	// rest from 1-org's project_numbers output, recorded beside Projects. 0-bootstrap
	// grants each recorded environment project's Cloud Build service agent the read of
	// the connections' token secret by its number. An application's placement records
	// its environments' ids and numbers together (bedrock org register writes them into
	// its first placement, org render prints the block), for the operations workflow
	// that starts a restore from GitHub.
	ProjectNumbers map[string]string `json:"projectNumbers,omitempty"`
	// Folders are the folders 1-org made under the organization's folder, by key (shared,
	// tst, stg, prd), as numeric ids; PublicInvokerTags are the public-invoker tag key and
	// its value true in each environment project, by environment, as resource names
	// (tagKeys/N, tagValues/N). Both are recorded by the creation from 1-org's first
	// apply (its outputs folder_ids, public_invoker_tag_key and public_invoker_tag_value):
	// the root organization sets the organization-policy baseline on the folders, with the
	// tags as the public-invoker exception of domain-restricted sharing (the root's
	// README, "The organization-policy baseline"). A hosting organization holds no role
	// at the organization node, where Google grants Organization Policy Administrator and
	// nowhere lower.
	Folders           map[string]string           `json:"folders,omitempty"`
	PublicInvokerTags map[string]PublicInvokerTag `json:"publicInvokerTags,omitempty"`
	// AppsZone is the apps domain's public zone, made by the creation in the net project
	// as the creating identity and adopted by 2-net (an import block): Cloud DNS asks
	// whoever makes a zone to own the domain, or a parent, in Google's webmaster
	// verification, which the root organization's apply verifies the creating identity
	// as, by its token in the domain's zone, where the net identity of each organization
	// would be made an owner by hand. Its name servers,
	// which Cloud DNS assigns, go into the root placement by the hand-off, as the label of
	// the apps domain handed onward. Recorded by the creation alone.
	AppsZone *ZoneRecord `json:"appsZone,omitempty"`
	// Labels are the labels every project and bucket carries beyond the model's own.
	Labels map[string]string `json:"labels"`
}

Placement is what the organization decided before anything of it exists: its naming prefix, its domains, its billing account, its regions, its GitHub organization, and the few constants the layers restate. Values the creation chooses (the boot project's suffix, the state bucket) are not here until it has run.

func ReadPlacement

func ReadPlacement(path string) (*Placement, error)

ReadPlacement reads and validates a placement file.

func ReadPlacementUnchecked

func ReadPlacementUnchecked(path string) (*Placement, error)

ReadPlacementUnchecked reads a placement without validating it: a record a person is still writing, which bedrock org create fills and then validates.

func ReadRecord

func ReadRecord(dir, prefix string) (*Placement, error)

ReadRecord reads the hosting organization's record from the root organization's repository: a hosting placement, validated as one.

func (*Placement) Adopt

func (p *Placement) Adopt(code string) error

Adopt records that the application's repository exists on GitHub already, so 1-org adopts it on its first apply instead of making it; an application not registered is an error.

func (*Placement) Adopted

func (p *Placement) Adopted() []string

Adopted are the codes of the applications whose repositories 1-org adopts rather than makes, in placement order.

func (*Placement) Advance

func (p *Placement) Advance(app string) (string, error)

Advance moves the application's registration to its next step in every environment under way and answers that step: identities to grants, grants to complete (""). An application the placement does not list and one registered in full are refused.

func (*Placement) AppID

func (p *Placement) AppID(role AppRole) string

AppID is the App ID the placement records for the role, or empty.

func (*Placement) AppManifest

func (p *Placement) AppManifest(role AppRole) AppManifest

AppManifest is the declaration of one of the organization's apps, as the placement shapes it: what every organization's app holds, what a root organization that keeps libraries adds, and what one without a cloud adds to the infrastructure app. The permissions are the caller's copy.

func (*Placement) AppManifests

func (p *Placement) AppManifests() []AppManifest

AppManifests are the declarations of the apps the placement calls for (Apps), in the order the bootstrap makes them.

func (*Placement) AppName

func (p *Placement) AppName(role AppRole) string

AppName is the app's name on GitHub.

func (*Placement) AppNamePrefix

func (p *Placement) AppNamePrefix() string

AppNamePrefix is the word the apps' names start with (<word>-infrastructure, <word>-deployer, <word>-release): githubAppPrefix when set, else the GitHub organization's login.

func (*Placement) ApplicationHostnames

func (p *Placement) ApplicationHostnames(app, env string) []string

ApplicationHostnames are the hostnames the application serves in the environment, in name order: the recorded ones (Hostnames) less the next revision's twins, else the default rule's, the code under the apps domain with the environment's suffix below production.

func (*Placement) ApplicationHosts

func (p *Placement) ApplicationHosts(app, env string) map[string]string

ApplicationHosts are the entries 2-net's hosts take for the application in the environment, hostname to backend service: the recorded ones verbatim, else the default rule's, the code's hostname and its -next twin on the application's backends in the environment's project.

func (*Placement) ApplicationPlacement

func (p *Placement) ApplicationPlacement(app, repository, bedrockVersion, bedrockSHA256 string) (*derive.Placement, error)

ApplicationPlacement is the first placement of a registered application, every field from this placement but the bedrock pin, which is the bedrock writing it (a release with its pipeline binary's checksum, or a commit pin with none): the prefix, the model's environments, the regions, the domains, the state bucket, the default branch, the release app's slug, the labels, the outlier detection thresholds and the environment projects' ids and numbers, with the framework's welcome image to create the services with, the application's code and its repository's name, and the first environment's database seeded. Approvals, the maintenance windows, the build machine and the instance caps are left to their defaults, the team's to write. It is refused while this placement records no state bucket or lacks an environment project's id or number, which 1-org's outputs give.

func (*Placement) ApplicationProjects

func (p *Placement) ApplicationProjects() (block string, missing []string)

ApplicationProjects is the block an application's placement records for its environments' projects (id and number, as 1-org's project_ids and project_numbers outputs name them), for the environments this placement records both of, and the environments it does not. Production is among them: a release is run again there from GitHub (bedrock rerun), though it is never restored by a run.

func (*Placement) ApplierIdentity

func (p *Placement) ApplierIdentity() string

ApplierIdentity is the email of the apply trigger's runner identity, in the pipeline project.

func (*Placement) ApplyTriggerName

func (p *Placement) ApplyTriggerName() string

ApplyTriggerName is the apply trigger, as 0-bootstrap names it; a root organization's is <prefix>-root-<code>-apply.

func (*Placement) ApprovalEnvironments

func (*Placement) ApprovalEnvironments() []string

ApprovalEnvironments are the environments whose version triggers wait for a release's approval, where the team group holds the approval and an entitlement takes one: every environment but the first, the rule an application's placement derives its own list from when it names none.

func (*Placement) ApprovingReviewCount

func (p *Placement) ApprovingReviewCount() int

ApprovingReviewCount is the approving reviews a pull request needs before it merges, on every application repository's default branch and patch lines and on this repository's default branch: the placement's approvingReviews, or one when it is left out.

func (*Placement) Apps

func (p *Placement) Apps() []AppRole

Apps are the GitHub Apps the placement calls for, in the order the bootstrap makes them: the infrastructure app always; the deployer app when the organization has a cloud, where the applications' pipelines and the plan trigger talk back as it; the release app when it has a cloud or lists libraries, since a release needs an actor whose tag pushes start workflows, which a workflow's own token cannot be, and the infrastructure app's key never leaves the root organization's repository.

func (*Placement) AppsZoneName

func (p *Placement) AppsZoneName() (project, zone string)

AppsZoneName is where the apps domain's zone is: the network project, empty until the placement records 1-org's project_ids (projects.net), and the name 2-net's dns.tf gives the zone, <prefix>-net-gbl-dns-apps.

func (*Placement) BootProject

func (p *Placement) BootProject() string

BootProject is the id of the project the pipeline runs from (the boot project; a root organization's root project), or its REPLACEME form until the placement records it.

func (*Placement) BootstrapRoles

func (p *Placement) BootstrapRoles() []BootstrapRole

BootstrapRoles are the roles the bootstrap needs, by the organization's kind: the table for a root organization; none for a hosting organization, which its root organization creates.

func (*Placement) BreakGlassProjectRoles

func (p *Placement) BreakGlassProjectRoles() []string

BreakGlassProjectRoles are the roles the break-glass account keeps on a root organization's root project beside its Folder Admin on the folder, which the apply keeps and the leftover report passes over: BigQuery Admin, with which it points the billing account's export at the dataset the bootstrap made, and Service Usage Consumer, so a check or a recovery run at its terminal bills its calls' quota to the project. A hosting organization keeps it nothing on a project.

func (*Placement) Bucket

func (p *Placement) Bucket() string

Bucket is the state bucket every backend block names: the seeded one, or the REPLACEME form the seed step's README says to substitute.

func (*Placement) Codes

func (p *Placement) Codes() []string

Codes lists the registered applications' codes, in registration order.

func (*Placement) CommitPin

func (p *Placement) CommitPin() bool

CommitPin reports whether the pin is a commit pin, built with go install.

func (*Placement) Connected

func (p *Placement) Connected() bool

Connected reports whether the placement records the Cloud Build GitHub authorization: the installation id and the token secret's version, which the connections, the repository links and the triggers take.

func (*Placement) ConnectionName

func (p *Placement) ConnectionName() string

ConnectionName is the pipeline project's Cloud Build connection, as 0-bootstrap names it (the bootstrap, for a root organization): regional, in the primary region.

func (*Placement) ConnectionUnset

func (p *Placement) ConnectionUnset() []string

ConnectionUnset names the placement keys of the Cloud Build GitHub authorization that are not recorded yet, in the order the README records them; none when both are.

func (*Placement) CreatedHostingOrganizations

func (p *Placement) CreatedHostingOrganizations() []HostingOrganization

CreatedHostingOrganizations are the hosting organizations whose folder is recorded, the ones 0-bootstrap grants on the shared secrets.

func (*Placement) CreatingIdentity

func (p *Placement) CreatingIdentity() string

CreatingIdentity is the root organization's creating identity, which creates a hosting organization from the apply trigger's run: a service account in the root project.

func (*Placement) CreatingIdentityMember

func (p *Placement) CreatingIdentityMember() string

CreatingIdentityMember is the creating identity as an IAM member.

func (*Placement) DelegatedVanityDomains

func (p *Placement) DelegatedVanityDomains() []string

DelegatedVanityDomains are the vanity domains delegated to the network project, which have a zone there, sorted.

func (*Placement) DeployerKeySecret

func (p *Placement) DeployerKeySecret() string

DeployerKeySecret is the Secret Manager secret holding the deployer GitHub App's private key, as the root organization's bootstrap names it in its root project.

func (*Placement) DeployerKeyVersionName

func (p *Placement) DeployerKeyVersionName() string

DeployerKeyVersionName is the resource name of the deployer key's alias, which 2-env's output carries to every application's pipeline; empty while no project holds the keys.

func (*Placement) DomainNames

func (p *Placement) DomainNames() []string

DomainNames lists the domains a root organization holds zones for, in name order.

func (*Placement) EntitlementDuration

func (p *Placement) EntitlementDuration(name string) string

EntitlementDuration is the longest grant of the entitlement as the layers declare it, in seconds (3600s): the placement's, or the default.

func (*Placement) ExportLocation

func (p *Placement) ExportLocation() string

ExportLocation is where the export's dataset is made: the multi-region of the primary region's continent where Cloud Billing supports one (US, EU), else the primary region itself, which Cloud Billing's export supports for some regions and refuses for others when the export is pointed at the dataset. A dataset's location cannot change.

func (*Placement) FittingSpannerConfigs

func (p *Placement) FittingSpannerConfigs() []string

FittingSpannerConfigs are the multi-region configurations whose read-write regions are the placement's two regions, in the table's order; none when no configuration bedrock knows has them.

func (*Placement) FittingSpannerConfigsCode

func (p *Placement) FittingSpannerConfigsCode() string

FittingSpannerConfigsCode names FittingSpannerConfigs in backticks, joined with "or", for Markdown.

func (*Placement) GrantedEnvironments

func (p *Placement) GrantedEnvironments(app string) []string

GrantedEnvironments lists the environments the application is placed in whose registration is past the identities step, in promotion order: those whose grants the layers render (1-org's public-invoker tag, 2-shr's registry, 2-spn's databases), since the application's identities exist there.

func (*Placement) HasCloud

func (p *Placement) HasCloud() bool

HasCloud reports whether the organization has a Google Cloud side. A hosting organization always has one; a root organization has one when its placement names the Google Cloud organization (organizationId), and none when it holds libraries alone.

func (*Placement) HostingOrganization

func (p *Placement) HostingOrganization(prefix string) *HostingOrganization

HostingOrganization is the record of the hosting organization with the prefix, nil when there is none.

func (*Placement) InfrastructureKeySecret

func (p *Placement) InfrastructureKeySecret() string

InfrastructureKeySecret is the Secret Manager secret holding the infrastructure GitHub App's private key, as the root organization's 0-bootstrap names it in its boot project.

func (*Placement) InstanceCapacities

func (p *Placement) InstanceCapacities(dir string) ([]InstanceCapacity, error)

InstanceCapacities reads each instance's capacity against the placement from the organization checkout's seeded values, 2-env's spanner_instances and 2-spn's processing_units, each at its default when the file or the attribute is not there: the shared instance first, when any environment is on it, then each environment's own in promotion order.

func (*Placement) IsRoot

func (p *Placement) IsRoot() bool

IsRoot reports whether the placement is a root organization's.

func (*Placement) JSON

func (p *Placement) JSON() ([]byte, error)

JSON is the placement as its file holds it, indented the way a person reads it. A root organization without a cloud leaves out every key it has no value for: the keys that name something of Google's would otherwise stand empty in a file that has none.

func (*Placement) KeptVanityDomains

func (p *Placement) KeptVanityDomains() []string

KeptVanityDomains are the vanity domains kept at the customer's DNS provider, sorted.

func (*Placement) KeptVanityRecords

func (p *Placement) KeptVanityRecords(domain string) []string

KeptVanityRecords are the records a kept vanity domain's DNS provider carries, as the rendered README lists them: the host relative to the domain, the type and where the value comes from; bedrock domain check prints them with the values.

func (*Placement) KeyVersion

func (p *Placement) KeyVersion(name string) string

KeyVersion is the version placement.json pins for the secret (github-<app>-key, or github-token), empty while none is pinned.

func (*Placement) KeysElsewhere

func (p *Placement) KeysElsewhere() error

KeysElsewhere refuses, in a hosting organization, what only the root organization that holds the keys does: adding, checking and pinning a version. Nil for a root organization.

func (*Placement) LabelNames

func (p *Placement) LabelNames(domain string) []string

LabelNames lists the labels of the domain handed onward, in name order.

func (*Placement) LayerRuns

func (p *Placement) LayerRuns() []LayerRun

LayerRuns is every run of the triggers in layer order: the five single-run layers, then 2-env once per environment in promotion order; none for a root organization, which has no layer. An identity under a project the placement does not record carries REPLACEME, which the commands refuse to run.

func (*Placement) Layers

func (p *Placement) Layers() []string

Layers are the organization's layers in apply order: the six layers of the hosting model; a root organization has none, since bedrock keeps it by API.

func (*Placement) Library

func (p *Placement) Library(repository string) *Library

Library is the library whose repository has the name, nil when the placement lists none.

func (*Placement) LibraryNames

func (p *Placement) LibraryNames() []string

LibraryNames lists the libraries' repositories in the order the placement lists them.

func (*Placement) Outlier

func (p *Placement) Outlier() derive.Outlier

Outlier is the outlier detection thresholds the pull-request backend is rendered with: the placement's, with the defaults where it sets none.

func (*Placement) OwnIdentity

func (p *Placement) OwnIdentity(member string) bool

OwnIdentity reports whether the member is an identity of the organization's own: a service account in one of its projects (serviceAccount:<name>@<project>.iam.gserviceaccount.com, the project one the placement records), or one of Google's own service agents (@gcp-sa-<service>.iam.gserviceaccount.com), which Google grants where a service needs them. Everything else on the organization's folder is outside the organization.

func (*Placement) OwnInstanceConfigList

func (p *Placement) OwnInstanceConfigList() string

OwnInstanceConfigList is OwnInstanceConfigs as an HCL list, for 2-env's validation.

func (*Placement) OwnInstanceConfigs

func (p *Placement) OwnInstanceConfigs() []string

OwnInstanceConfigs are the configurations an environment's own instance may take (2-env's spanner_instances): the regional one in the primary region, then the multi-region ones that fit the placement's regions.

func (*Placement) OwnInstanceConfigsCode

func (p *Placement) OwnInstanceConfigsCode() string

OwnInstanceConfigsCode names OwnInstanceConfigs as OwnInstanceConfigsProse does, each in backticks, for Markdown.

func (*Placement) OwnInstanceConfigsProse

func (p *Placement) OwnInstanceConfigsProse() string

OwnInstanceConfigsProse names OwnInstanceConfigs for a message: "regional-us-central1 or nam10".

func (*Placement) Pending

func (p *Placement) Pending() []HostingOrganization

Pending are the hosting organizations recorded but not created yet: the ones without a folder, which the creation run creates in record order.

func (*Placement) PinKeyVersion

func (p *Placement) PinKeyVersion(name, version string) error

PinKeyVersion records the version of the secret (github-<app>-key, or github-token) the alias points at: a number, never latest.

func (*Placement) Pinned

func (p *Placement) Pinned() bool

Pinned reports whether the placement pins a bedrock.

func (*Placement) PinnedVersionName

func (p *Placement) PinnedVersionName(name string) string

PinnedVersionName is the resource name of the version the placement pins for the key (projects/<root project>/secrets/<container>/versions/<number>), as the bootstrap reads a key before its apply has pointed the alias at it; empty while the placement pins none or records no root project.

func (*Placement) Place

func (p *Placement) Place(code string, environments []string) (added, dropped []string, err error)

Place sets the environments an application registered in full is placed in, a prefix of the promotion order named in full, and answers the environments added and dropped. An added environment starts at the first step of the application's registration there, which register --next moves on. A dropped environment must be out of service already (bedrock org teardown <app> <env>, the stack torn down there), so that nothing the layers own there is left behind; its out-of-service entry and its recorded hostnames go with it. An application whose registration is under way is refused until it completes.

func (*Placement) Placed

func (p *Placement) Placed(code, env string) bool

Placed reports whether the application is placed in the environment.

func (*Placement) PlacedEnvironments

func (p *Placement) PlacedEnvironments(code string) []string

PlacedEnvironments are the environments the application is placed in, in promotion order: its entry's list, or every environment when the entry names none; none for an application the placement does not list.

func (*Placement) PlanTriggerName

func (p *Placement) PlanTriggerName() string

PlanTriggerName is the plan trigger, as 0-bootstrap names it (<prefix>-boot-<code>-layers-plan); a root organization's is <prefix>-root-<code>-plan, since it plans no layer.

func (*Placement) PlannerIdentity

func (p *Placement) PlannerIdentity() string

PlannerIdentity is the email of the plan trigger's runner identity, in the pipeline project (<prefix>-org-gbl-planner; a root organization's <prefix>-root-gbl-planner).

func (*Placement) Primary

func (p *Placement) Primary() Region

Primary is the primary region.

func (*Placement) Project

func (p *Placement) Project(key string) string

Project is the project id under a key (boot, or an environment or shared project), or the REPLACEME form until the seed or 1-org has run and the placement records it.

func (*Placement) ProjectKeys

func (p *Placement) ProjectKeys() []string

ProjectKeys are the organization's projects by key, in layer order, by its kind: the boot project, the shared projects and the environment projects, or the root project alone.

func (*Placement) ProjectLabels

func (p *Placement) ProjectLabels(layer, environment string) map[string]string

ProjectLabels are the labels the seed gives the boot project and the state bucket, as the layers label what they make: the model's own, with the placement's.

func (*Placement) PutInService

func (p *Placement) PutInService(app string, envs []string) ([]string, error)

PutInService removes the environments from the application's out-of-service entry (every environment when none is given) and answers the ones removed; an application not registered in full, an environment the model lacks, and environments in service already are refused.

func (*Placement) Record

func (p *Placement) Record(h *Placement) bool

Record adds the hosting organization to the root organization's placement (hostingOrganizations: its prefix and its boot project), or updates the boot project of a record that has it, leaving a recorded folder as it is. It reports whether the placement changed.

func (*Placement) RecordHostnames

func (p *Placement) RecordHostnames(app string, byEnv map[string]map[string]string) (bool, error)

RecordHostnames records the hosts the application's stack serves, by environment (hostname to backend service, every site's and the next revision's twins, as the stack's net_hosts output lists them), as read from its state, for the environments given, keeping the record of the others, and reports whether the record changed. Each environment given is one the application is placed in and has at least one entry; what is recorded is held to the same rules as the placement is (Validate), so a hostname another application serves is refused here, before the placement is written.

func (*Placement) RegionalSpannerConfig

func (p *Placement) RegionalSpannerConfig() string

RegionalSpannerConfig is the regional configuration of an environment's own instance: regional-<primary region>, where the primary Cloud Run service runs.

func (*Placement) Register

func (p *Placement) Register(code, repository string, environments []string) error

Register adds an application to the placement, placed in the environments given (a prefix of the promotion order; none means every environment), at the first step of its registration in each: a code under the one rule (derive.ValidateApplicationCode) not registered yet, and a repository name no other application has.

func (*Placement) Registered

func (p *Placement) Registered(code string) bool

Registered reports whether an application is registered under the code.

func (*Placement) ReleaseAppLogin

func (p *Placement) ReleaseAppLogin() string

ReleaseAppLogin is the login the release app's actions carry (<slug>[bot]), which a library's release workflow accepts a release from; empty while no release app is recorded.

func (*Placement) ReleaseAppSlug

func (p *Placement) ReleaseAppSlug() string

ReleaseAppSlug is the release app's slug, the name in its page's address, as every application's placement records the author of its releases: the slug the root organization recorded when the app was made, or the app's declared name, which GitHub takes as the slug when no other app has it.

func (*Placement) ReleaseKeySecret

func (p *Placement) ReleaseKeySecret() string

ReleaseKeySecret is the Secret Manager secret holding the release GitHub App's private key, as the root organization's bootstrap names it in its root project.

func (*Placement) ReleaseKeyVersionName

func (p *Placement) ReleaseKeyVersionName() string

ReleaseKeyVersionName is the resource name of the release key's alias, which 2-env's output carries to every application's release trigger; empty while no project holds the keys.

func (*Placement) Repository

func (p *Placement) Repository(code string) string

Repository is the repository of the application registered under the code, the name a person knows the application by; the code itself for an application the placement does not list.

func (*Placement) RepositoryLinkName

func (p *Placement) RepositoryLinkName() string

RepositoryLinkName is the infrastructure repository's link under the connection, which the triggers watch.

func (*Placement) RerunExample

func (p *Placement) RerunExample() string

RerunExample is the substitutions a person starts the apply trigger by hand with, as the READMEs and the triggers' comments show them: 2-env for one environment in the hosting model. A root organization's apply trigger takes none: it applies the whole record every run.

func (*Placement) Retire

func (p *Placement) Retire(code string) error

Retire takes a registered application out of the placement: its entry, its registration step, its out-of-service record and its hostnames, so that every layer renders without it (bedrock org retire, once the application is torn down and destroyed and its repository archived and out of 1-org's state). An application the placement does not register is refused.

func (*Placement) RootOrganization

func (p *Placement) RootOrganization() string

RootOrganization is the prefix of the organization whose boot project holds the keys, which names the secrets: a root organization's own, a hosting organization's root.organization (empty while unrecorded).

func (*Placement) RootProject

func (p *Placement) RootProject() string

RootProject is the project holding the keys: a root organization's root project (projects.root, empty until the bootstrap records it), a hosting organization's root.project.

func (*Placement) Routed

func (p *Placement) Routed(app, env string) bool

Routed says whether 2-net serves the application's hostnames in the environment: the application is placed there and registered in full there, the organization is not torn down, and the environment is not out of service.

func (*Placement) Secondary

func (p *Placement) Secondary() Region

Secondary is the secondary region.

func (*Placement) SecretContainer

func (p *Placement) SecretContainer(name string) string

SecretContainer is the secret's name in the project that holds the keys and the token.

func (*Placement) SecretProject

func (p *Placement) SecretProject() (string, error)

SecretProject is the project holding the keys as the placement records it: a root organization's root project (projects.root), a hosting organization's root.project. One not recorded yet is refused.

func (*Placement) SecretVersionName

func (p *Placement) SecretVersionName(name string) string

SecretVersionName is the resource name every reader of the key names: the secret's alias current in the project that holds the keys, which that organization's apply points at the version pinned. Empty while the placement records no such project.

func (*Placement) Served

func (p *Placement) Served() []string

Served lists the applications registered in full in at least one environment, in registration order: those with hostnames in 2-net.

func (*Placement) ServedEnvironments

func (p *Placement) ServedEnvironments(app string) []string

ServedEnvironments lists the environments the application is registered in full in, in promotion order: those whose hostnames 2-net serves, since the stack's backends exist there.

func (*Placement) SetApp

func (p *Placement) SetApp(role AppRole, app *github.App)

SetApp records the app's id, and for the release app its slug, as GitHub gave them.

func (*Placement) SharedInstanceEnvironments

func (*Placement) SharedInstanceEnvironments() []string

SharedInstanceEnvironments are the environments whose databases live on the shared instance 2-spn creates, where that layer declares the Spanner entitlements: every environment but the first, whose instance is its own.

func (*Placement) SharedSecrets

func (p *Placement) SharedSecrets() []string

SharedSecrets are the secrets a root organization holds for every organization, by resource name: the three GitHub Apps' keys, and the Cloud Build token once the authorization is recorded.

func (*Placement) StackTriggerName

func (p *Placement) StackTriggerName(env, code string) string

StackTriggerName is an application's stack trigger in an environment, as 2-env names it (cloud-build.tf): the trigger the application's operations workflow starts for its apply action, in the environment's project and the primary region.

func (*Placement) Step

func (p *Placement) Step(app string) string

Step is the step the application's registration is at in the environments under way, the same in each (Validate): RegistrationIdentities, RegistrationGrants, or "" for an application registered in full wherever it is placed.

func (*Placement) StepIn

func (p *Placement) StepIn(app, env string) string

StepIn is how far the application's registration has gone in the environment: RegistrationIdentities, RegistrationGrants, or "" for an environment registered in full, or one the application is not placed in.

func (*Placement) TakeOutOfService

func (p *Placement) TakeOutOfService(app string, envs []string) ([]string, error)

TakeOutOfService adds the environments to the application's out-of-service entry (every environment when none is given) and answers the ones added; an application not registered in full, an environment the model lacks, and environments all out of service already are refused.

func (*Placement) TeamGroup

func (p *Placement) TeamGroup(env string) string

TeamGroup is the environment's team group as an IAM member (group:<address>).

func (*Placement) TeamGroupAddress

func (p *Placement) TeamGroupAddress(env string) string

TeamGroupAddress is the environment's team group as the address the Workspace Admin console names it by, where the approvals are mailed.

func (*Placement) TokenSecret

func (p *Placement) TokenSecret() *TokenSecret

TokenSecret reads the token secret's parts off the version's resource name, or nil while the placement records none.

func (*Placement) TokenSecretID

func (p *Placement) TokenSecretID() string

TokenSecretID is the id of the secret a root organization's bootstrap puts the Bot Account's token in, in the root project (<prefix>-root-gbl-github-token), which every Cloud Build connection authorizes with through its alias current.

func (*Placement) TokenSecretLocation

func (p *Placement) TokenSecretLocation() string

TokenSecretLocation is the region of a regional token secret, empty for a global one.

func (*Placement) TokenSecretName

func (p *Placement) TokenSecretName() string

TokenSecretName is the token secret's resource name without its version (projects/P[/locations/L]/secrets/N), empty while unrecorded.

func (*Placement) TokenSecretProject

func (p *Placement) TokenSecretProject() string

TokenSecretProject is the project of the secret cloudBuildTokenSecretVersion names (projects/<project>/...), empty while unrecorded.

func (*Placement) TokenSecretRegional

func (p *Placement) TokenSecretRegional() bool

TokenSecretRegional reports whether the Cloud Build token secret the placement names is a regional one (projects/P/locations/L/secrets/N), as the console's host-connection flow writes it.

func (*Placement) TriggerBuildTimeoutSeconds

func (p *Placement) TriggerBuildTimeoutSeconds(command string) int

TriggerBuildTimeoutSeconds is the whole build's timeout for the trigger that ends in the command: the sum of its steps' timeouts.

func (*Placement) TriggerSteps

func (p *Placement) TriggerSteps(command string) []TriggerStep

TriggerSteps are the steps of the trigger that ends in the command (plan or apply): FetchBedrock, which puts the pinned bedrock in place from placement.json at run time (and BuildBedrock after it for a commit pin), Check, and the command's own step.

func (*Placement) TriggerSubstitutions

func (p *Placement) TriggerSubstitutions() map[string]string

TriggerSubstitutions are the substitutions both triggers carry: the shape of their steps, which bedrock org plan and apply compare with their own; a hosting organization's triggers add _LAYER and _ENVIRONMENT (cloud-build.tf).

func (*Placement) UnderWay

func (p *Placement) UnderWay(app string) []string

UnderWay lists the environments whose registration of the application is under way, in promotion order; none for an application registered in full.

func (*Placement) UnrecordedProjects

func (p *Placement) UnrecordedProjects() []string

UnrecordedProjects names the projects the placement does not record yet, as the keys a person records (projects.<key>): the layer identities of such a project are rendered with REPLACEME, and a run of the triggers refuses to plan or apply its layer. Empty once every layer can run.

func (*Placement) Validate

func (p *Placement) Validate() error

Validate refuses a placement a layer could not be rendered from: what every organization has, then what its kind renders from.

func (*Placement) ValidateDraft

func (p *Placement) ValidateDraft() error

ValidateDraft holds the placement bedrock org bootstrap drafts, from its flags, the discovery and the prompts, to the rules before anything is made: what Validate holds a finished placement to, less what the bootstrap itself records (the project and the bucket, the apps and their keys, the Bot Account and the Cloud Build authorization).

func (*Placement) VanityAuthorizationName

func (p *Placement) VanityAuthorizationName(domain string) string

VanityAuthorizationName is the name 2-net gives the vanity domain's DNS authorization in Certificate Manager, from which the check reads the authorization record of a kept domain, which no zone here holds.

func (*Placement) VanityDomainNames

func (p *Placement) VanityDomainNames() []string

VanityDomainNames are the vanity domains, sorted.

func (*Placement) VanityDomainOf

func (p *Placement) VanityDomainOf(host string) (domain, label string, ok bool)

VanityDomainOf is the declared vanity domain a hostname is on, the domain itself or one label below it, and the label (empty for the domain itself); none when the hostname is on no declared vanity domain.

func (*Placement) VanityHostnames

func (p *Placement) VanityHostnames(domain string) []string

VanityHostnames are the hostnames the organization records on the vanity domain, the domain itself and labels of it, sorted: what a kept domain's DNS provider carries an A record for.

func (*Placement) VanityKept

func (p *Placement) VanityKept(domain string) bool

VanityKept reports whether the vanity domain is kept at the customer's DNS provider.

func (*Placement) VanityNames

func (p *Placement) VanityNames(domain string) string

VanityNames is the longest name 2-net derives from a vanity domain, the wildcard certificate map entry's, which bounds the domain's length: the prefix, -net-gbl-cme-, the domain with hyphens for its dots, and -wildcard.

func (*Placement) VanityZone

func (p *Placement) VanityZone(domain string) (project, zone string)

VanityZone is where a vanity domain's zone is: the network project, as AppsZoneName, and the name 2-net's dns.tf gives the zone, <prefix>-net-gbl-dns-<the domain with hyphens for its dots>, the name a parked zone of the same domain has (domains.tf), so a domain registered here before it was declared keeps its zone.

func (*Placement) Write

func (p *Placement) Write(path string) error

Write puts the placement back in its file, indented the way a person reads it.

func (*Placement) ZoneName

func (p *Placement) ZoneName(domain string) string

ZoneName is the name a root organization gives a domain's zone in the root project: <prefix>-root-gbl-dns-<the domain with hyphens for its dots>, the shape 2-net gives a vanity domain's zone in the network project.

func (*Placement) ZoneProject

func (p *Placement) ZoneProject() string

ZoneProject is where a root organization's zones are: the root project, empty until the bootstrap records it (projects.root).

type PolicyReader

type PolicyReader interface {
	// ProjectPolicy is the project's bindings, by role.
	ProjectPolicy(ctx context.Context, project string) ([]Binding, error)
	// OrganizationFolder is the id of the folder named name directly under the
	// organization (its numeric id), or empty when there is none.
	OrganizationFolder(ctx context.Context, organizationID, name string) (string, error)
	// ChildFolders are the folders directly under the folder (its numeric id).
	ChildFolders(ctx context.Context, folder string) ([]Folder, error)
	// FolderPolicy is the folder's bindings, by role.
	FolderPolicy(ctx context.Context, folder string) ([]Binding, error)
	// Close releases the connection.
	Close() error
}

PolicyReader reads IAM policies and finds the organization's folders. NewPolicyReader is the real one, over Cloud Resource Manager; tests pass a fake.

func NewPolicyReader

func NewPolicyReader(ctx context.Context) (PolicyReader, error)

NewPolicyReader opens the Cloud Resource Manager clients with Application Default Credentials; without any, the open fails and says so.

type PolicyReaderFunc

type PolicyReaderFunc func(ctx context.Context) (PolicyReader, error)

PolicyReaderFunc opens a PolicyReader.

type PreflightResult

type PreflightResult struct {
	OrganizationID    string
	BillingAccount    string
	BreakGlassAccount string
	Checks            []RoleCheck
}

PreflightResult is what the check found: the placement's organization, billing account and break-glass account, and each role's answer in the table's order.

func CheckPermissions

func CheckPermissions(ctx context.Context, p *Placement, tester PermissionTester) (*PreflightResult, error)

CheckPermissions asks, once per scope, which of the bootstrap roles' permissions the caller holds, and answers each role with the permissions it lacks. An API that refuses to answer fails the check.

func (*PreflightResult) Missing

func (r *PreflightResult) Missing() []RoleCheck

Missing are the roles whose permissions the caller does not all hold.

func (*PreflightResult) Write

func (r *PreflightResult) Write(w io.Writer)

Write prints one line per role, holds or missing with the permissions tested (all of them when held, the ones lacking when not), then what to do.

type PublicInvokerTag

type PublicInvokerTag struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

PublicInvokerTag is an environment project's public-invoker tag: the key and its value true, as resource names (tagKeys/N, tagValues/N), which the domain-restricted sharing policy on the environment's folder names in its exception, and an application stack binds to a Cloud Run service before granting allUsers.

type Record

type Record struct {
	Name string   `json:"name"`
	Type string   `json:"type"`
	TTL  int64    `json:"ttl,omitempty"`
	Data []string `json:"data"`
}

Record is one record set a zone carries for the person who declared it: its name under the domain ("@" for the apex, else a label, or labels joined with dots), its type, its time to live in seconds (300 unless given) and its values as Cloud DNS takes them, except that a TXT value is quoted by the apply when it is not already.

type Region

type Region struct {
	Name string `json:"name"`
	Code string `json:"code"`
}

Region is one region: its name and the three-letter code resource names carry.

type RegistrationSteps

type RegistrationSteps map[string]string

RegistrationSteps is how far an application's registration has gone in each environment under way, by environment: RegistrationIdentities, then RegistrationGrants; an environment absent from it is registered in full. Every environment under way is at the same step (Validate), since register --next moves them together and bedrock org place adds an environment to an application registered in full alone. A placement written before the steps were per environment names one step for the application, which reads as that step in every environment it is placed in.

func EveryEnvironment

func EveryEnvironment(step string) RegistrationSteps

EveryEnvironment is the steps of an application placed in every environment, each at the step: what the older form of the field meant.

func (*RegistrationSteps) UnmarshalJSON

func (s *RegistrationSteps) UnmarshalJSON(data []byte) error

UnmarshalJSON reads the steps as written, or as the older form wrote them: one step for the application.

type Report

type Report struct {
	// Dir is the repository directory checked.
	Dir string
	// Checked counts the owned files compared.
	Checked int
	// Findings are the owned files that differ or are missing, in path order, then the
	// files refused with a reason.
	Findings []Finding
	// Unseeded lists the seeded files the repository lacks: not drift, since the tool
	// writes them once and a person keeps them, but worth a line.
	Unseeded []string
}

Report is the outcome of one check.

func Check

func Check(p *Placement, dir string) (*Report, error)

Check renders the placement and compares the owned files with the repository's; then it refuses, in each layer, every .tf file the render does not produce and every override file (OpenTofu merges an override.tf or *_override.tf into the layer, so a pull request could change what the layers declare without touching a rendered file).

func (*Report) Clean

func (r *Report) Clean() bool

Clean reports no drift and nothing refused.

type RoleCheck

type RoleCheck struct {
	BootstrapRole
	Missing []string
}

RoleCheck is one bootstrap role and the permissions tested for it that the caller lacks; none when the caller holds them all.

func (RoleCheck) Held

func (c RoleCheck) Held() bool

Held reports whether the caller holds every permission tested for the role.

type RootPlace

type RootPlace struct {
	// Organization is the root organization's prefix, which names its secrets
	// (<prefix>-root-gbl-github-<app>-key).
	Organization string `json:"organization"`
	// Project is the root organization's root project, where the secrets live.
	Project string `json:"project"`
}

RootPlace names the root organization whose boot project holds the GitHub Apps' keys, in a hosting organization's placement (root).

type Scope

type Scope string

Scope is where a bootstrap role is granted and its permissions are tested.

const (
	// OnOrganization is the organization node: the roles there reach every folder and
	// project under it.
	OnOrganization Scope = "organization"
	// OnBillingAccount is the billing account the projects are linked to.
	OnBillingAccount Scope = "billing account"
)

The two places the break-glass account holds roles above the organization's folder.

type SecretAddRequest

type SecretAddRequest struct {
	// Secret is the organization secret's name.
	Secret string
	// Project and Container are where the version goes.
	Project   string
	Container string
	// Value is the secret value, stored as given.
	Value []byte
}

SecretAddRequest is what secret add was asked to do with an organization secret.

type SecretAddResult

type SecretAddResult struct {
	Secret    string
	Project   string
	Container string
	Version   string
}

SecretAddResult is what secret add did: the version added, and where.

func AddSecret

func AddSecret(ctx context.Context, open secret.ClientFunc, req *SecretAddRequest) (*SecretAddResult, error)

AddSecret stores the value as a new version of the secret's container. The container is 0-bootstrap's own resource, created by its apply and not adopted, so one the project lacks is refused rather than created: the layer's next apply would fail on it.

func (*SecretAddResult) Write

func (r *SecretAddResult) Write(w io.Writer)

Write prints what was added and the pin to make.

type SecretPinRequest

type SecretPinRequest struct {
	// Secret is the organization secret's name; Version the version's number.
	Secret  string
	Version string
	// Dir is the infrastructure repository's root, holding placement.json.
	Dir string
	// Project and Container are where the version is verified.
	Project   string
	Container string
}

SecretPinRequest is what secret pin was asked to do with an organization secret.

type SecretPinResult

type SecretPinResult struct {
	Secret  string
	Version string
	// File is where the pin went (placement.json) and Key the key it went under.
	File string
	Key  string
	// Unchanged is true when the version was pinned already and nothing was written.
	Unchanged bool
	// Project and Container are where Secret Manager confirmed the version enabled.
	Project   string
	Container string
	// Rendered is the number of owned files org render wrote after the placement
	// changed.
	Rendered int
	// AppUnset is true when the app's id is not recorded beside its key.
	AppUnset bool
}

SecretPinResult is what secret pin found and did.

func PinSecret

PinSecret writes the version the secret's alias is to point at, after Secret Manager confirms it is enabled: the version's number in the root organization's placement.json (githubInfrastructureKeyVersion, githubDeployerKeyVersion or githubReleaseKeyVersion), followed by org render, which writes the alias into 0-bootstrap's github.tf; the apply moves it, and every reader in every organization follows. A version that is not a number (latest among them) is refused, a hosting organization is sent to the root organization that holds the keys, and a version pinned already leaves every file as it is.

func (*SecretPinResult) Write

func (r *SecretPinResult) Write(w io.Writer)

Write prints what was pinned, where, and what to do next.

type Seed

type Seed struct {
	OrganizationFolder string
	TerraformFolder    string
}

Seed is what the creation learns as it makes the organization's folders: their numeric ids, which the seeded tfvars of the new repository carry. Nil renders REPLACEME, as org new does before the creation has recorded them.

type Spanner

type Spanner struct {
	// Config is the instance configuration, a multi-region one bedrock knows
	// (SpannerConfigs) whose read-write replicas are the two regions (nam10 for
	// us-central1 and us-west3); any other is refused, naming the ones that fit.
	Config string `json:"config"`
}

Spanner is the shared instance's configuration.

type SpannerConfig

type SpannerConfig struct {
	Name      string
	ReadWrite [2]string
}

SpannerConfig is a multi-region instance configuration and the two regions its read-write replicas are in.

type TokenCheckResult

type TokenCheckResult struct {
	Version   string
	Project   string
	Container string
	// Login is the account GitHub says the token is, the Bot Account's; Organization the
	// GitHub organization it owns.
	Login        string
	Organization string
	// Pinned is the version the alias points at as placement.json pins it, or empty.
	Pinned string
}

TokenCheckResult is what the token's check found.

func CheckToken

func CheckToken(ctx context.Context, open secret.ClientFunc, access KeyAccessFunc, identity TokenIdentityFunc, p *Placement, req *KeyCheckRequest) (*TokenCheckResult, error)

CheckToken proves the version of the Bot Account's token: it must be enabled, and GitHub must say it is the Bot Account's (githubBotAccount) and the account an owner of the organization. A hosting organization is sent to the root organization that holds it.

func (*TokenCheckResult) Write

func (r *TokenCheckResult) Write(w io.Writer)

Write prints what was proven and what moves the alias.

type TokenIdentityFunc

type TokenIdentityFunc func(ctx context.Context, token, organization string) (string, error)

TokenIdentityFunc asks GitHub whose the token is and that the account owns the organization, answering the login; a token that is not a personal access token, not a member's or not an owner's is refused with why.

type TokenSecret

type TokenSecret struct {
	Project  string
	Location string
	Secret   string
}

TokenSecret is the connections' token secret by the parts of its resource name: its project, its location (empty for a global secret) and its id.

type TriggerStep

type TriggerStep struct {
	ID             string
	Image          string
	Entrypoint     string
	Args           []string
	Env            []string
	TimeoutSeconds int
}

TriggerStep is one step of the triggers' builds, as the root organization's apply makes a trigger from it and as 0-bootstrap's render writes it (cloud-build.tf).

type UnrestrictedKey

type UnrestrictedKey struct {
	Environment string
	Project     string
	Key         APIKey
}

UnrestrictedKey is one API key in an environment project that carries no API restriction.

func UnrestrictedKeys

func UnrestrictedKeys(ctx context.Context, p *Placement, list KeyLister) (keys []UnrestrictedKey, unrecorded []string, err error)

UnrestrictedKeys lists, for each environment project the placement records, in promotion order, every API key that carries no API restriction. Unrecorded names the environments the placement records no project for, which are not read.

type VanityDomain

type VanityDomain struct {
	// DNS says where the domain's zone lives: empty, delegated to the network project,
	// whose zone serves it (2-net makes the zone; the registrar or the parent's provider
	// is pointed at it, once); "customer", kept at the customer's DNS provider, which
	// stays authoritative for the domain, its mail and every other record untouched, and
	// carries the records bedrock prints (an A record per hostname the applications
	// declare on the domain, at the load balancer's address, and the certificate's
	// authorization CNAME): no zone here, named records there, never a wildcard.
	DNS string `json:"dns,omitempty"`
}

VanityDomain is what the placement says about one vanity domain beyond its name.

type VanityDomains

type VanityDomains map[string]VanityDomain

VanityDomains are the vanity domains by domain. The type exists for the list the field was before: a placement written then is refused with what the field is now, not with a decoding error.

func (*VanityDomains) UnmarshalJSON

func (v *VanityDomains) UnmarshalJSON(data []byte) error

UnmarshalJSON reads the map, and refuses the list the field was.

type Written

type Written struct {
	*render.Written
}

Written is what Write did: the files written.

func Write

func Write(p *Placement, files []render.File, dir string) (*Written, error)

Write puts the files into the repository directory, creating it and the layer directories when absent: owned files always, seeded files only when absent.

type ZoneRecord

type ZoneRecord struct {
	Name        string   `json:"name"`
	NameServers []string `json:"nameServers"`
}

ZoneRecord is the apps domain's zone as the creation recorded it: its name in the net project (<prefix>-net-gbl-dns-apps, as AppsZoneName names it) and the name servers Cloud DNS assigned it, as Cloud DNS spells them (with the trailing dot).

Jump to

Keyboard shortcuts

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