workload

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

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

Documentation

Overview

Package workload holds what the emulator gives the containers that run users' code as on GCP, GKE pods and Build steps, so that unmodified clients reach the Instance by real hostname as a service account: the metadata and registry proxies their Sidecar agents serve, the DNS answers that send Google hostnames to the Sidecar agent's :443 relay to the Google front end, and the names of the Instance CA bundle and its variables.

Index

Constants

View Source
const (
	CABundleKey      = "ca-certificates.crt"
	CABundleDir      = "/etc/gcpemu/certs"
	CABundlePath     = CABundleDir + "/" + CABundleKey
	SystemBundlePath = "/etc/ssl/certs/ca-certificates.crt"
)

The Instance CA bundle in a workload container, and the system bundle it replaces.

View Source
const MetadataHostEnv = "GCE_METADATA_HOST"

MetadataHostEnv tells Google client libraries (Go, Python, Java, Node) that they run on GCE, so they use the metadata server without probing. On GCP the probe is reliable because machines report a Google DMI product name; emulated ones cannot, and a probe racing a still-starting DNS would make a process decide once and for all that it has no credentials.

Variables

View Source
var CAEnvVars = []string{"SSL_CERT_FILE", "REQUESTS_CA_BUNDLE", "NODE_EXTRA_CA_CERTS"}

CAEnvVars are set to the bundle path in every workload container: Go and OpenSSL, Python requests and Node.js read them.

Functions

func DNSAnswer

func DNSAnswer(frontendHosts []string, relaysFrontend bool, addr net.IP) func(string) net.IP

DNSAnswer returns the names a workload's DNS relay answers with addr, where its Sidecar agent serves: metadata.google.internal, and, when the Sidecar agent relays to the Google front end, the front end's hostnames and every LOCATION-docker.pkg.dev. Other names resolve as usual.

func MetadataProxy

func MetadataProxy(base string) http.Handler

MetadataProxy forwards metadata requests to the emulator at base/md/<caller IP>/<path>, where the caller's address picks its identity. It does not add X-Forwarded-For (the metadata server rejects requests that carry it, like GCE's) and drops Authorization.

func RegistryProxy

func RegistryProxy(registry string, token func(*http.Request) string) http.Handler

RegistryProxy forwards registry requests to Artifact Registry at registry (host:port, plain HTTP), adding the access token token returns for the request when it carries no Authorization of its own.

Types

type TokenSource

type TokenSource struct {
	URL string
	// contains filtered or unexported fields
}

TokenSource caches the access token served as JSON at URL, as the metadata server serves it.

func (*TokenSource) Token

func (t *TokenSource) Token() string

Token returns the cached token, fetching a new one shortly before it expires; "" when none can be had.

Jump to

Keyboard shortcuts

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