Documentation
¶
Overview ¶
Package deploy is the deploy sequence as commands: each step of the pipeline (the deployment record first; the others follow) over the same inputs, the facts the pipeline's resolve step writes to the workspace and the build's own substitutions, so a pipeline file composes them and an application with nothing custom lists them all.
Index ¶
- Constants
- Variables
- func AppIdentity(ctx context.Context, gh GitHubFunc, appID string, pemKey []byte) (*github.App, error)
- func AppInstallationToken(ctx context.Context, gh GitHubFunc, appID string, pemKey []byte, ...) (string, error)
- func AppInstallations(ctx context.Context, gh GitHubFunc, appID string, pemKey []byte) ([]github.Installation, error)
- func AppOrgInstallationToken(ctx context.Context, gh GitHubFunc, appID string, pemKey []byte, ...) (token string, installation int64, err error)
- func ApplyEnvironmentStack(ctx context.Context, clients *Clients, w Workspace, out io.Writer) error
- func BuildImage(ctx context.Context, clients *Clients, w Workspace, ...) error
- func CheckRelease(ctx context.Context, clients *Clients, w Workspace, out io.Writer) error
- func Deploy(ctx context.Context, clients *Clients, w Workspace, out io.Writer) error
- func FirstApply(ctx context.Context, clients *Clients, w Workspace, req *BuildRequest, ...) error
- func GitHubComments(ctx context.Context, token, repoFullName string, number int) ([]github.Comment, error)
- func GoogleIDToken(ctx context.Context, audience string) (string, error)
- func GuardMigrations(ctx context.Context, clients *Clients, w Workspace, out io.Writer) error
- func Hook(ctx context.Context, clients *Clients, w Workspace, stage hook.Stage, ...) error
- func Jobs(ctx context.Context, clients *Clients, w Workspace, out io.Writer) error
- func MaintenanceOff(ctx context.Context, clients *Clients, w Workspace, out io.Writer) error
- func MaintenanceOn(ctx context.Context, clients *Clients, w Workspace, window bool, out io.Writer) error
- func Migrate(ctx context.Context, clients *Clients, w Workspace, ...) error
- func NetHosts(ctx context.Context, clients *Clients, bucket string) (map[string]string, error)
- func Persona(ctx context.Context, clients *Clients, w Workspace, action PersonaAction, ...) error
- func PlanEnvironmentStack(ctx context.Context, clients *Clients, w Workspace, out io.Writer) error
- func PlanEnvironments(ctx context.Context, clients *Clients, w Workspace, req *BuildRequest, ...) error
- func Principal(ctx context.Context) (string, error)
- func PublicGitHub(token string) *github.Client
- func PullRequestStack(ctx context.Context, clients *Clients, w Workspace, req *BuildRequest, ...) error
- func PullRequestStacks(ctx context.Context, clients *Clients, req *TeardownRequest) ([]string, error)
- func ReadStackOutputs(ctx context.Context, clients *Clients, w Workspace, out io.Writer) error
- func RunRelease(ctx context.Context, clients *Clients, req *ReleaseRequest, out io.Writer) error
- func ShiftTraffic(ctx context.Context, clients *Clients, w Workspace, out io.Writer) error
- func Sleep(ctx context.Context, d time.Duration) error
- func StackOutputsObject(app, env, number, commit string) string
- func StackTeardown(ctx context.Context, clients *Clients, w Workspace, req *BuildRequest, ...) error
- func StartReleaseBackup(ctx context.Context, clients *Clients, w Workspace, now time.Time, ...) error
- func Sweep(ctx context.Context, clients *Clients, w Workspace, req *BuildRequest, ...) error
- func SweepJobs(ctx context.Context, clients *Clients, w Workspace, out io.Writer) error
- func TalkBack(ctx context.Context, clients *Clients, w Workspace, out io.Writer) error
- func TeardownPullRequests(ctx context.Context, clients *Clients, req *TeardownRequest, numbers []string, ...) error
- func ValidateRelease(ctx context.Context, clients *Clients, w Workspace, bedrock string, ...) error
- func WaitForWindow(ctx context.Context, clients *Clients, w Workspace, out io.Writer) error
- func WriteRecord(ctx context.Context, open StoreFunc, req *RecordRequest, out io.Writer) error
- type ApplicationTeardown
- type Approval
- type Backup
- type Build
- type BuildApproval
- type BuildApprovalResult
- type BuildRequest
- type BuildStep
- type Builds
- type BuildsFunc
- type Clients
- type Command
- type CommentsFunc
- type Database
- type DatabaseRef
- type EnvironmentTeardown
- type Facts
- type Firestore
- type FirestoreAsFunc
- type Force
- type GitHubFunc
- type Grants
- type GrantsFunc
- type IDTokenFunc
- type JobTemplate
- type LiveRelease
- type Maintenance
- type Metrics
- type MetricsFunc
- type MigrateAction
- type Migration
- type MigrationVersion
- type OSRunner
- type PersonaAction
- type Record
- type RecordRequest
- type Registry
- type RegistryFunc
- type ReleaseBackup
- type ReleaseRequest
- type ResolveRequest
- type Restore
- type RetiredSecret
- type Retirement
- type Revision
- type RevisionTemplates
- type Rollback
- type Run
- type RunFunc
- type Runner
- type SecretReference
- type Secrets
- type SecretsAsFunc
- type SecretsFunc
- type ServiceTemplate
- type SleepFunc
- type Spanner
- type SpannerAsFunc
- type SpannerFunc
- type StackChange
- type StackOutput
- type StackOutputs
- type StackPlan
- type Standing
- type Store
- type StoreAsFunc
- type StoreFunc
- type Tasks
- type TasksFunc
- type TeardownRecord
- type TeardownRequest
- type Versions
- type VersionsFunc
- type Window
- type Workspace
- func (w Workspace) Append(facts map[string]string) error
- func (w Workspace) Build() (*Build, error)
- func (w Workspace) BuildArgs() ([]string, error)
- func (w Workspace) Environment() (map[string]string, error)
- func (w Workspace) Revisions() ([]Revision, error)
- func (w Workspace) WriteRevisions(revisions []Revision) error
Constants ¶
const ( // EnvironmentFile holds the facts the resolve step exports, one `export NAME=value` // per line, appended to by later steps (the image digest, the reuse flag). EnvironmentFile = "environment.sh" // BuildFile is the build as Cloud Build describes it (gcloud builds describe, JSON): // its id and every substitution. BuildFile = "build.json" // RevisionsFile lists the revisions the deploy step created, one `region,service, // revision` per line. RevisionsFile = "revisions.txt" )
The files a build's steps share under the workspace.
const ( // StackPlanFile is the tag build's saved plan of the environment's stack, in the // workspace, which the apply applies. StackPlanFile = "stack.plan" // StackPlanJSONFile is that plan's JSON, beside it, whose summary the record carries. StackPlanJSONFile = "stack-plan.json" )
const ( StackApplied = "applied" StackDestroyed = "destroyed" StackFailed = "failed" )
The statuses an outputs object carries.
const ( // PlanFile is the saved plan, and PlanJSONFile the plan as tofu show -json writes // it, which the guard reads. PlanFile = "pr.plan" PlanJSONFile = "pr-plan.json" )
The files the stack's steps leave in the workspace, and what they read.
const ( Live = "live" Preview = "preview" )
The two statuses a record carries.
const ( BackupReady = "READY" BackupCreating = "CREATING" )
Spanner's backup states.
const ( DatabaseReady = "READY" DatabaseReadyOptimizing = "READY_OPTIMIZING" )
Spanner's database states that serve.
const ( // BuildArgsFile holds the image build's arguments, one NAME=value per line: the // declared substitutions resolve writes, then what a hook before the build appends. BuildArgsFile = "build-args.txt" )
const ( // MetadataFile is what docker buildx writes about the image it pushed; its // containerimage.digest is the image's digest. MetadataFile = "image-metadata.json" )
The image build's inputs and what it leaves.
const ( // RevisionTemplatesFile is the workspace file holding the release's revision // templates, as the stack's output says them. RevisionTemplatesFile = "revision-templates.json" )
Variables ¶
var PersonaActions = []PersonaAction{PersonaRegister, PersonaRemove}
PersonaActions lists the actions.
Functions ¶
func AppIdentity ¶
func AppIdentity(ctx context.Context, gh GitHubFunc, appID string, pemKey []byte) (*github.App, error)
AppIdentity asks GitHub which app a key signs as: a JWT issued by appID and signed with the key in PEM fetches the app's own record, which GitHub gives for the app's own key alone. A key that is not the app's, or an App ID that is another app's, is refused by GitHub. bedrock org secrets check proves a key's version with it.
func AppInstallationToken ¶
func AppInstallationToken(ctx context.Context, gh GitHubFunc, appID string, pemKey []byte, owner, repo, what string) (string, error)
AppInstallationToken mints a GitHub App's installation token on the repository from the app's private key in PEM: a JWT signed with the key asks GitHub for the app's installation on the repository and then for a token good for an hour. what names the app in a refusal (the deployer app, the infrastructure app).
func AppInstallations ¶
func AppInstallations(ctx context.Context, gh GitHubFunc, appID string, pemKey []byte) ([]github.Installation, error)
AppInstallations asks GitHub where the app a key signs as is installed: a JWT issued by appID and signed with the key in PEM lists the app's installations, which GitHub gives for the app's own key alone. bedrock org check holds an app to its declaration with it.
func AppOrgInstallationToken ¶
func AppOrgInstallationToken(ctx context.Context, gh GitHubFunc, appID string, pemKey []byte, organization, what string) (token string, installation int64, err error)
AppOrgInstallationToken mints a GitHub App's installation token on the organization from the app's private key in PEM, for an organization that has no repository of the app's yet: the app's own listing of its installations names the organization's, and a token is minted for it. It answers the installation's id with the token.
func ApplyEnvironmentStack ¶
ApplyEnvironmentStack applies the plan PlanEnvironmentStack saved, in a tag build, as the apply identity, and says what it did; a plan with no change applies nothing.
func BuildImage ¶
func BuildImage(ctx context.Context, clients *Clients, w Workspace, secretDir, migrate, hooks string, out io.Writer) error
BuildImage builds the application's image from the checkout's Dockerfile and pushes it under its two tags (<release>-<env> and <commit>-<env>), unless the release check found this commit's build to reuse. The build arguments are VERSION and COMMIT (the image bakes the version in, and the framework names the job of its build from it and the template job the stack sets on the service), PROGRAMS (the shipped programs the checkout's release files declare, read from the application as bedrock check reads it, one word per program as the seeded Dockerfile's loop compiles them; empty when the code ships none), the build arguments the placement declares, values of the stack's (every _BUILD_ARG_<NAME> the environment file carries, as NAME=value: a release build's trigger's, which resolve exported, or a pull request's own stack's, which deploy pr-outputs appended; the log names them and never their values), the declared substitutions and what a hook before the build added (the build arguments file, NAME=value lines). Each build secret resolve found declared (BUILD_SECRETS: the checkout's pins in the stack's containers) is read as the deploy identity by its pinned version into secretDir (memory-backed in Cloud Build, gone with the step, never in the workspace) and passed to docker as a BuildKit secret the Dockerfile mounts; it is never a build argument, which the image would keep. The digest the push answered goes to the environment file (IMAGE_DIGEST).
The migrate command the image carries (/migrate) is taken out of the image, built or reused, and left at migrate for the migration steps after it, which run it on the build worker; with hooks set, the hooks program (/hooks) is taken out the same way for the hook steps.
func CheckRelease ¶
CheckRelease decides whether the image build runs. One registry serves every environment and the image tags carry the environment (<release>-<env>, <commit>-<env>), so the release tag's digest and the commit tag's digest tell the story: neither exists, the build runs; the commit is built and the release tag is not, the release name is added to that build and nothing is rebuilt (a tag moved, or a pull-request release whose commit was fast-forwarded to the default branch); both exist and agree, the build is reused; the release tag names another build, the run is refused, since a release names one build per environment.
func Deploy ¶
Deploy puts a new revision of the service in every region, receiving no traffic yet. The service itself is the infrastructure's (created with its runtime identity, ingress and scaling); only the image and the pipeline's labels change. Before each update the service is checked for the state a failed earlier deploy leaves behind, traffic pointed at a revision that is not ready, and repaired by moving traffic back to the last ready revision, as CCC's deployments do. The traffic that serves now is pinned by revision name so the new revision takes none; a revision tag, when there is one, names the new revision under its own URL. One line per region is left for the next steps: region, service, revision.
func FirstApply ¶
func FirstApply(ctx context.Context, clients *Clients, w Workspace, req *BuildRequest, out io.Writer) error
FirstApply applies the environment's stack when no release's build can. It reads its build (the stack trigger carries the application, the environment, the apply identity and the records bucket), refuses a live stack (one a release has run on and no teardown has taken down since), points tofu at the environment's state prefix as the apply identity, untaints the Cloud Run services and jobs a failed apply left tainted (they exist; the plan updates them in place, where a replacement would meet production's deletion protection), plans with the environment and the generated secrets' pins derived the way a pull request's plan derives them (each container's newest enabled version; nothing while a container has none, since the first release adds it), prints the plan's summary and applies it.
func GitHubComments ¶
func GitHubComments(ctx context.Context, token, repoFullName string, number int) ([]github.Comment, error)
GitHubComments reads the comments through the public API.
func GoogleIDToken ¶
GoogleIDToken is IDTokenFunc over the process's default credentials.
func GuardMigrations ¶
GuardMigrations refuses a build whose migrations the migrate command could not apply in order, before anything is touched. The schema migrations directory and the seed directory beside it (schema/devseed) are each one sequence by the rule (migration.Sequence). In a pull-request build two more things hold for the schema migrations once the repository has a release tag: every one the branch started from (the merge base with the default branch) is still in the tree, unchanged, since a committed schema migration never changes; and the sequence is read over the tree together with the default branch's, so an index the default branch has taken since the branch was cut is refused now, not after the merge. Before the first release nothing has run the migrations but disposable environments, so the freeze is off: the schema directory is read as the seed directory is, and a pull request may rename, rewrite or remove a committed migration while the sequence stays whole. Seed files are development data: a pull request may edit or remove one, and the seed directory keeps only the sequence rule (a removal renumbers the files after it), read together with the files the default branch added since the branch was cut. A changed seed applies from the start by recreating the database, which the resolve step does for a pull request's on its next build (staleDatabase). A refusal lists every problem, names the fix (bedrock migration renumber, which go generate runs) and is posted on the pull request. A torn-down environment, a teardown and an application without a schema have nothing to guard.
func Hook ¶
func Hook(ctx context.Context, clients *Clients, w Workspace, stage hook.Stage, program string, out io.Writer) error
Hook runs the application's hook for the stage in the checkout, as the build's deploy identity, with every fact of the environment file and every substitution of the build in its environment: the script (infrastructure/hooks/<stage>.sh), run with bash; or, when program names one, the hooks program the image build took out of the image, run with the stage as its argument. A hook before the build may add build arguments by appending NAME=value lines to the build arguments file (BUILD_ARGS_FILE names it). No script, nothing runs; a failing hook stops the build at its stage. after-down runs only on a teardown, and the others never do.
func Jobs ¶
Jobs creates this build's job for the job process (cmd/jobs), when the application has one: built from the job template the release's stack says (the revision_templates output's job: identity, variables, secret mounts, timeout, retries, resources), named after the stack's template job (the substitution _JOBS_JOB, read from the stack as this build applied it; never run, never deployed to) with the version key, <template>-<version key>, on this build's image with the pipeline's labels and given the template job's IAM policy: the service carries the template's name (APP_JOBS_TEMPLATE, set by the stack) and the image its version, and the framework names the job of its own build from the two (resource/jobs), so the revision this build deploys starts a job of its own code, and a traffic rollback to an earlier revision starts that revision's job; only the running service starts it, the pipeline never does. The step runs after the stack's apply, before the migrations and before anything the run waits for: making a job touches no data, so a failure here stops the run with the database untouched. A build of a version this environment deployed before updates the job it made then, the same code. An application without a job process has nothing to make, and the pipeline has no step for it; a torn-down pull-request environment has nothing to make either.
func MaintenanceOff ¶
MaintenanceOff takes the application out of maintenance once the release's revision serves: the task queue is resumed, against the new release. A run that was not in maintenance has nothing to end. The maintenance revisions stay, as any old revision does.
func MaintenanceOn ¶
func MaintenanceOn(ctx context.Context, clients *Clients, w Workspace, window bool, out io.Writer) error
MaintenanceOn puts the application into maintenance when the run needs it. The step stands at two places in the pipeline: before the stack is planned, where a restore run (whose database is replaced by the plan) goes into maintenance; and after the gate (window), where a breaking release does, once the window is open, with a second look at the window first (windowStillOpen). The release's own image starts as a revision with the maintenance variable set, in every region, under the tag next, receiving no traffic; the revision is probed through the load balancer's next hostname and must answer 503 with the marker, else the run stops here with nothing moved, naming the application's missing switch; then all traffic moves to it, the application's task queue is paused (and, on a restore, purged), the running executions of the serving build's job are canceled, and the old revision's requests in flight are let finish: its active instances are read until none is, or until the service's request timeout has passed since traffic moved. What can wait, waits before any of that, with the application serving (waitBeforeMaintenance): a restore from production's backup waits for production's newest backup to be READY, and a breaking release that takes a release backup waits for Spanner to be free of another backup of the database, since either wait would otherwise run behind the maintenance page. Any other run keeps the application serving: an ordinary release inside a window under releases all deploys the rolling way, with no maintenance revision, no probe, no pause and no cancel.
func Migrate ¶
func Migrate(ctx context.Context, clients *Clients, w Workspace, program, versionVariable string, preflight bool, out io.Writer) error
Migrate runs the migrations on the build worker: the release's own migrate command, which the image build took out of the environment's image to program, run in the checkout (where it reads the schema directory, as it does in the image) as the deploy identity, with the variables the stack derived for it (MIGRATE_ENV, the levels it constructs; the version variable set to the build's version, as the image sets it for the processes it runs) and the flags the facts decide: the seed (schema/devseed as data migrations after the schema) where the SEED fact is true, every pull request, its database being new, and a release build only in the environments the seed list of the placement in the checkout names (resolve reads it there, so a release that changes the list migrates with its own). A seeded database takes nothing twice. The command reaches Spanner and Firestore through their APIs as the deploy identity, which the application stack grants database admin on the application's own database and nothing wider; its lines go straight into the build log. A build carrying a migration operation does what it asks first: version runs the command with -version alone and the steps after do nothing; force runs it with -force <n> (or -force-data <n>), leaves the force for the record, and then runs the migrations as always; rerun is the migrations as always, by name. A build that runs no migrations (shared-db) runs nothing; a failed run stops the build with the command's lines above; an operation that cannot run is refused before anything runs. A build carrying a retirement (bedrock secret retire) runs the migrations as always and then the command once more with -retire-secret (retire.go). With preflight, in a run that waits for the maintenance window, the command is run once with -version instead, before the wait (preflight below).
func NetHosts ¶
NetHosts are the hosts 2-net routes, by backend service, read from its state in the state bucket as the person: none when the layer has not applied or routes nothing.
func Persona ¶
func Persona(ctx context.Context, clients *Clients, w Workspace, action PersonaAction, out io.Writer) error
Persona registers each persona method's deployment with the persona provider, or removes it: the client ID the placement's root and this deployment make (<root>-pr<N>, <root>-<environment>), the callback on the deployment's canonical hostname, and the cast from the checkout, sent as the build's deploy identity with its Google identity token for the provider. A build with no registrations to send (no persona method, or an environment beyond the first) does nothing; a torn-down environment registers nothing, and only a teardown removes. A refusal fails the step.
func PlanEnvironmentStack ¶
PlanEnvironmentStack plans the environment's stack in a tag build, as the apply identity, after the image build and before the migrations: tofu init on the environment's state prefix, the release's own test of the secret pins (testPins, before the plan, so that a refused release changes nothing), the capacity guard (guardCapacity: the databases on the environment's instance against what it holds, when the stack's database is not there yet), the Cloud Run services and jobs a failed apply left tainted untainted (untaintCloudRun: they exist, and the plan updates them in place), tofu plan saved to the workspace with its JSON beside it, the summary printed and appended (STACK_PLAN), the guard against a destroy of what the state protects (guardProtected), then the plan's tests. A failing plan, guard or test stops the build with the stack unapplied. The plan is this build's own: the plan a reviewer approved on the pull request was bound to the state of that moment, and a release bundles several pull requests. A pull-request build plans every environment earlier instead.
func PlanEnvironments ¶
func PlanEnvironments(ctx context.Context, clients *Clients, w Workspace, req *BuildRequest, out io.Writer) error
PlanEnvironments plans the stack for every environment on a pull request (deploy plan-environments, the check-and-plan trigger's step after bedrock check, as the apply identity, on every push), each as that environment's plan identity, a reader, without the state lock: the plan the reviewer approves is each environment's, and the job can change no environment. Each plan runs the tests; one comment on the pull request carries every summary; a failing plan or test stops the build, which is the required check, and is said on the pull request. A secret the code declares that an environment after the first has no pinned version for is not a refusal here: the environment's summary says it, with the pin to make, since the release's own plan refuses it there (testPins). After the plans come the pull request's looks ahead, read as the same identities: the patch preview when the pull request is against a patch line, and the window preview. Before the plans, the Cloud Armor guard reads the base branch's terraform.tfvars through GitHub and refuses a policy removed in one step (guardCloudArmor): the rule bedrock check applies by hand and cannot in the job's checkout, which holds the pull request's commit alone and gives it nothing to compare with. A tag build plans its own environment later instead (deploy stack plan). Triggers that carry no promotion order (a stack not yet applied with a bedrock that writes it, which the first release on it does) plan nothing, with a notice: the pull request that moves an application here builds.
func Principal ¶
Principal is the account the application-default credentials sign as: a person's account after gcloud auth application-default login, or a service account's. An error is no credentials, or an endpoint that names none.
func PublicGitHub ¶
PublicGitHub is the client over the public API.
func PullRequestStack ¶
func PullRequestStack(ctx context.Context, clients *Clients, w Workspace, req *BuildRequest, ifExists bool, out io.Writer) error
PullRequestStack is the pull request's stack job (deploy pr-stack): the build read through the Cloud Build API, the latest /gcbrun comment read with the repository's token, the pull request's stack planned, guarded and applied into its own prefix (or destroyed on /gcbrun down), and the outcome written to the records bucket for the preview build. With ifExists (deploy pr-stack --if-exists, the check-and-plan trigger's last step), the stack is applied again only when the pull request has a preview standing, so a push keeps it current, and a reload-db in the latest comment is left to the build that comment ran. A failure is written for the preview build too, with its reason, so that build stops at once rather than waiting.
func PullRequestStacks ¶
func PullRequestStacks(ctx context.Context, clients *Clients, req *TeardownRequest) ([]string, error)
PullRequestStacks are the numbers of the pull-request stacks under the integration environment's prefix in the state bucket, sorted: each has a state of its own at 3-app/<app>/<integration>/pr<N>/default.tfstate.
func ReadStackOutputs ¶
ReadStackOutputs is the preview build's read of what the pull request's stack job applied (deploy pr-outputs): the object for this build's commit and /gcbrun comment, waited for while the job runs, whose facts go to the environment file for the steps after. A job that failed stops this build with the job's reason; a destroy is what a /gcbrun down build waits for, and nothing else. A tag build says so and ends.
func RunRelease ¶
RunRelease cuts the releases a push calls for: release-please, pinned, as the release app, github-release then release-pr for the pushed branch.
func ShiftTraffic ¶
ShiftTraffic moves every region to 100 percent on its new revision, keeping the tags other revisions carry. A pull-request revision served under a tag alone leaves the traffic where it is.
func Sleep ¶
Sleep is the real waiting: it returns when the duration has passed, or the context's error when that ends first.
func StackOutputsObject ¶
StackOutputsObject is the object's name in the records bucket for the pull request and the commit.
func StackTeardown ¶
func StackTeardown(ctx context.Context, clients *Clients, w Workspace, req *BuildRequest, destroy bool, out io.Writer) error
StackTeardown tears the environment's stack down, or destroys it with destroy, in the stack trigger's build: it reads its build (the trigger carries the application, the environment, the apply identity and the records bucket; the workflow's run carries the requester), the checkout's placement, and does what the hand command does (PrepareTeardown, Run) as the apply identity, its summary printed first. The refusals are the hand command's: a host 2-net still routes, a plan beyond or short of what the command means to destroy. The record names the requester and the build's approver.
func StartReleaseBackup ¶
func StartReleaseBackup(ctx context.Context, clients *Clients, w Workspace, now time.Time, out io.Writer) error
StartReleaseBackup takes the release backup when the run is a tag build in an environment on the placement's releaseBackups list that applies its migrations: the cut is now, the backup is named after the database, the release and the build (<database>-pre-<release with dashes>-<the build id's first eight characters>, so a release run again keeps a backup of its own cut), its data is as of the cut and it is kept fourteen days; the facts carry it to the record. A pull-request build, a run that deploys nothing, a run that applies no migration, a restore run (which replaces the database) and a rollback run (which restores a backup) take none, each said on out.
func Sweep ¶
func Sweep(ctx context.Context, clients *Clients, w Workspace, req *BuildRequest, out io.Writer) error
Sweep destroys the environments of closed pull requests. A pull request has an environment while its services stand (the pull_request label on the application's services, in every region of _SERVICES); GitHub says which of those pull requests are closed, asked with the repository's token minted from the Cloud Build connection the way resolve mints it; and each closed one's stack is destroyed from its own state prefix, the way /gcbrun down destroys it, as the apply identity, which the sweep trigger runs as. Closing or merging a pull request starts no build, so this is how an environment nobody took down goes away. An open pull request's environment stays, and so does one GitHub cannot answer for.
func SweepJobs ¶
SweepJobs deletes the jobs deploy jobs made that nothing runs any more. A job of the job process stays while a revision of the service, in any region, carries its version key: a revision that exists can take a traffic rollback, and then starts the job of its own build. Any job stays while an execution of it is still running, and while it is younger than three hours, since its build may still be running; the template always stays. Nothing here retires a revision: that is Cloud Run's own ceiling of revisions per service. An application without a job process has nothing to sweep, and the pipeline has no step for it; a torn-down pull-request environment has nothing to sweep either.
func TalkBack ¶
TalkBack says on the pull request what the build did, as the deployer app: a GitHub deployment named after the pull request's environment (<app>-pr<N>) carrying its URL, which the pull request's sidebar shows and "View deployment" opens, and a comment with the release and the database mode. A teardown (/gcbrun down) marks every deployment of the environment inactive instead. A tag build, or an environment without a deployer app yet, says nothing.
func TeardownPullRequests ¶
func TeardownPullRequests(ctx context.Context, clients *Clients, req *TeardownRequest, numbers []string, out io.Writer) error
TeardownPullRequests destroys every pull-request stack under the integration environment's prefix, each the way the sweep destroys a closed pull request's: its builds' jobs deleted in the environment's project (which the placement records), then the stack from its own prefix, then its state object; a state that holds nothing is skipped and its object goes. Nothing of a pull request's stack is kept.
func ValidateRelease ¶
func ValidateRelease(ctx context.Context, clients *Clients, w Workspace, bedrock string, routerDirs []string, out io.Writer) error
ValidateRelease is what stands between a tag and a build. Two checks through the GitHub API: the tag belongs to a GitHub Release cut by an accepted release actor (_RELEASE_ACTORS, comma-separated logins: the release app as <slug>[bot]), which is how release-please, and nothing else, makes a release; and the tagged commit is on the default branch, or it is a patch release, the tip of the line's branch patch/<major>.<minor>.x whose base on the default branch carries a release tag of the same line. Then the record gate: this environment follows the previous one in the promotion order (_PREVIOUS_ENV, empty in the first), and a release runs here only after the previous environment holds a live deployment record of it, which its record step writes once traffic has shifted there. Last the maintenance window (windowCheck): whether the release turns away the one this environment runs, read from the release file in the checkout's router packages (routerDirs, one per site) and the environment's newest live record, and whether the run can wait for the window; what can never proceed is refused here, before anything is built. A pull-request build has no release to validate, and says so; its previews are the check-and-plan job's. A tag build first says which bedrock runs it (bedrock, the running version), and whether that is a commit pin: a release may be deployed by a bedrock built from an unreleased commit, and the log says so rather than refusing it.
func WaitForWindow ¶
WaitForWindow holds the run at the gate until the environment's maintenance window opens, when the release needs it (WINDOW_NEEDED): the image is built and the jobs are made by now, so the wait costs nothing and the window holds only maintenance, the migrations and the rollout. It prints when the run will proceed and waits, reading the clock again at most every ten minutes; when the window opens it leaves when, how long it waited and which opening let it in. A run in maintenance already (a restore run, or a rerun after a window release that failed) passes at once. An opening further away than the build can wait stops the run here, before anything changes.
func WriteRecord ¶
WriteRecord writes the request's record to its object and prints it, the way the bash step did, with where it went.
Types ¶
type ApplicationTeardown ¶
type ApplicationTeardown struct {
// Environments are the environments with a stack, in promotion order;
// PullRequests the numbers of the pull-request stacks under the integration
// environment's prefix.
Environments []*EnvironmentTeardown
PullRequests []string
// contains filtered or unexported fields
}
ApplicationTeardown is one application's teardown or destroy in every environment, prepared, with the pull-request stacks after them: bedrock teardown --all and bedrock destroy --all, and bedrock org teardown's loop over the registered applications.
func PrepareApplication ¶
func PrepareApplication(ctx context.Context, clients *Clients, req *TeardownRequest, out io.Writer) (*ApplicationTeardown, error)
PrepareApplication prepares every environment of the application in promotion order (a refusal in any stops the whole before anything runs) and lists the pull-request stacks. The request's environment is ignored.
func (*ApplicationTeardown) Empty ¶
func (a *ApplicationTeardown) Empty() bool
Empty reports that nothing of the application stands: no environment's stack and no pull-request stack.
func (*ApplicationTeardown) Run ¶
Run runs every environment in promotion order, then destroys the pull-request stacks.
func (*ApplicationTeardown) Summary ¶
func (a *ApplicationTeardown) Summary() string
Summary says what the run does, environment by environment, and which pull-request stacks go after them.
type Approval ¶
type Approval struct {
// Approver is the account that approved the build in Cloud Build and At when, as
// Cloud Build recorded them; Comment is what the approver wrote, if anything.
Approver string `json:"approver"`
At string `json:"at"`
Comment string `json:"comment,omitempty"`
}
Approval is a build's approval as the record keeps it.
type Backup ¶
type Backup struct {
// Name is the backup's resource name (projects/<p>/instances/<i>/backups/<b>).
Name string
// VersionTime is the moment the backup's data is from; CreateTime when it was taken.
VersionTime string
CreateTime string
// Database is the database the backup was taken from (projects/<p>/instances/<i>/databases/<d>);
// State is CREATING while Spanner takes it and READY once it can be restored.
Database string
State string
// ExpireTime is when Spanner deletes the backup.
ExpireTime string
}
Backup is one backup of a database as the restore reads it.
type Build ¶
type Build struct {
ID string `json:"id"`
Substitutions map[string]string `json:"substitutions"`
// StartTime is when the build started running (after its approval, where one is
// needed) and Timeout its whole-build timeout (86400s), from which the wait for a
// maintenance window knows how long the run may still take.
StartTime string `json:"startTime,omitempty"`
Timeout string `json:"timeout,omitempty"`
// Approval is the build's approval as Cloud Build describes it, where the trigger
// requires one (placement.json's approvals): decided before the build ran, so the
// run knows who approved it and writes them into the record. Nil where none is
// required.
Approval *BuildApproval `json:"approval,omitempty"`
// ServiceAccount is the identity the build runs as (projects/<p>/serviceAccounts/
// <email>): a trigger-held job runs as the apply identity and drives tofu as itself,
// where the pipeline's deploy identity impersonates it.
ServiceAccount string `json:"serviceAccount,omitempty"`
// Steps are the build's steps as Cloud Build describes them: a trigger-held job reads
// their ids to say when it runs under an older bedrock's steps.
Steps []BuildStep `json:"steps,omitempty"`
}
Build is the build as Cloud Build describes it: its id and every substitution, the trigger's and Cloud Build's own (COMMIT_SHA, TAG_NAME) alike.
func ParseBuild ¶
ParseBuild reads a build as Cloud Build's API describes it: its id and substitutions.
type BuildApproval ¶
type BuildApproval struct {
State string `json:"state,omitempty"`
Result *BuildApprovalResult `json:"result,omitempty"`
}
BuildApproval is a build's approval: its state (PENDING, APPROVED, REJECTED) and, once decided, the result.
type BuildApprovalResult ¶
type BuildApprovalResult struct {
ApproverAccount string `json:"approverAccount,omitempty"`
ApprovalTime string `json:"approvalTime,omitempty"`
Decision string `json:"decision,omitempty"`
Comment string `json:"comment,omitempty"`
}
BuildApprovalResult is who decided a build's approval, when, which way and with what comment, as Cloud Build records it.
type BuildRequest ¶
type BuildRequest struct {
BuildID, Project, Location string
}
BuildRequest names the build a trigger-held command runs in: its id and where it runs, as the step passes them (BUILD_ID, PROJECT_ID, LOCATION).
type BuildStep ¶
type BuildStep struct {
ID string `json:"id,omitempty"`
}
BuildStep is one step of a build as Cloud Build describes it, by its id.
type Builds ¶
type Builds interface {
// Get is the build as Cloud Build describes it, the JSON the API answers.
Get(ctx context.Context, project, location, id string) ([]byte, error)
// ReadToken mints a read token for the repository (projects/<p>/locations/<l>/
// connections/<c>/repositories/<r>) from the connection it is linked through.
ReadToken(ctx context.Context, repository string) (string, error)
}
Builds reads a build and mints the GitHub token of the repository it came from, through Cloud Build: the API, or a fake in tests.
type BuildsFunc ¶
BuildsFunc opens Builds.
type Clients ¶
type Clients struct {
// Storage opens Cloud Storage, for the deployment records.
Storage StoreFunc
// StorageAs opens Cloud Storage as an impersonated identity, for a pull-request
// build's read of an environment's records as that environment's plan identity;
// StorageAsWriter the same for writing, for the stack trigger's teardown record as
// the apply identity.
StorageAs StoreAsFunc
StorageAsWriter StoreAsFunc
// Builds opens Cloud Build, for the build's own description and the repository's
// GitHub token.
Builds BuildsFunc
// Comments reads a pull request's comments with that token.
Comments CommentsFunc
// GitHub opens the GitHub client with that token, for the release checks.
GitHub GitHubFunc
// Registry opens Artifact Registry, for the release check on the image.
Registry RegistryFunc
// Run opens Cloud Run, for the services and the job process's jobs.
Run RunFunc
// Tasks opens Cloud Tasks, for the queue a maintenance step pauses and resumes.
Tasks TasksFunc
// Metrics opens Cloud Monitoring, for the active instances a maintenance step waits on.
Metrics MetricsFunc
// HTTP is the client a maintenance step probes the maintenance revision with, and
// the persona registrations go through.
HTTP *http.Client
// IDToken mints the build identity's Google identity token for an audience: the
// persona provider takes it as the deploy identity's proof of itself.
IDToken IDTokenFunc
// Sleep waits between a maintenance step's tries and through the wait for a
// maintenance window; nil waits for real.
Sleep SleepFunc
// Now is the clock the maintenance window is read against; nil is the real one.
Now func() time.Time
// FirestoreAs opens Firestore as the apply identity, for the documents a restore run
// deletes.
FirestoreAs FirestoreAsFunc
// SpannerAs opens Spanner as the apply identity, for the restore from production's
// backup; Spanner opens it as the build's own identity, for the capacity guard of a
// step that runs as the identity it reads as.
SpannerAs SpannerAsFunc
Spanner SpannerFunc
// Secrets opens Secret Manager, for the build secrets and the deployer app's key.
Secrets SecretsFunc
// SecretsAs opens Secret Manager as an impersonated identity, for the tests of a
// stack's plan.
SecretsAs SecretsAsFunc
// Grants reads the application's databases as the worker, for the migrate step's wait
// on the deploy identity's grants.
Grants GrantsFunc
// Versions reads a database's schema migration version as the worker: the migration
// guard's read of each environment's on a consolidation pull request, and the migrate
// step's of the database in front of a consolidation.
Versions VersionsFunc
// Exec runs the programs a step drives: tofu, docker, the migrate command, a hook's
// script.
Exec Runner
}
Clients are the deploy sequence's seams: what its commands open, replaced by fakes in tests. Each is opened by the command that needs it, never before.
func DefaultClients ¶
DefaultClients opens the real services. out is where the clients note a call they send again after a transient answer (retry.go): the process's standard output, which in the pipeline is the step's.
type Command ¶
Command is one program run: its directory, the variables it gets beyond the process's own, and its name and arguments.
type CommentsFunc ¶
type CommentsFunc func(ctx context.Context, token, repoFullName string, number int) ([]github.Comment, error)
CommentsFunc reads a pull request's comments with the token minted for the build: the GitHub API, or a fake in tests.
type Database ¶
Database is a Spanner database as its state matters here: READY (or READY_OPTIMIZING, serving while Spanner finishes a restore's optimization) serves, and CREATING is a restore still in progress, from the backup RestoredFrom names.
type DatabaseRef ¶
type DatabaseRef struct {
// Name is the database's resource name (projects/<p>/instances/<i>/databases/<d>).
Name string `json:"name"`
// Generation is 1 for the database the stack created and the number a rollback
// restored a backup into otherwise.
Generation int `json:"generation"`
}
DatabaseRef is the database a run's revisions open, as the record keeps it.
type EnvironmentTeardown ¶
type EnvironmentTeardown struct {
// contains filtered or unexported fields
}
EnvironmentTeardown is one environment's teardown or destroy, prepared: the stack initialized at the environment's prefix, its state listed and sorted into what goes and what stays, the protections production holds found, and the records read for the plan's variables and for the record. Run does it.
func PrepareTeardown ¶
func PrepareTeardown(ctx context.Context, clients *Clients, req *TeardownRequest, out io.Writer) (*EnvironmentTeardown, error)
PrepareTeardown reads what the environment's teardown or destroy needs and refuses what cannot go: the stack's state in the state bucket (none, or one with no outputs, the empty state an init writes: the stack has not been applied, said on out, and nil is answered), 2-net's hosts (a host routed to the environment's backend service refuses the run), the records (the database generation, the generated secrets' pins, the live release), and the stack's state listed after its init.
func (*EnvironmentTeardown) Run ¶
Run does the environment's teardown or destroy: the apply that lifts the protections production holds, the destroy plan with the kept resources excluded, the plan held against what the command means to destroy, its apply, and the record.
func (*EnvironmentTeardown) Summary ¶
func (t *EnvironmentTeardown) Summary() string
Summary says what the run does in the environment, for the person to read before it runs: what goes and what stays, by type, the protections lifted first, and the live release.
type Facts ¶
type Facts struct {
// Tag or PullRequest names the trigger: a release build carries TAG_NAME, a
// pull-request build _PR_NUMBER.
Tag string
PullRequest string
// Environment is the trigger's: tst, stg or prd.
Environment string
// Comment is the /gcbrun comment a pull-request build ran on, and CommentID its id,
// which the pull request's stack job writes into its outputs: the preview reads
// the outputs of the job that acted on the same comment.
Comment string
CommentID int64
// Token is the repository's GitHub token, minted from the connection the trigger
// reads the repository through.
Token string
// The facts the environment file exports, as the later steps read them. JobsJob
// names the job process's Cloud Run job, empty for an application without one.
Services string
JobsJob string
ReloadDB bool
// ReloadReason says why the pull request's database is recreated: the comment
// asked (/gcbrun reload-db), or the migrations the last build applied are no longer
// in the tree.
ReloadReason string
Down bool
// Restore is a release build's restore instruction: empty or production-backup (the
// environment's database is replaced in place before the release deploys), or a
// backup's resource name or @<moment> (restored into the database's next generation,
// the live database kept as the forensic copy); Requester says who asked. A requester with no restore and no migration operation is a rerun
// (bedrock rerun: the release's tag build again, production included), and the
// record names them. Both empty for a tag's own build.
Restore string
Requester string
// RestoreDatabase and RestoreDatabaseBackup are production's live database and the
// backup it was restored from, for a restore from production's backup; for a restore
// as of a moment, RestoreDatabase is the database the backup is taken of (an earlier
// generation whose history holds the moment; empty for the live one). See
// restoreDatabaseSub.
RestoreDatabase string
RestoreDatabaseBackup string
// RestoreReason is why: what the person who asked said (_REASON), or, when the build
// decided the restore itself (the seed changed in an environment on the placement's
// seed list; the staging rehearsal), its own sentence.
RestoreReason string
// Rollback is a rollback run's instruction (rollback.go): the release the environment
// leaves, with RollbackReason why and Requester saying who asked. The run applies no
// migration (RunMigrations is false) and touches nothing of the database. Both empty
// for any other run.
Rollback string
RollbackReason string
// MaintenanceOff says the run takes the application out of a maintenance an earlier
// run left on and deploys nothing (bedrock maintenance off): every step but the last
// is skipped, and Requester says who asked.
MaintenanceOff bool
// Approver is who approved the build in Cloud Build where its trigger required an
// approval (a release, a rerun or a rollback in an environment on placement.json's
// approvals), ApprovedAt when, and ApprovalComment what they wrote; the record names
// them. All empty where no approval was required.
Approver string
ApprovedAt string
ApprovalComment string
// Seed says the migrate command applies the development seed: a pull request's
// database is new and always seeded; a release build seeds where the placement in the
// checkout names the environment on its seed list.
Seed bool
// KeepsReleaseBackups says a release build takes a backup of the database as of its
// cut, before its migrations: the placement in the checkout names the environment on
// its releaseBackups list (production alone unless it says otherwise). Never on a
// pull-request build.
KeepsReleaseBackups bool
// Migration is the migration operation a release build carries (the operations
// workflow's version, rerun or force), which the migrate step does; nil for none.
Migration *MigrateAction
// Retirement is the retirement a release build carries (the operations workflow's
// retire), which the plan and migrate steps do; nil for none.
Retirement *Retirement
Image string
ImageTag string
CommitTag string
Version string
Release string
RevisionTag string
RunMigrations bool
ShiftTraffic bool
// Project and Location are where the build runs, for the steps that link to its log.
Project string
Location string
// Substitutions are every substitution of the build, as the trigger passed them;
// Declared are the substitutions the application declares for the environment beyond
// the contract, sorted, as the stack's placement in the checkout states them
// (declared holds their values; declare).
Substitutions map[string]string
Declared []string
// BuildSecrets are the build secrets the image build reads, NAME=<secret version
// resource name>, comma-separated (buildSecrets).
BuildSecrets string
// BuildArguments are the build arguments the placement in the checkout declares
// (buildArguments) whose values a release build's trigger carries (_BUILD_ARG_<NAME>):
// the environment file exports those substitutions for the image build, sorted. A
// pull-request build exports none, its values coming from the pull request's own
// stack job's outputs (deploy pr-outputs).
BuildArguments []string
// contains filtered or unexported fields
}
Facts are what resolve found and computed: what the steps after it read.
func Resolve ¶
func Resolve(ctx context.Context, clients *Clients, req *ResolveRequest, out io.Writer) (*Facts, error)
Resolve reads the build and works out the facts: the trigger's kind, the pull request's instruction, the image and its tags, whether the migrations run and traffic shifts. It refuses a build that is neither a tag's nor a pull request's, one that names no services, a pull-request build outside tst, one with no connection to read its comment through or no /gcbrun comment, an unknown option, and shared-db with reload-db.
func (*Facts) Write ¶
Write leaves the facts in the workspace for the steps after: the environment file (the facts, then every substitution of the build as export _NAME=value, for the hooks), the build arguments file (the declared substitutions, one --build-arg each, for the Dockerfile's ARG _NAME) and the build file. The files are the step's own (0600): every step runs as root in its image and reads them regardless.
type Firestore ¶
type Firestore interface {
// DeleteAllDocuments deletes every document of the database (projects/<p>/databases/<d>),
// in every collection, and waits for the deletion to end.
DeleteAllDocuments(ctx context.Context, database string) error
}
Firestore deletes a database's documents: the v1 API, or a fake in tests.
type FirestoreAsFunc ¶
FirestoreAsFunc opens Firestore as an impersonated identity: the apply identity, which owns the environment's data stores, since the deploy identity holds no data role.
func NewFirestoreAs ¶
func NewFirestoreAs(out io.Writer) FirestoreAsFunc
NewFirestoreAs opens the Firestore v1 REST API as the identity, noting on out each call it sends again after a transient answer (retry.go).
type Force ¶
type Force struct {
// Table is the migrations table set: schema, or data.
Table string `json:"table"`
// Version is the version set; -1 for no version.
Version int `json:"version"`
Requester string `json:"requester"`
}
Force is a forced migration version as the record keeps it.
type GitHubFunc ¶
GitHubFunc opens the GitHub client with the token the resolve step minted: the public API, or a stand-in in tests.
type Grants ¶
type Grants interface {
// Read reads the database named by its resource name (a Spanner database,
// projects/<p>/instances/<i>/databases/<d>, or a Firestore one,
// projects/<p>/databases/<d>): nil when the identity may, the API's error when it
// may not yet (403) or when the read failed otherwise.
Read(ctx context.Context, database string) error
}
Grants reads the application's databases as the worker, the deploy identity: the real APIs, or a fake in tests.
type GrantsFunc ¶
GrantsFunc opens Grants.
func NewGrants ¶
func NewGrants(out io.Writer) GrantsFunc
NewGrants opens the Spanner and Firestore v1 REST APIs with the process's default credentials, the worker's identity, noting on out each call they send again after a transient answer (retry.go).
type IDTokenFunc ¶
IDTokenFunc mints a Google identity token for the audience as the process's identity: the build's deploy identity on Cloud Build, whose email the persona provider verifies against the application's deploy identities.
type JobTemplate ¶
type JobTemplate struct {
ServiceAccount string `json:"serviceAccount"`
Timeout string `json:"timeout"`
MaxRetries int `json:"maxRetries"`
CPU string `json:"cpu"`
Memory string `json:"memory"`
Command []string `json:"command"`
Labels map[string]string `json:"labels"`
Env map[string]string `json:"env"`
Secrets map[string]SecretReference `json:"secrets"`
}
JobTemplate is what the job process's job runs with.
type LiveRelease ¶
LiveRelease is what an environment runs: the release its newest live record names, when it was recorded and by which build. Applied says the environment's stack is applied (its state names the records bucket); Release is empty when nothing is live.
func LiveReleases ¶
func LiveReleases(ctx context.Context, clients *Clients, p *derive.Placement, app string) ([]LiveRelease, error)
LiveReleases reads every environment of the placement, in promotion order.
type Maintenance ¶
type Maintenance struct {
// Revisions are the maintenance revisions by region.
Revisions map[string]string `json:"revisions"`
// Queue is the task queue paused, in full; empty when the application has none.
Queue string `json:"queue,omitempty"`
Purged bool `json:"purged,omitempty"`
// Canceled is how many running executions of the serving build's job were canceled.
Canceled int `json:"canceled"`
// Waited says how the wait for the old revision's requests in flight ended.
Waited string `json:"waited"`
}
Maintenance is a run's maintenance as the record keeps it.
type Metrics ¶
type Metrics interface {
// ActiveInstances is the newest count of the revision's active instances in the
// window ending now; known is false when the window holds no point (a revision
// with no traffic reports none).
ActiveInstances(ctx context.Context, project, revision string, window time.Duration) (count int, known bool, err error)
}
Metrics reads the instances of a revision that are handling a request: Cloud Run's run.googleapis.com/container/instance_count with state active, or a fake in tests.
type MetricsFunc ¶
MetricsFunc opens Metrics.
func NewCloudMonitoring ¶
func NewCloudMonitoring(out io.Writer) MetricsFunc
NewCloudMonitoring opens the Cloud Monitoring v3 REST API with the process's default credentials, noting on out each call it sends again after a transient answer (retry.go).
type MigrateAction ¶
type MigrateAction struct {
// Action is version, rerun or force.
Action string
// Table is the migrations table a force sets: schema, or data.
Table string
// Version is the version a force sets; -1 for no version.
Version int
// Requester is who asked (_REQUESTER); a force names one.
Requester string
}
MigrateAction is the migration operation a build carries: what the operations workflow asked the migrate command for, beyond the migrations themselves.
func (*MigrateAction) String ¶
func (a *MigrateAction) String() string
String says what the operation does, for the build's log.
type Migration ¶
type Migration struct {
Dir string `json:"dir"`
Name string `json:"name"`
Hash string `json:"hash"`
}
Migration is one migration file a build applied: its directory (root-relative), its name and its content's hash (the first 16 hex digits of the SHA-256).
type MigrationVersion ¶
MigrationVersion is what the schema migrations table says about a database: the version applied (Known false when the table holds no row, or does not exist yet: a database nothing has run on, which the migrate command's first file gives the table), and whether a file is in progress.
func (MigrationVersion) String ¶
func (v MigrationVersion) String() string
String spells the version as the migrate command's report does.
type OSRunner ¶
type OSRunner struct{}
OSRunner runs programs on the operating system, found on PATH.
type PersonaAction ¶
type PersonaAction string
PersonaAction is what deploy persona does: register the deployment with the provider after traffic, or remove a torn-down pull request's registration.
const ( PersonaRegister PersonaAction = "register" PersonaRemove PersonaAction = "remove" )
The actions.
type Record ¶
type Record struct {
App string `json:"app"`
Env string `json:"env"`
// StackID is the id of the environment's stack the release deployed into
// (stackid.go), the prefix the record lies under. Absent in a pull-request build's
// record, which lies under the pull request's own prefix.
StackID string `json:"stackId,omitempty"`
Version string `json:"version"`
Commit string `json:"commit"`
Image string `json:"image"`
Digest string `json:"digest"`
Regions []string `json:"regions"`
Revisions []Revision `json:"revisions"`
Timestamp string `json:"timestamp"`
// Status is live once traffic shifted to the revisions, preview otherwise (a
// pull-request build, whose revision serves under a tag).
Status string `json:"status"`
Build string `json:"build"`
// Migrations lists the migration files the build applied (the schema migrations,
// and the seed migrations where the seed ran), each with its content's hash: what
// the database holds, so a later build of a pull request can tell that a file was
// renumbered or changed since and recreate the database. Absent when no migration
// ran.
Migrations []Migration `json:"migrations,omitempty"`
// Stack is what the tag build's apply of the environment's stack did (the plan it
// applied, made in this build): its counts and changes. Absent in a pull-request
// build, which applies no environment's stack, and on a bedrock before the step.
Stack *StackPlan `json:"stack,omitempty"`
// Requester is who asked for the run through the operations workflow: a restore, a
// rerun of the release (bedrock rerun) or a migration operation. Absent for a tag's
// own build.
Requester string `json:"requester,omitempty"`
// Approval is who approved the build in Cloud Build, when and with what comment,
// where its trigger required an approval (a release, a rerun or a rollback in an
// environment on placement.json's approvals). Absent where none was required.
Approval *Approval `json:"approval,omitempty"`
// Restore says the build was a restore run: what the environment's database was
// replaced with, who asked, and what the stack replaced. Absent otherwise.
Restore *Restore `json:"restore,omitempty"`
// Maintenance says the run put the application into maintenance before the database
// was replaced: the maintenance revisions, the queue paused, whether it was purged,
// the job executions canceled and how the wait for the old revision's requests
// ended. Absent otherwise.
Maintenance *Maintenance `json:"maintenance,omitempty"`
// Force says the run set a migrations table to a version before the migrations ran
// (the operations workflow's force): the table, the version and who asked. Absent
// otherwise.
Force *Force `json:"force,omitempty"`
// Window says the release needed the environment's maintenance window: whether it
// was breaking, why, which opening let the run in, when and after how long a wait.
// Absent for a release that deploys at any time.
Window *Window `json:"window,omitempty"`
// Cut is the moment before the run's migrations ran, as the release backup step took
// it: the state the release backup holds. Absent when the run took none.
Cut string `json:"cut,omitempty"`
// ReleaseBackup is the backup the run started as of the cut, in an environment the
// placement's releaseBackups names: what bedrock rollback restores. Absent otherwise.
ReleaseBackup *ReleaseBackup `json:"releaseBackup,omitempty"`
// Database is the Spanner database the run's revisions open: its name and its
// generation (1 for the stack's own, the number a rollback restored into otherwise).
// Absent when the run touched no stack.
Database *DatabaseRef `json:"database,omitempty"`
// Rollback says the run was a rollback: who asked and why, the release left, the
// backup restored and the forensic one taken, the database restored into and the one
// kept. Absent otherwise.
Rollback *Rollback `json:"rollback,omitempty"`
// GeneratedSecrets are the versions the run's plan derived for the secrets the code
// declares generated (generated.go), by variable: what the revisions mount for each.
// Absent when the code declares none, and in a pull-request build.
GeneratedSecrets map[string]string `json:"generatedSecrets,omitempty"`
// VersionedSecrets are the versions the run's plan listed for the secrets the code
// declares versioned (generated.go), by variable, oldest first: the revisions receive
// every one, each under the variable's name with the version's number after it, and
// the highest is the current version. Absent when the code declares none, and in a
// pull-request build.
VersionedSecrets map[string][]string `json:"versionedSecrets,omitempty"`
// RetiredSecret says the run retired a version of a versioned secret (the operations
// workflow's retire): the variable, the version and who asked. The run's revisions do
// not receive the version, and VersionedSecrets does not name it. Absent otherwise.
RetiredSecret *RetiredSecret `json:"retiredSecret,omitempty"`
}
Record is what a build leaves in the records bucket once it has deployed: what is running where, and whether traffic moved to it. The next environment's gate reads it (a release reaches an environment after it is live in the previous one) and the release check reuses the image it names.
type RecordRequest ¶
type RecordRequest struct {
// Skipped says why nothing is recorded: the pull request's environment was torn down,
// or the run asked for the migration version alone.
Skipped string
Bucket string
Object string
Record Record
}
RecordRequest is what the record step found in the workspace: the record to write and where, or that there is nothing to record.
func NewRecordRequest ¶
func NewRecordRequest(ctx context.Context, open StoreFunc, w Workspace, now time.Time) (*RecordRequest, error)
NewRecordRequest composes the record from the workspace: the facts the resolve step exported (and the image build appended), the build's substitutions, and the revisions the deploy step created. now stamps it. A release's record goes under the environment's stack's id, <app>/<env>/<id>/releases/<release>/<build>.json, read through open from the object the stack's apply wrote (stackid.go); a stack without one has not been applied by a bedrock with stack ids, and the record is refused. A pull request's record goes under the pull request's own prefix, <app>/<env>/pr<N>-<commit>/<build>.json.
type Registry ¶
type Registry interface {
// Digest is the digest the tag names, or empty when the tag does not exist.
Digest(ctx context.Context, image, tag string) (string, error)
// AddTag names the digest by another tag.
AddTag(ctx context.Context, image, tag, digest string) error
}
Registry reads and names the images in the application's Artifact Registry repository: the API, or a fake in tests.
type RegistryFunc ¶
RegistryFunc opens the Registry.
func NewArtifactRegistry ¶
func NewArtifactRegistry(out io.Writer) RegistryFunc
NewArtifactRegistry opens the Artifact Registry REST API with the process's default credentials: the build's own identity on Cloud Build. Each call it sends again after a transient answer is noted on out (retry.go).
type ReleaseBackup ¶
type ReleaseBackup struct {
// Name is the backup's resource name (projects/<p>/instances/<i>/backups/<b>).
Name string `json:"name"`
// VersionTime is the moment the backup's data is from, the cut; ExpireTime when
// Spanner deletes it.
VersionTime string `json:"versionTime"`
ExpireTime string `json:"expireTime"`
}
ReleaseBackup is the backup a release build took as of its cut, as the record keeps it.
type ReleaseRequest ¶
ReleaseRequest is what the release trigger's step passes: the release app, its key (a Secret Manager version's resource name, the alias 2-env names), the repository and the pushed branch.
type ResolveRequest ¶
type ResolveRequest struct {
BuildID string
Project string
Location string
Known []string
// Source is the checkout the build runs in (the workspace): where the migration
// files are read when a pull request's records are compared with the tree, and the
// placement whose seed list a release build follows.
Source string
}
ResolveRequest names the build to resolve: its id and where it runs (the pipeline passes BUILD_ID, PROJECT_ID and LOCATION to the step), and the pipeline's own substitutions (the stack's map), so the declared ones can be told apart.
type Restore ¶
type Restore struct {
// Kind is the restore: empty (an empty database, filled by the migrations and the
// seed) or production-backup.
Kind string `json:"kind"`
Requester string `json:"requester"`
// Reason is why the build restored the database on its own: the seed changed in an
// environment on the placement's seed list, and the release is the requester. Empty
// for a restore a person asked for.
Reason string `json:"reason,omitempty"`
// Replaced lists the stack's resources the run replaced, by address.
Replaced []string `json:"replaced,omitempty"`
// Cleared lists what the run emptied instead of replacing: the Firestore database
// whose documents it deleted.
Cleared []string `json:"cleared,omitempty"`
// Backup is the backup the restore restored from (production's newest for a
// production-backup restore; the one named, made as of the moment, or the release's
// pre-release backup for a generation restore), and BackupTime the moment its data
// is from.
Backup string `json:"backup,omitempty"`
BackupTime string `json:"backupTime,omitempty"`
// Forensic, Database, Kept, Generation and PreviousGeneration are a generation
// restore's: the forensic backup taken of the live database as the restore began,
// the database the backup was restored into (the current generation), the one left
// as the forensic copy, and their generation numbers. Absent for an empty or
// production-backup restore, which replaces the database in place.
Forensic string `json:"forensic,omitempty"`
Database string `json:"database,omitempty"`
Kept string `json:"kept,omitempty"`
Generation int `json:"generation,omitempty"`
PreviousGeneration int `json:"previousGeneration,omitempty"`
}
Restore is a restore run as the record keeps it.
type RetiredSecret ¶ added in v0.1.2
type RetiredSecret struct {
Variable string `json:"variable"`
Version string `json:"version"`
Requester string `json:"requester"`
}
RetiredSecret is a retirement as the record keeps it: the versioned secret's variable, the version the application rewrote its stored values away from, and who asked.
type Retirement ¶ added in v0.1.2
type Retirement struct {
// Variable is the versioned secret's variable, as the code declares it.
Variable string
// Version is the Secret Manager version to retire.
Version string
// Requester is who asked (_REQUESTER).
Requester string
}
Retirement is the retirement a build carries: the version of a versioned secret the operations workflow asked to take out of use.
func (*Retirement) String ¶ added in v0.1.2
func (r *Retirement) String() string
String says what the retirement does, for the build's log.
type Revision ¶
type Revision struct {
Region string `json:"region"`
Service string `json:"service"`
Revision string `json:"revision"`
}
Revision is one revision the deploy step created.
type RevisionTemplates ¶
type RevisionTemplates struct {
Services map[string]ServiceTemplate `json:"services"`
Job *JobTemplate `json:"job"`
}
RevisionTemplates is the stack's revision_templates output: each service's revision template by the service's name, and the job process's job template, or nil for an application without a job process.
type Rollback ¶
type Rollback struct {
Requester string `json:"requester"`
Reason string `json:"reason"`
// From is the release the environment left, live when the rollback was asked for.
From string `json:"from"`
}
Rollback is a rollback run as the record keeps it: who asked, why, and the release the environment left. The record's migrations list what the database holds, by the live record the rollback found, since the run applied none.
type Run ¶
type Run interface {
// Get reads the resource (projects/<p>/locations/<r>/jobs/<j> or .../services/<s>).
Get(ctx context.Context, name string) (map[string]any, error)
// Patch sends the resource back and waits for the change to settle; with fields, only
// those are updated. It answers the resource as it settled.
Patch(ctx context.Context, name string, resource map[string]any, fields ...string) (map[string]any, error)
// Services lists the services of the project in the region, every page.
Services(ctx context.Context, project, region string) ([]map[string]any, error)
// Jobs lists the jobs of the project in the region, every page.
Jobs(ctx context.Context, project, region string) ([]map[string]any, error)
// Revisions lists the service's revisions, every page, in no particular order.
Revisions(ctx context.Context, service string) ([]map[string]any, error)
// Executions lists the job's executions, every page.
Executions(ctx context.Context, job string) ([]map[string]any, error)
// CancelExecution cancels a running execution of a job and waits for the
// cancellation: Cloud Run sends the task SIGTERM and kills it after its grace.
CancelExecution(ctx context.Context, name string) error
// CreateJob creates the job under the parent (projects/<p>/locations/<r>) with the id
// and waits for it; it answers the job as it settled.
CreateJob(ctx context.Context, parent, id string, job map[string]any) (map[string]any, error)
// Delete deletes the resource and waits for the deletion.
Delete(ctx context.Context, name string) error
// GetIamPolicy reads the resource's IAM policy: its bindings, its version and the etag
// a SetIamPolicy must carry.
GetIamPolicy(ctx context.Context, name string) (map[string]any, error)
// SetIamPolicy replaces the resource's IAM policy and answers it as set.
SetIamPolicy(ctx context.Context, name string, policy map[string]any) (map[string]any, error)
}
Run reads and changes Cloud Run services and jobs and follows what it changed: the v2 API, or a fake in tests. A resource is its JSON document, as the API answers it, so a change edits the document and sends it back whole. Nothing here runs a job: the pipeline runs none (the job process's job is the running service's to start).
type RunFunc ¶
RunFunc opens Run.
func NewCloudRun ¶
NewCloudRun opens the Cloud Run v2 REST API with the process's default credentials, noting on out each call it sends again after a transient answer (retry.go).
type Runner ¶
type Runner interface {
// Run runs the command with its output and errors on out.
Run(ctx context.Context, c Command, out io.Writer) error
// Output runs the command and answers what it wrote to standard output; its
// errors go to errOut.
Output(ctx context.Context, c Command, errOut io.Writer) ([]byte, error)
}
Runner runs programs.
type SecretReference ¶
SecretReference is a secret mount: the container's id and the pinned version.
type Secrets ¶
type Secrets interface {
// Access is the payload of the version named projects/<p>/secrets/<s>/versions/<n>.
Access(ctx context.Context, version string) ([]byte, error)
// State is the version's state (ENABLED, DISABLED, DESTROYED), read without its
// payload; a version that does not exist is an error.
State(ctx context.Context, version string) (string, error)
// Container reports whether the container named projects/<p>/secrets/<s> exists.
Container(ctx context.Context, name string) (bool, error)
// Create creates the container in the project, with automatic replication and the
// labels.
Create(ctx context.Context, project, id string, labels map[string]string) error
// EnabledVersions are the numbers of the container's enabled versions, oldest first; none
// when it has none.
EnabledVersions(ctx context.Context, container string) ([]string, error)
// Grant adds the member to the role on the container's own policy; a member already
// in the role is left as it is.
Grant(ctx context.Context, container, role, member string) error
// Add adds the payload as a new version of the container and answers its number.
Add(ctx context.Context, container string, payload []byte) (string, error)
Close() error
}
Secrets reads secret versions: Secret Manager, or a fake in tests.
func NewSecretManager ¶
NewSecretManager opens Secret Manager with the process's default credentials.
func NewSecretManagerAs ¶
NewSecretManagerAs opens Secret Manager as the identity, impersonated with the process's default credentials: the plan's tests read a version's state as the identity the plan ran as, which may read what the deploy identity may not.
type SecretsAsFunc ¶
SecretsAsFunc opens Secrets as an identity the process's credentials may impersonate.
type SecretsFunc ¶
SecretsFunc opens Secrets.
type ServiceTemplate ¶
type ServiceTemplate struct {
ServiceAccount string `json:"serviceAccount"`
// MaxInstances is the placement's cap for the environment, or nil for Cloud Run's
// default.
MaxInstances *int `json:"maxInstances"`
Timeout string `json:"timeout"`
Port int `json:"port"`
// HTTP2 names the port h2c, so that Cloud Run talks HTTP/2 to the container: the
// site's main package imports the framework's server.
HTTP2 bool `json:"http2"`
// Args are the container's arguments: the site's binary in the sites layout, none
// in the flat one.
Args []string `json:"args"`
CPU string `json:"cpu"`
Memory string `json:"memory"`
Labels map[string]string `json:"labels"`
// Env are the variables with a value, and Secrets the ones mounted from Secret
// Manager, by variable.
Env map[string]string `json:"env"`
Secrets map[string]SecretReference `json:"secrets"`
}
ServiceTemplate is what one service's revision runs with.
type SleepFunc ¶
SleepFunc waits, or returns the context's error; tests substitute one that does not wait.
type Spanner ¶
type Spanner interface {
// LatestBackup is the most recently created backup of the database
// (projects/<p>/instances/<i>/databases/<d>) on its instance, READY or still CREATING
// (a backup Spanner is taking, a release's started minutes ago, holds the newest data,
// and a restore waits for it); nil when it has none.
LatestBackup(ctx context.Context, instance, database string) (*Backup, error)
// DropDatabase drops the database (projects/<p>/instances/<i>/databases/<d>); a
// database that is already gone is no error.
DropDatabase(ctx context.Context, database string) error
// RestoreDatabase creates the database id on the instance from the backup and waits
// for the restore to end.
RestoreDatabase(ctx context.Context, instance, databaseID, backup string) error
// CreateBackup starts a backup of the database (projects/<p>/instances/<i>/databases/<d>)
// as of versionTime, named backupID on the instance and kept until expireTime, and
// answers the operation's name without waiting for it.
CreateBackup(ctx context.Context, instance, backupID, database string, versionTime, expireTime time.Time) (string, error)
// Backup reads one backup by resource name; nil when there is none.
Backup(ctx context.Context, name string) (*Backup, error)
// Database reads one database by resource name (projects/<p>/instances/<i>/databases/<d>):
// its state and, for one a restore made, the backup it was restored from; nil when
// there is none.
Database(ctx context.Context, name string) (*Database, error)
// Databases names the databases on the instance (projects/<p>/instances/<i>), each by
// its resource name, for the count against what the instance holds.
Databases(ctx context.Context, instance string) ([]string, error)
// ProcessingUnits is the instance's compute capacity, a thousand to a node.
ProcessingUnits(ctx context.Context, instance string) (int, error)
}
Spanner drops and restores databases, lists backups and counts an instance's databases: the v1 API, or a fake in tests.
type SpannerAsFunc ¶
SpannerAsFunc opens Spanner as an impersonated identity: the apply identity, which holds database admin on the environment's instance.
func NewSpannerAs ¶
func NewSpannerAs(out io.Writer) SpannerAsFunc
NewSpannerAs opens the Spanner v1 REST API as the identity, noting on out each call it sends again after a transient answer (retry.go).
type SpannerFunc ¶
SpannerFunc opens Spanner with the process's own credentials: the build's identity, for a step that runs as the identity it reads as.
func NewSpanner ¶
func NewSpanner(out io.Writer) SpannerFunc
NewSpanner opens the Spanner v1 REST API with the process's default credentials, noting on out each call it sends again after a transient answer (retry.go).
type StackChange ¶
StackChange is one planned change: the resource's address and tofu's actions.
type StackOutput ¶
StackOutput is one planned change to an output: its name and tofu's actions.
type StackOutputs ¶
type StackOutputs struct {
App string `json:"app"`
Env string `json:"env"`
PullRequest string `json:"pullRequest"`
Commit string `json:"commit"`
// Build is the job's build id, and Comment the id of the /gcbrun comment it acted
// on (0 for a refresh on a push, which read no comment).
Build string `json:"build"`
Comment int64 `json:"comment"`
// Status is applied, destroyed or failed; Reason says why the job failed.
Status string `json:"status"`
Reason string `json:"reason,omitempty"`
Timestamp string `json:"timestamp"`
// What the applied stack says, as the deploy steps read it: the services
// (region=service per region), the job process's template job, the hostname, the
// migrate command's settings, secrets (their pinned versions, never values) and
// databases, and the build arguments the placement
// declares, by the argument's name.
Services string `json:"services,omitempty"`
JobsJob string `json:"jobsJob,omitempty"`
Hostname string `json:"hostname,omitempty"`
Hostnames string `json:"hostnames,omitempty"`
MigrateEnv string `json:"migrateEnv,omitempty"`
MigrateSecrets string `json:"migrateSecrets,omitempty"`
MigrateDatabases string `json:"migrateDatabases,omitempty"`
BuildArguments map[string]string `json:"buildArguments,omitempty"`
// Persona is the persona registrations the pull request's stack carries (the
// _PERSONA substitution as its code renders it, "[]" for none), which the preview
// build registers with the provider as the pull request's own; on a destroy, the
// registrations read before it, which the teardown's deploy persona remove removes.
// Empty for an object written by a bedrock before it.
Persona string `json:"persona,omitempty"`
// RevisionTemplates is the stack's revision_templates output as applied: what the
// preview build's deploy service and deploy jobs build the revisions and the job
// from.
RevisionTemplates *RevisionTemplates `json:"revisionTemplates,omitempty"`
// SharedDatabase says the stack has no database of its own (/gcbrun shared-db);
// DatabaseRecreated says the job replaced the pull request's database, and why.
DatabaseRecreated string `json:"databaseRecreated,omitempty"`
}
StackOutputs is the stack job's object: what the pull request's stack says once applied, or that the job destroyed it or failed.
type StackPlan ¶
type StackPlan struct {
Add int `json:"add"`
Change int `json:"change"`
Destroy int `json:"destroy"`
Changes []StackChange `json:"changes,omitempty"`
Outputs []StackOutput `json:"outputs,omitempty"`
}
StackPlan is what a plan of the environment's stack would do: the counts tofu prints, each change, and each output the plan changes. The deployment record carries the tag build's. The outputs are listed because the stack passes its settings through to them (the revision templates carry the environment variables, the substitutions the names the steps read): a change to a setting alone plans no resource change and still has to be applied, or the release deploys under the values before it.
type Standing ¶
type Standing struct {
Env string
// Stack says the environment's stack has been applied; TornDown that a teardown of
// that stack is recorded beside its id with no live release since (a release run
// after the way back's apply ends it). Release is the live release, or "".
Stack bool
TornDown bool
Release string
}
Standing is what one environment of an application holds, read from the state bucket and the records as the person, for bedrock org teardown's account of the applications whose stacks it cannot reach (each in its own repository): whether a stack stands there, whether a teardown took it down, and the release that is live.
type Store ¶
type Store interface {
Write(ctx context.Context, bucket, object string, data []byte) error
// List names the objects under the prefix; Read is one object's content, and
// answers an error that is os.ErrNotExist for an object that is not there, as
// Delete does.
List(ctx context.Context, bucket, prefix string) ([]string, error)
Read(ctx context.Context, bucket, object string) ([]byte, error)
Delete(ctx context.Context, bucket, object string) error
Close() error
}
Store writes objects into buckets: Cloud Storage, or a fake in tests.
func NewStorage ¶
NewStorage opens Cloud Storage with the process's default credentials (in Cloud Build, the build's service account).
func NewStorageAs ¶
NewStorageAs opens Cloud Storage as the identity, impersonated with the process's default credentials, for reading: a pull-request build reads an environment's deployment records as that environment's plan identity, which may read what the deploy identity may not.
func NewStorageAsWriter ¶
NewStorageAsWriter opens Cloud Storage as the identity for writing: the stack trigger's teardown, run as the deploy identity, writes its record under the prefix the apply identity alone writes (<app>/stacks/).
type StoreAsFunc ¶
StoreAsFunc opens a Store as an identity the process's credentials may impersonate.
type Tasks ¶
type Tasks interface {
// Pause stops the queue from dispatching; tasks keep queuing up.
Pause(ctx context.Context, queue string) (string, error)
// Purge deletes every task in the queue.
Purge(ctx context.Context, queue string) (string, error)
// Resume lets the queue dispatch again.
Resume(ctx context.Context, queue string) (string, error)
// State is the queue's state (RUNNING, PAUSED, DISABLED).
State(ctx context.Context, queue string) (string, error)
}
Tasks pauses, purges and resumes a Cloud Tasks queue, named in full (projects/<p>/locations/<r>/queues/<q>): the v2 API, or a fake in tests. Each call answers the queue's state as the API reports it.
type TasksFunc ¶
TasksFunc opens Tasks.
func NewCloudTasks ¶
NewCloudTasks opens the Cloud Tasks v2 REST API with the process's default credentials, noting on out each call it sends again after a transient answer (retry.go).
type TeardownRecord ¶
type TeardownRecord struct {
Kind string `json:"kind"`
App string `json:"app"`
Env string `json:"env"`
StackID string `json:"stackId,omitempty"`
At string `json:"at"`
By string `json:"by"`
Approval *Approval `json:"approval,omitempty"`
Release string `json:"release,omitempty"`
Destroyed []string `json:"destroyed"`
Kept []string `json:"kept,omitempty"`
// Backups are the final backups a destroy took first, by resource name.
Backups []string `json:"backups,omitempty"`
}
TeardownRecord is what a teardown or a destroy leaves beside the stack's id (<app>/stacks/<env>/teardown.json): what was done, when, by whom (and who approved the build, through the operations workflow outside the first environment), to which stack, with the release that was live and what went and stayed. A destroy takes the stack's id object with the stack (google_storage_bucket_object.stack), so a reader finding the record without the id knows the stack is gone; one finding both with the same id knows the environment is torn down; one finding an id the record does not name knows the record is an earlier stack's.
type TeardownRequest ¶
type TeardownRequest struct {
// Dir is the stack directory of the checkout; DataDir the run's directory for what
// tofu keeps between its commands (TF_DATA_DIR): each environment's stack gets a
// directory of its own under it, named after the environment, and the pull-request
// stacks share one, since a backend's prefix is recorded at init and a run prepares
// every environment before any runs.
Dir string
DataDir string
// Placement is the application's placement beside the stack; App the application
// and Env the environment.
Placement *derive.Placement
App string
Env string
// Destroy destroys the whole stack instead of tearing it down.
Destroy bool
// Backup takes, before a destroy drops them, a final backup of each Spanner database
// the stack holds, kept finalBackupKeep (the most Spanner allows), waited for, and
// named in the record: the command's default, which --no-backup leaves out. A
// teardown keeps the database and takes none.
Backup bool
// By names who runs the command, for the record (the person by hand; the GitHub
// actor through the operations workflow), and Approval who approved the build in
// Cloud Build, where one did; Now is the clock the record is dated by.
By string
Approval *Approval
Now func() time.Time
// Identity is the apply identity the stack trigger's build runs the teardown as
// (StackTeardown), with Impersonate when the build runs as the deploy identity and
// becomes it: the state and the records are read as it, tofu drives the stack as it,
// and the record is written as it. Empty by hand: the person, nothing impersonated.
Identity string
Impersonate bool
}
TeardownRequest is one environment's teardown, or its destroy with Destroy.
type Versions ¶
type Versions interface {
// Version reads the schema migrations table's row of the database
// (projects/<p>/instances/<i>/databases/<d>): through the database role when one is
// named (the session is created as it), else as the identity itself. A database that
// does not exist is a not-found error (isNotFound); a read the identity may not make
// is a permission error (notYet).
Version(ctx context.Context, database, role string) (MigrationVersion, error)
}
Versions reads the schema migration version of a Spanner database.
type VersionsFunc ¶
VersionsFunc opens Versions.
func NewVersions ¶
func NewVersions(out io.Writer) VersionsFunc
NewVersions opens the Spanner v1 REST API with the process's default credentials, the build's identity, noting on out each call it sends again after a transient answer (retry.go).
type Window ¶
type Window struct {
// Breaking says the release turned away the release the environment ran, and so
// deployed behind the maintenance page.
Breaking bool `json:"breaking"`
// Reason says why the run needed the window.
Reason string `json:"reason"`
// Slot is the opening that let the run in: a weekly slot with its zone, a dated
// slot, anytime, or in maintenance for an environment in maintenance already.
Slot string `json:"slot,omitempty"`
// Opened is when the gate let the run through, RFC3339.
Opened string `json:"opened,omitempty"`
// Waited is how long the run waited at the gate; empty when the window was open on
// arrival.
Waited string `json:"waited,omitempty"`
}
Window is a run's maintenance window as the record keeps it: present when the release needed the window.
type Workspace ¶
type Workspace string
Workspace is where a build's steps share their files: /workspace in Cloud Build.
func (Workspace) Append ¶
Append adds facts to the environment file, one export line each, sorted by name: a later step's findings (the image digest, the reuse flag) for the steps after it.
func (Workspace) BuildArgs ¶
BuildArgs reads the build arguments file: one NAME=value per line, the declared substitutions resolve wrote and what a hook before the build appended. Blank lines and lines starting with # are skipped; the value runs to the end of the line.
func (Workspace) Environment ¶
Environment reads the facts from the workspace's environment file: the value of every `export NAME=value` line, unquoted the way a shell would read it (double quotes with the shell's escapes, single quotes with the '\” idiom, or bare). Other lines are ignored.
func (Workspace) Revisions ¶
Revisions reads the workspace's revisions file: one region,service,revision per line.
func (Workspace) WriteRevisions ¶
WriteRevisions leaves the revisions the deploy step created: one region,service,revision per line.
Source Files
¶
- apptoken.go
- backup.go
- buildimage.go
- checkrelease.go
- consolidation.go
- environment.go
- envstack.go
- exec.go
- firestore.go
- firstapply.go
- generated.go
- grants.go
- guardarmor.go
- guardcapacity.go
- guardmigrations.go
- guardplan.go
- guardprotected.go
- hook.go
- jobs.go
- live.go
- maintenance.go
- metrics.go
- migrate.go
- outputs.go
- persona.go
- pins.go
- planfailure.go
- principal.go
- prstack.go
- record.go
- registry.go
- release.go
- releasejob.go
- resolve.go
- retire.go
- retry.go
- revisiontemplate.go
- rollback.go
- run.go
- secrets.go
- service.go
- spanner.go
- stackid.go
- stackteardown.go
- sweep.go
- sweepjobs.go
- talk.go
- talkback.go
- tasks.go
- teardown.go
- trigger.go
- untaint.go
- versions.go
- window.go