Environment Model
TheEnvironment struct (defined in apps/strait/internal/domain/types.go) includes:
Standard Environments
Every project is created with three standard environments:- Development (
development) - Staging (
staging) - Production (
production)
Variable Inheritance
Environments support a hierarchical structure via theparent_id field.
- Inheritance: An environment inherits all variables from its parent.
- Overrides: If an environment defines a variable with the same key as its parent, the local value takes precedence.
- Resolution: Strait recursively resolves variables up the parent chain to provide a final, flattened set of variables at execution time.
Endpoint URL Overrides
One of the primary use cases for environments is routing the same job definition to different physical endpoints based on the environment.- Mechanism: If an environment defines an
ENDPOINT_URLvariable, the executor will use this value instead of the job’s defaultendpoint_url. - Dispatch Time: The override is resolved at the moment of dispatch, allowing for dynamic routing without modifying the job definition.
SSRF Validation
To prevent Server-Side Request Forgery (SSRF), all overridden URLs are strictly validated:- Blocking: Private IP ranges (e.g.,
10.0.0.0/8,192.168.0.0/16) and loopback addresses (127.0.0.1) are blocked. - Layers: Validation occurs in both the API layer (during environment/job updates) and the Worker layer (during override resolution).
Use Case: Routing
Environments allow you to maintain a single job definition (e.g.,process-order) while routing it to different services:
- Staging Environment:
ENDPOINT_URL=https://staging.api.myapp.com/jobs - Production Environment:
ENDPOINT_URL=https://api.myapp.com/jobs