Documentation
¶
Overview ¶
Package envcontract checks an app's effective env against its declared contract. It reports key names, kinds and reasons only: no value is ever returned, logged or placed in an error.
Index ¶
Constants ¶
const ( FormatNonEmpty = "nonempty" FormatURL = "url" FormatPort = "port" FormatInt = "int" FormatBool = "bool" FormatEnum = "enum" )
Shapes a rule's Format may name. enum takes a list: "enum:a,b,c".
const ( ModeOff = "off" ModeWarn = "warn" ModeBlock = "block" )
Gate modes, the values of the env.contract.mode setting.
const BlockedPrefix = "env contract not met, deploy stopped before any container changed: "
BlockedPrefix starts the message of a blocked deploy. The failure classifier keys on the matching phrase, so change both together.
Variables ¶
This section is empty.
Functions ¶
func ValidFormat ¶
ValidFormat reports whether f is a format Evaluate understands.
Types ¶
type BlockedError ¶
type BlockedError struct{ Violations []Violation }
BlockedError stops a deploy. It carries key names and reasons, never values.
func (*BlockedError) Error ¶
func (e *BlockedError) Error() string
type Entry ¶
type Entry struct {
// contains filtered or unexported fields
}
Entry is one effective env key as the oracle sees it. The value stays private so a caller of Evaluate cannot get it back out.
func OpaqueEntry ¶
OpaqueEntry describes a key whose value is resolved later (secret store, reference, vault): it counts as present and well formed.
type Gate ¶
type Gate struct {
Rules func(ctx context.Context, app string) ([]Rule, error)
Base func(ctx context.Context, app string) (Env, error)
Mode func(ctx context.Context) string
Record func(ctx context.Context, app, attemptID string, v []Violation)
}
Gate runs the contract check for a deploy. Every dependency is a func so the gate stays free of the store and the settings service.
type LookupError ¶
type LookupError struct{}
LookupError stops a block-mode deploy when the contract could not be read. It carries no cause text so a store error never reaches a deploy message.
func (*LookupError) Error ¶
func (*LookupError) Error() string
type Rule ¶
type Rule struct {
Key string `json:"key"`
Required bool `json:"required"`
Format string `json:"format"`
Secret bool `json:"secret"`
}
Rule is one declared key.
type Violation ¶
type Violation struct {
Key string `json:"key"`
Kind Kind `json:"kind"`
Reason string `json:"reason"`
}
Violation is one broken rule. Reason never contains a value.
func PresenceOnly ¶
PresenceOnly keeps the violations that say whether a key is set, dropping the ones that depend on what a value looks like.