Documentation
¶
Overview ¶
Package build emulates Cloud Build's Builds API (cloudbuild.googleapis.com v1) over gRPC and REST on the API gateway, on both projects/*/builds and projects/*/locations/*/builds. Build steps run in order or by waitFor as Managed containers that share a per-Build /workspace volume (steps.go), at most build.concurrency Builds at a time while the rest wait QUEUED (runner.go). A Build's substitutions are expanded when it is created (subst.go), and the Secret versions in its availableSecrets read when it starts (secrets.go). timeout and queueTtl run on the Emulator clock. A Build's source comes from Cloud Storage or a Git URL (source.go). Step logs are appended as they run to log-BUILD_ID.txt in the Build's logsBucket, and kept in memory for /_emu/v1/build/<build name>/log (logs.go). Steps act as the Build's service account (serviceaccount.go) and reach the Instance by real hostname through the Build agent (agent.go, agentctl.go), and build, run and push images with the Build daemon at /var/run/docker.sock (daemon.go, credentials.go). Once the steps succeed, images are pushed and artifacts.objects uploaded (results.go). Every status change is published to the Project's cloud-builds topic when it exists (notify.go). Cloud Build v2 answers UNIMPLEMENTED.
Index ¶
- func New(env *emu.Env) emu.Service
- type Service
- func (s *Service) ApplySeed(ctx context.Context, section *yaml.Node, baseDir string) error
- func (s *Service) ClockAdvanced(ctx context.Context) error
- func (s *Service) EnvVars(gw string, endpoints map[string]string) map[string]string
- func (s *Service) ExportSeed(ctx context.Context) (any, error)
- func (s *Service) Name() string
- func (s *Service) Ready() error
- func (s *Service) Register(r emu.Router) error
- func (s *Service) Reset(ctx context.Context) error
- func (s *Service) ResetDone()
- func (s *Service) ResourceCounts() map[string]int
- func (s *Service) Restore(ctx context.Context, dir string) error
- func (s *Service) Snapshot(ctx context.Context, dir string) error
- func (s *Service) Start(ctx context.Context) error
- func (s *Service) Stop(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the Cloud Build Service.
func (*Service) ApplySeed ¶ added in v0.10.0
ApplySeed creates or updates the seeded Build triggers and worker pools. It is idempotent.
func (*Service) ClockAdvanced ¶
ClockAdvanced expires QUEUED Builds and times out WORKING ones that the advance made due, before returning.
func (*Service) EnvVars ¶
EnvVars implements emu.EnvVarer (FR-CORE-004): the gcloud endpoint override for `gcloud builds`.
func (*Service) ExportSeed ¶ added in v0.10.0
ExportSeed implements emu.SeedExporter: every Build trigger and worker pool, without the fields the API sets. Builds are not exported.
func (*Service) Ready ¶
Ready reports whether Build steps can run: a container runtime must be reachable. The result is cached for a few seconds.
func (*Service) Register ¶
Register installs the gRPC service, the REST surface, the log endpoint and the Build daemon's Admin API (daemon.go). The Build Operations are not listed with the Instance's other Operations: a State snapshot waits for those to finish, but must be possible while a Build runs.
func (*Service) Reset ¶
Reset stops the scheduler and every Build, waiting (bounded by ctx) until their containers and volumes are removed, so that none of them writes to the store after the Instance resets it (#307).
func (*Service) ResetDone ¶
func (s *Service) ResetDone()
ResetDone runs the scheduler again once the store is reset too.
func (*Service) ResourceCounts ¶
ResourceCounts implements emu.ResourceCounter.
func (*Service) Restore ¶
Restore implements emu.Snapshotter. A Build that was QUEUED or WORKING when the State snapshot was saved cannot go on, since its containers are gone: it ends INTERNAL_ERROR.