config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package config resolves the environment ate-setup installs into. It layers the developer's .ate-dev-env.sh (sourced through bash, so existing setups keep working), the ambient process environment, and command line flags into a single typed Config.

Index

Constants

View Source
const (
	RouterEnvoy        = "envoy"
	RouterAgentgateway = "agentgateway"

	SandboxClassGvisor  = "gvisor"
	SandboxClassMicrovm = "microvm"

	// Cluster size profiles. size0 is the shipped footprint; size10 assumes a
	// dedicated node for PostgreSQL and raises the store, its client pool, and
	// the podcertificate controller's API rate limits to match.
	ClusterSizeSize0  = "size0"
	ClusterSizeSize10 = "size10"
)

Enumerated values for the install-shaping flags.

View Source
const (
	CloudSQLIPTypePrivate = "private"
	CloudSQLIPTypePublic  = "public"
	CloudSQLIPTypePSC     = "psc"
)

Cloud SQL Auth Proxy IP types, the values ATE_API_POSTGRES_CLOUDSQL_IP_TYPE accepts.

View Source
const DefaultPostgresConnectionString = "" /* 262-byte string literal not displayed */

DefaultPostgresConnectionString mirrors default_postgres_connection_string in the shell installer: the apiserver reaches PostgreSQL over mTLS using the podcertificate controller's projected servicedns trust bundle and its own podidentity credential bundle.

View Source
const DefaultPostgresSchema = "public"

DefaultPostgresSchema mirrors the shell installer's default for ATE_API_POSTGRES_SCHEMA, the PostgreSQL schema holding the Substrate tables.

View Source
const DefaultRolloutTimeout = 60 * time.Second

DefaultRolloutTimeout is the default wait timeout for workload rollouts.

View Source
const Size10PostgresPoolParams = "&pool_max_conns=64&pool_min_conns=4"

Size10PostgresPoolParams is appended to the default connection string on size10 clusters. pgxpool defaults MaxConns to max(4, runtime.NumCPU()), which under-uses the size10 server's raised max_connections; pinning the pool makes the client side open the sockets the server is provisioned for.

Variables

This section is empty.

Functions

func RepoRoot

func RepoRoot() (string, error)

RepoRoot walks up from the working directory to the module root. This replaces `git rev-parse --show-toplevel` and works in a source tarball with no .git directory.

Types

type CloudSQLConfig added in v0.2.0

type CloudSQLConfig struct {
	// Instance is the instance connection name, PROJECT:REGION:INSTANCE.
	Instance string
	// InstanceSet records whether ATE_API_POSTGRES_CLOUDSQL_INSTANCE was
	// present in the environment at all, empty value included.
	InstanceSet bool

	// GSA is the Google service account the proxy authenticates as, and whose
	// email (minus the .gserviceaccount.com suffix) is the IAM database user.
	GSA string
	// IAMAuth enables automatic IAM database authentication ("true" or
	// "false"). Empty defaults to enabled.
	IAMAuth string
	// IPType selects which instance address the proxy dials: one of the
	// CloudSQLIPType constants. Empty defaults to private.
	IPType string
}

CloudSQLConfig is the operator's Cloud SQL intent, as expressed by the ATE_API_POSTGRES_CLOUDSQL_* variables.

Every field is empty-means-unspecified except Instance, which is three-way: a non-empty instance selects Cloud SQL, an explicitly empty one removes it, and an unset one (InstanceSet false) adopts whatever the target cluster already records. Without that distinction a redeploy from a shell that simply never exported the variable would tear the proxy sidecar out from under a working installation.

type Config

type Config struct {
	// Root is the repository root. All manifest paths are relative to it.
	Root string

	// Kind selects the local Kind install profile (ATE_INSTALL_KIND).
	Kind bool

	// Namespace is the namespace the control plane is installed into, from
	// ATE_NAMESPACE. It defaults to the canonical installdefaults.SystemNamespace,
	// so an install that does not set it is unaffected. The checked-in manifests
	// under manifests/ate-install/ name that namespace literally, so the
	// manifest-applying steps refuse any other value; see Env.RequireCanonicalNamespace.
	Namespace string

	// Kubeconfig and Context select the target cluster. Empty Context means
	// "use the current context" (the KUBECTL_CONTEXT convention).
	//
	// Kubeconfig is a single file, handed to client-go as its explicit path. It
	// falls back to $KUBECONFIG rather than staying empty so that ate-setup and
	// the shell scripts it delegates to agree on the cluster — but only when
	// that variable names one file. See loadKubeconfig.
	Kubeconfig string
	Context    string

	// GKE cluster coordinates, used to fetch credentials and to derive the
	// service account JWT issuer.
	ProjectID       string
	ClusterName     string
	ClusterLocation string

	// ExpectedJWTIssuer is the service account token issuer ate-api-server
	// trusts (EXPECTED_JWT_ISSUER). It overrides both the GKE derivation from
	// the coordinates above and OpenID discovery, for clusters whose issuer
	// follows neither form.
	ExpectedJWTIssuer string

	// BucketName is the snapshot bucket demos are templated with.
	BucketName string

	// KODockerRepo is where ko pushes images (KO_DOCKER_REPO).
	KODockerRepo string
	// KODefaultPlatforms constrains ko's build platforms.
	KODefaultPlatforms string

	// Images selects where container images come from. Its zero value builds
	// them from source with ko, which is what a developer install does.
	Images images.Source

	// Router selects the atenet router dataplane.
	Router string
	// PostgresConnectionString is the apiserver's store connection string.
	// Empty means use DefaultPostgresConnectionString.
	PostgresConnectionString string
	// PostgresSchema is the PostgreSQL schema for the Substrate tables
	// (ATE_API_POSTGRES_SCHEMA). Empty means DefaultPostgresSchema.
	PostgresSchema string
	// PostgresPoolMaxConns sizes the apiserver's pgxpool
	// (ATE_API_POSTGRES_POOL_MAX_CONNS). It is spliced into the DSN rather
	// than passed separately, because that is the only place pgxpool reads it
	// from. Empty leaves the pgxpool default in place.
	PostgresPoolMaxConns string
	// PostgresServerCAFile is a local PEM file holding the server CA of an
	// external PostgreSQL (ATE_API_POSTGRES_SERVER_CA_FILE). Its contents are
	// published as the postgres-server-ca Secret, which ate-api-server mounts
	// at /run/postgres-server-ca/server-ca.pem for sslmode=verify-ca DSNs.
	PostgresServerCAFile string
	// CloudSQL points the apiserver at a Cloud SQL instance through the Auth
	// Proxy sidecar instead of a directly reachable PostgreSQL.
	CloudSQL CloudSQLConfig

	// RolloutTimeout is the timeout duration for rollout status checks.
	RolloutTimeout time.Duration

	// PodcertWorkersPerSigner overrides WORKERS_PER_SIGNER on podcertificate-controller.
	PodcertWorkersPerSigner int

	// ClusterSize is the footprint profile (ATE_INSTALL_CLUSTER_SIZE): size0
	// or size10.
	ClusterSize string

	// CordonControlPlane pins each control plane workload to its own node
	// (ATE_INSTALL_CORDON_CONTROL_PLANE). It assumes a node pool labeled and
	// tainted ate.dev/workloadType=ate-control-plane:NoSchedule with one node
	// per pod plus a spare for rollout surges.
	CordonControlPlane bool

	// ExperimentalUseSDSMint enables per-SNI dynamic cert minting on atenet-egress.
	ExperimentalUseSDSMint bool

	// AdditionalEgressExtprocService is the optional NS/SVC:PORT external processor filter.
	AdditionalEgressExtprocService string

	// ExperimentalEgressCredentialInjection points the egress gateway's MITM-leg
	// handler at a credential provider so a matching EgressPolicy rule injects its
	// credential. CredentialProviderName/Address configure the provider.
	ExperimentalEgressCredentialInjection bool
	CredentialProviderName                string
	CredentialProviderAddress             string

	// AnthropicAPIKey is required only by the claude-code-multiplex demo.
	AnthropicAPIKey string

	// OtlpEndpoint is where the control plane ships telemetry
	// (ATE_OTLP_ENDPOINT). Benchmark actors are pointed at it too.
	OtlpEndpoint string
	// BenchmarkActorMemory is the memory limit for benchmark actors
	// (BENCHMARK_ACTOR_MEMORY). Empty leaves the workload default in place.
	BenchmarkActorMemory string
	// contains filtered or unexported fields
}

Config is the fully resolved installation environment. Fields sourced from the developer environment keep their shell names in the comments so the mapping back to .ate-dev-env.sh stays obvious.

func Load

func Load(opts Options) (*Config, error)

Load resolves the effective configuration. Precedence, lowest to highest: .ate-dev-env.sh, the process environment, then flags.

func (*Config) EnsureClusterCredentials

func (c *Config) EnsureClusterCredentials(ctx context.Context) error

EnsureClusterCredentials fetches GKE credentials when the configuration names a project but no explicit context.

This reproduces the prologue of the shell installer: a developer whose .ate-dev-env.sh sets PROJECT_ID gets their kubeconfig populated before anything talks to the cluster. Setting a context (or KUBECTL_CONTEXT) is taken as "I already have credentials" and skips the call, as it did there.

func (*Config) KoEnv

func (c *Config) KoEnv() []string

KoEnv returns the environment overrides ko needs for this configuration.

func (*Config) Manifest

func (c *Config) Manifest(parts ...string) string

Manifest resolves a path under manifests/ate-install.

func (*Config) Path

func (c *Config) Path(parts ...string) string

Path resolves a repo-relative path.

func (*Config) PostgresConnString

func (c *Config) PostgresConnString() string

PostgresConnString returns the configured connection string, falling back to the in-cluster default. On a size10 cluster the default also pins the client pool to what the bundled server is provisioned for; an explicit connection string is passed through untouched, since its database was sized by whoever wrote it.

func (*Config) PostgresSchemaName

func (c *Config) PostgresSchemaName() string

PostgresSchemaName returns the configured schema, falling back to the shell installer's default. ate-api-server rejects an empty value.

func (*Config) ScriptEnv

func (c *Config) ScriptEnv() []string

ScriptEnv returns the environment for the shell scripts ate-setup still delegates to (the benchmark and micro-VM helpers).

Those scripts read the same variables the shell installer exported to them, so this reproduces that environment: .ate-dev-env.sh under the process environment, with the resolved configuration layered on top so that flags such as --context and --kind reach them.

func (*Config) Size10 added in v0.2.0

func (c *Config) Size10() bool

Size10 reports whether the size10 footprint profile is selected.

func (*Config) WaitTimeout

func (c *Config) WaitTimeout(historical time.Duration) time.Duration

WaitTimeout returns how long to wait for a workload whose historical timeout was historical.

The shell installer applied --rollout-timeout to the ate-system rollouts only; the podcertificate-controller wait and the CSI driver waits were fixed at 120s because they are the slow bootstrap paths — an image pull on a cold cluster, in the CSI case a driver being torn down and reinstalled. Honoring the flag everywhere would let its 60s default halve exactly those waits.

So the flag now reaches every wait, but only when someone asked for it. Left alone, each site keeps the timeout the scripts gave it.

type Options

type Options struct {
	Kind                                  bool
	Kubeconfig                            string
	Context                               string
	Router                                string
	RolloutTimeout                        string
	PodcertWorkersPerSigner               int
	ClusterSize                           string
	CordonControlPlane                    bool
	ExperimentalUseSDSMint                bool
	AdditionalEgressExtprocService        string
	ExperimentalEgressCredentialInjection bool
	CredentialProviderName                string
	CredentialProviderAddress             string
	OtlpEndpoint                          string

	// Image source selection.
	ImageRepo string
	ImageTag  string

	// NoDevEnv skips sourcing .ate-dev-env.sh even when it exists.
	NoDevEnv bool
}

Options carries the raw flag values the root command collects, before defaulting and validation.

Jump to

Keyboard shortcuts

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