config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package config defines the shared, user-facing types used inside a project's gothic.config.go file: the typed environment-value builders (Env, SSMParam, SecretsManager) and the GothicContext passed to lifecycle hooks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheConfig

type CacheConfig struct {
	RedisURL          string
	RedisPassword     string
	RedisTLS          bool
	CacheFilesPath    string
	Compression       bool
	CompressionMethod CompressionMethod
}

CacheConfig carries backend-specific cache settings.

type CacheType

type CacheType int

CacheType selects a cache backend.

const (
	// CACHE_CONTROL_HEADERS is the default — production behavior emitting
	// Cache-Control headers for a CDN rather than storing responses.
	CACHE_CONTROL_HEADERS CacheType = iota
	// IN_MEMORY caches responses in a Go in-memory map.
	IN_MEMORY
	// REDIS caches responses in Redis (see CacheConfig.RedisURL).
	REDIS
	// LOCAL_FILES caches responses on the local filesystem.
	LOCAL_FILES
)

type CompressionMethod

type CompressionMethod int

CompressionMethod selects a compression algorithm for cached/served payloads.

const (
	// GZIP is the default compression method.
	GZIP CompressionMethod = iota
	// BROTLI uses Brotli compression.
	BROTLI
)

type Config

type Config struct {
	ProjectName    string
	TofuBinaryPath string
	DockerfilePath string
	WasmBinary     string
	TailwindBinary string
	OptimizeImages OptimizeImagesConfig
	// Runtime is the routing/caching configuration the generated main.go hands to
	// gothicServer.Middleware. It is read at runtime (not by the CLI's config
	// parser), and its zero value is the default behavior, so it may be omitted.
	Runtime RuntimeConfig
	Deploy  *DeployConfig
}

Config is the user-facing configuration type declared in a project's gothic.config.go file. It mirrors the internal cli.Config that the AST parser produces, but lives here so user projects can reference it via the public gothicframework/core/config package without importing CLI internals.

GoModuleName is intentionally absent: it is read from go.mod at runtime.

type DeployConfig

type DeployConfig struct {
	ServerMemory  int
	ServerTimeout int
	Region        string
	Profile       string
	CustomDomain  bool
	Stages        map[string]Stage
}

DeployConfig holds the deployment settings and per-stage configuration.

type EnvSource

type EnvSource int

EnvSource identifies where a runtime env var value comes from.

const (
	// RawEnv is a plain string value baked into the Lambda environment.
	RawEnv EnvSource = iota
	// SSMParamEnv is an AWS SSM Parameter Store path resolved at deploy time.
	SSMParamEnv
	// SecretsManagerEnv is an AWS Secrets Manager path/ARN resolved at deploy time.
	SecretsManagerEnv
)

type EnvValue

type EnvValue struct {
	Source EnvSource
	Value  string
	// JSONKey, when non-empty, selects a single field out of a JSON-encoded
	// secret/parameter at deploy time (jsondecode(...)["JSONKey"]). Set via .Get.
	JSONKey string
}

EnvValue is an opaque typed wrapper around a runtime env var. Users construct these via the builder functions below; the AST parser identifies each builder by its call-expression function name.

func Env

func Env(v string) EnvValue

Env declares a plain string environment value.

func SSMParam

func SSMParam(path string) EnvValue

SSMParam declares an environment value sourced from an SSM Parameter Store path.

func SecretsManager

func SecretsManager(path string) EnvValue

SecretsManager declares an environment value sourced from a Secrets Manager path/ARN.

func (EnvValue) Get

func (v EnvValue) Get(jsonKey string) EnvValue

Get selects a single field from a JSON-encoded secret or parameter. AWS Secrets Manager secrets are commonly stored as a JSON object (e.g. {"secret-key":"..."}); gothic.SecretsManager("/myapp/dev/api-key").Get("secret-key") pulls just that key at deploy time via Terraform's jsondecode, so the env var receives the value rather than the whole JSON blob. It also works on JSON-valued SSMParam entries.

type GothicContext

type GothicContext struct {
	Stage       string
	ProjectName string
	Suffix      string
	Region      string
	Env         map[string]EnvValue
	Outputs     map[string]string
}

GothicContext is injected into BeforeDeploy / AfterDeploy lifecycle hooks.

type OptimizeImagesConfig

type OptimizeImagesConfig struct {
	LowResolutionRate int
}

OptimizeImagesConfig controls image optimization defaults.

type RuntimeConfig

type RuntimeConfig struct {
	// CacheStrategy selects the production cache backend.
	CacheStrategy CacheType

	// LocalDevelopmentCache selects the dev (hot-reload) cache backend.
	LocalDevelopmentCache CacheType

	// ServeStaticFiles controls when /public/* is served from disk.
	ServeStaticFiles StaticFilesMode

	// CacheConfig provides backend-specific settings (Redis URL, file path, ...).
	CacheConfig *CacheConfig
}

RuntimeConfig is the runtime routing/caching configuration for the server. Its zero value is the sensible default (CACHE_CONTROL_HEADERS in production, in-memory in dev, static files served only under hot reload), so a project may omit the Runtime field entirely.

type Stage

type Stage struct {
	HostedZoneId   EnvValue
	CustomDomain   EnvValue
	CertificateArn EnvValue
	WafArn         EnvValue
	ENV            map[string]EnvValue
}

Stage is the per-stage configuration declared inside Deploy.Stages.

HostedZoneId, CustomDomain, CertificateArn and WafArn are source-aware EnvValues (built with gothic.Env / gothic.SSMParam / gothic.SecretsManager) exactly like ENV entries, so a domain or an ARN can be pulled from SSM Parameter Store or Secrets Manager at deploy time instead of being committed in plain text. Use gothic.Env("literal") for a plain value.

type StaticFilesMode

type StaticFilesMode int

StaticFilesMode controls when /public/* assets are served from local disk.

const (
	// HOT_RELOAD_ONLY (default) serves /public/* from disk only during development;
	// in production CloudFront serves them from S3.
	HOT_RELOAD_ONLY StaticFilesMode = iota
	// ALL_ENVS serves /public/* from disk in every environment (the public folder
	// must ship alongside the server binary).
	ALL_ENVS
)

Jump to

Keyboard shortcuts

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