Documentation
¶
Overview ¶
Package policy evaluates deploy guardrail rules against what an app is about to run. It is pure: callers resolve the layers and the subject.
Index ¶
Constants ¶
const ( ScopeOrg = "org" ScopeProject = "project" ScopeEnvironment = "environment" // OrgScopeID is the single organization-wide scope id. OrgScopeID = "org" )
Scopes a rule set can be attached to, least to most specific.
const ( RuleAllowedRegistries = "allowed_registries" RuleRequireReadiness = "require_readiness_probe" RuleMaxMemoryMB = "max_memory_mb" RuleMaxCPU = "max_cpu" RuleForbidPrivileged = "forbid_privileged" RuleForbidHostMounts = "forbid_host_mounts" RuleRequiredLabels = "required_labels" RuleMaxReplicas = "max_replicas" )
Rule ids, the keys of a Set.
const ( CodeRegistryNotAllowed = "policy_registry_not_allowed" CodeReadinessRequired = "policy_readiness_probe_required" CodeMemoryCeiling = "policy_memory_ceiling_exceeded" CodeCPUCeiling = "policy_cpu_ceiling_exceeded" CodePrivilegedForbidden = "policy_privileged_forbidden" CodeHostMountForbidden = "policy_host_mount_forbidden" CodeLabelRequired = "policy_label_required" CodeReplicasExceeded = "policy_replicas_exceeded" // CodeViolation is the response code of a blocked deploy. CodeViolation = "policy_violation" )
Stable machine readable violation codes.
Variables ¶
This section is empty.
Functions ¶
func RegistryOf ¶
RegistryOf returns the registry host an image reference pulls from.
Types ¶
type Mode ¶
type Mode string
Mode is how a rule reacts: off ignores it, warn reports it, enforce blocks.
type Rule ¶
type Rule struct {
Mode Mode `json:"mode"`
Values []string `json:"values,omitempty"`
Limit float64 `json:"limit,omitempty"`
}
Rule is one guardrail. Values carries list rules (registries, labels, allowed host path prefixes); Limit carries numeric ceilings.
type Subject ¶
type Subject struct {
Image string
MemoryBytes int64
NanoCPUs int64
HasReadiness bool
Privileged bool
HostMounts []string
Labels map[string]string
Replicas int
}
Subject is the deploy being judged. Zero MemoryBytes or NanoCPUs mean no limit is set, which a ceiling treats as exceeding it.
type Violation ¶
type Violation struct {
Rule string `json:"rule"`
Code string `json:"code"`
Mode Mode `json:"mode"`
Message string `json:"message"`
NextAction string `json:"next_action"`
}
Violation is one rule a subject breaks, with a stable code and the next action for a human.