Documentation
¶
Overview ¶
Package apptype models a governed app type (ADR 052): a constraint and defaults layer over the app spec that an admin publishes and apps pin.
Index ¶
Constants ¶
const ( EnvEnabled = "LEVELRAIL_APPTYPE_ENABLED" EnvMaxParams = "LEVELRAIL_APPTYPE_MAX_PARAMS" EnvMaxSchemaBytes = "LEVELRAIL_APPTYPE_MAX_SCHEMA_BYTES" EnvMaxPatternLen = "LEVELRAIL_APPTYPE_MAX_PATTERN_LEN" EnvMaxVersions = "LEVELRAIL_APPTYPE_MAX_VERSIONS" )
Env names for the feature flag and its limits.
const ( CodeWorkloadMismatch = "apptype_workload_mismatch" CodeParamInvalid = "apptype_param_invalid" CodeBuildNotAllowed = "apptype_build_not_allowed" CodeAddonNotAllowed = "apptype_addon_not_allowed" CodeFixedValueChanged = "apptype_fixed_value_changed" CodeFixedValueMissing = "apptype_fixed_value_missing" CodeReplicasOutOfRange = "apptype_replicas_out_of_range" CodeReadinessRequired = "apptype_readiness_required" )
Violation codes. They share the policy.Violation shape so every surface that renders deploy policy violations renders these too.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Addons ¶
type Addons struct {
Databases *DatabaseRule `json:"databases,omitempty"`
Volumes *Toggle `json:"volumes,omitempty"`
Domains *DomainRule `json:"domains,omitempty"`
Cron *Toggle `json:"cron,omitempty"`
}
Addons limits optional extras; a nil rule means unrestricted.
type AppType ¶
type AppType struct {
Name string `json:"name"`
Version int `json:"version,omitempty"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Workload string `json:"workload"`
Enforcement policy.Mode `json:"enforcement,omitempty"`
Parameters json.RawMessage `json:"parameters,omitempty"`
Binds map[string]string `json:"binds,omitempty"`
EnvironmentConfig map[string]EnvRule `json:"environmentConfig,omitempty"`
Build BuildRule `json:"build,omitempty"`
Addons Addons `json:"addons,omitempty"`
Fixed map[string]string `json:"fixed,omitempty"`
Defaults map[string]string `json:"defaults,omitempty"`
Messages map[string]string `json:"messages,omitempty"`
}
AppType is the published document.
func ParseDocument ¶
ParseDocument decodes and validates a type document. Unknown fields are refused so a typo in a rule cannot silently weaken a type.
type BuildRule ¶
type BuildRule struct {
Allowed []string `json:"allowed,omitempty"`
}
BuildRule limits build methods; empty means any.
type DatabaseRule ¶
type DatabaseRule struct {
AllowedEngines []string `json:"allowed_engines,omitempty"`
Max int `json:"max,omitempty"`
}
DatabaseRule limits database engines and count.
type DomainRule ¶
type DomainRule struct {
Allowed bool `json:"allowed"`
Suffixes []string `json:"suffixes,omitempty"`
}
DomainRule limits custom domains.
type EnvRule ¶
type EnvRule struct {
ReplicasMin *int `json:"replicasMin,omitempty"`
ReplicasMax *int `json:"replicasMax,omitempty"`
ReadinessRequired bool `json:"readinessRequired,omitempty"`
}
EnvRule tightens a type for one environment kind.
type Limits ¶
Limits caps what a type document may carry.
func LimitsFromEnv ¶
func LimitsFromEnv() Limits
LimitsFromEnv reads the caps, falling back to the ADR defaults.
type Schema ¶
type Schema struct {
Type string
Enum []any
Minimum *float64
Maximum *float64
MinLength *int
MaxLength *int
Pattern string
Format string
Default any
Description string
Required []string
Properties map[string]*Schema
// contains filtered or unexported fields
}
Schema is the constrained JSON Schema subset a type uses for parameters. Composition, references and remote ids are left out so a form and a one-line error per field stay predictable.
func ParseSchema ¶
func ParseSchema(raw json.RawMessage, lim Limits) (*Schema, error)
ParseSchema checks raw against the subset and the env-driven limits.
func (*Schema) ParamPaths ¶
ParamPaths lists the dotted path of every scalar parameter, sorted.
type Spec ¶
type Spec struct {
Workload string `json:"workload,omitempty"`
EnvKind string `json:"env_kind,omitempty"`
Params map[string]any `json:"params,omitempty"`
Build string `json:"build,omitempty"`
Replicas *int `json:"replicas,omitempty"`
Readiness bool `json:"readiness,omitempty"`
Databases []string `json:"databases,omitempty"`
Volumes int `json:"volumes,omitempty"`
Domains []string `json:"domains,omitempty"`
Cron string `json:"cron,omitempty"`
Values map[string]string `json:"values,omitempty"`
}
Spec is the slice of an app the checks look at. Values holds flat dotted spec paths (for example labels.team) for fixed-value rules.