Documentation
¶
Overview ¶
Package resolved answers what configuration a container actually received.
Kubernetes spreads that answer across env, envFrom, valueFrom, the downward API, and mounted volumes, with precedence rules between them. Reading it back means opening the pod spec, then every ConfigMap it references, and applying the same precedence the kubelet did. That is the work this package does once so nobody has to do it by hand at two in the morning.
Secret values are masked by never being fetched. Masking a value you already hold is a rendering decision; masking a value you never read is a property.
Index ¶
Constants ¶
const ( // ClassUnknown means no comparison was possible, usually a secret nobody // may read on one side. ClassUnknown = "" // ClassMatch is identical and unremarkable. ClassMatch = "match" // ClassExpected differs for a reason the values themselves explain. ClassExpected = "expected" // ClassDrift differs with no explanation. ClassDrift = "drift" // ClassSuspicious matches where matching is the problem. ClassSuspicious = "suspicious" // ClassMissing is present on one side only. ClassMissing = "missing" )
Classifications.
const ( // DiffUnknown means no comparison was possible: there is no previous // revision, or this container did not exist in it. DiffUnknown = "" // DiffUnchanged is only ever set for values the template fully determines. DiffUnchanged = "unchanged" DiffChanged = "changed" DiffAdded = "added" DiffRemoved = "removed" DiffSourceChanged = "source-changed" DiffNotRecoverable = "not-recoverable" // DiffRuntime marks values resolved at container start, which belong to the // run rather than to the revision. DiffRuntime = "runtime" )
Diff states.
const ( SourceInline = "inline" SourceConfigMap = "configMap" SourceSecret = "secret" SourceDownward = "downwardAPI" SourceResource = "resourceField" )
Where a value came from.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
Pod string `json:"pod"`
Containers []Container `json:"containers"`
// Caveat states what this reading cannot promise.
Caveat string `json:"caveat,omitempty"`
// ComparedTo names the revision the diff column is against, empty when no
// comparison was possible.
ComparedTo string `json:"comparedTo,omitempty"`
}
Config is a pod's configuration, one table per container.
func Resolve ¶
Resolve reads one pod's configuration.
Every ConfigMap is fetched at most once however many keys reference it, and no Secret is fetched at all.
func ResolveWith ¶
func ResolveWith(ctx context.Context, client kubernetes.Interface, pod *corev1.Pod, permit Permit) Config
ResolveWith adds a permission probe, so every masked row knows whether its reveal would work before anybody clicks it.
type Container ¶
type Container struct {
Name string `json:"name"`
Init bool `json:"init,omitempty"`
Image string `json:"image,omitempty"`
Values []Value `json:"values"`
Mounts []Mount `json:"mounts,omitempty"`
}
Container is one container's resolved configuration.
type CrossRow ¶
type CrossRow struct {
Key string `json:"key"`
Left string `json:"left,omitempty"`
Right string `json:"right,omitempty"`
// LeftUnset and RightUnset distinguish a key that is not set from one set
// to the empty string, which are different configurations.
LeftUnset bool `json:"leftUnset,omitempty"`
RightUnset bool `json:"rightUnset,omitempty"`
// Masked marks a secret-sourced row. Its values never appear; only digests
// are compared, so production credentials never sit beside staging ones on
// a screen.
Masked bool `json:"masked,omitempty"`
LeftDigest string `json:"leftDigest,omitempty"`
RightDigest string `json:"rightDigest,omitempty"`
Class string `json:"class"`
Reason string `json:"reason,omitempty"`
LeftSource Source `json:"leftSource,omitzero"`
RightSource Source `json:"rightSource,omitzero"`
}
CrossRow is one key compared across two environments.
type Declared ¶
Declared is one env entry as the pod template declares it. Declared, not resolved: a template holds references, never their contents.
type Diff ¶
type Diff struct {
State string `json:"state,omitempty"`
// Previous is the old value, or the old reference when only that survives.
Previous string `json:"previous,omitempty"`
Reason string `json:"reason,omitempty"`
}
Diff is how one value compares with the previous revision.
type Mount ¶
type Mount struct {
Path string `json:"path"`
Source Source `json:"source"`
Masked bool `json:"masked,omitempty"`
ReadOnly bool `json:"readOnly,omitempty"`
}
Mount is file-based configuration. A tool that shows only environment variables sends people back to kubectl for half of their config.
type Permit ¶
Permit reports whether this reader may read one Secret, and what they need when they may not.
type Snapshot ¶
type Snapshot struct {
Containers map[string][]Declared
// EnvFrom records the bulk references a container declared. Their keys
// cannot be listed from the template, since the keys live in the object
// being referenced, but knowing the reference existed is enough to tell a
// genuinely new key from one whose old content is simply gone.
EnvFrom map[string][]Source
}
Snapshot is a revision's declared environment, by container.
func FromTemplate ¶
FromTemplate reads a revision's pod template. No cluster reads happen here: everything it returns was preserved inside the ReplicaSet.
type Source ¶
type Source struct {
Kind string `json:"kind"`
Ref string `json:"ref,omitempty"`
Key string `json:"key,omitempty"`
}
Source is one value's provenance. Without it a config table is a list of strings nobody can act on: knowing MAX_CONNECTIONS is 25 matters far less than knowing which ConfigMap to edit.
type Summary ¶
type Summary struct {
Drift int `json:"drift"`
Suspicious int `json:"suspicious"`
Missing int `json:"missing"`
Expected int `json:"expected"`
Match int `json:"match"`
Unknown int `json:"unknown"`
}
Summary counts each class, which is what the topbar reports.
type Value ¶
type Value struct {
Key string `json:"key"`
Value string `json:"value"`
Source Source `json:"source"`
// Masked marks a value that was never read, because it comes from a Secret.
Masked bool `json:"masked,omitempty"`
// Missing marks a reference that could not be resolved. A key that is not
// there is frequently why a container is crashing, so it renders as missing
// rather than as blank.
Missing bool `json:"missing,omitempty"`
// Overrides marks a value that shadowed another source, which is where
// "but the ConfigMap says something else" comes from.
Overrides bool `json:"overrides,omitempty"`
Reason string `json:"reason,omitempty"`
// CanReveal reports whether this reader may fetch the masked value.
// RevealReason names what is missing when they may not, because a control
// is disabled and explained, never hidden.
CanReveal bool `json:"canReveal,omitempty"`
RevealReason string `json:"revealReason,omitempty"`
// Diff is how this value compares with the previous revision, scoped to
// what the cluster actually preserved.
Diff Diff `json:"diff,omitzero"`
// Digest is a hash of a masked value, computed for comparison only. It
// exists so two environments' credentials can be compared without either
// one being read onto a screen.
Digest string `json:"digest,omitempty"`
}
Value is one resolved environment entry.