Documentation
¶
Index ¶
- Constants
- Variables
- func CheckEncrypted(ciphertext []byte) error
- func CheckSOPSAvailable() (string, error)
- func CheckSOPSInstalled() bool
- func Decrypt(ctx context.Context, repoRoot, rel string) ([]byte, error)
- func Encrypt(plaintext []byte, recipients string) ([]byte, error)
- func EncryptFor(ctx context.Context, repoRoot, rel string, plaintext []byte, redact []string) ([]byte, error)
- func FileRecipients(encrypted []byte) []string
- func GenerateSecretYAML(data SecretData) ([]byte, error)
- func Hash(v string) string
- func IsEncrypted(data []byte) bool
- func Keys(values map[string]string) []string
- func Rotate(ctx context.Context, repoRoot, rel string) error
- func SameValues(a, b map[string]string) bool
- func ShortHash(v string) string
- func ShortRecipient(r string) string
- func UpdateKeys(ctx context.Context, repoRoot, rel string) error
- func ValidKey(k string) error
- func Version(ctx context.Context) (string, error)
- func VersionAtLeast(v string, min [3]int) bool
- func WriteFileAtomic(path string, data []byte) error
- type AgeKeys
- type Config
- type Manifest
- type Rule
- type SecretData
Constants ¶
const ( AnnotationLab = "claims.stuttgart-things.com/lab" AnnotationVaultPath = "claims.stuttgart-things.com/vault-path" )
Annotations claims sets on the Secrets below secrets/ (plain metadata, not encrypted: encrypted_regex covers data/stringData only).
const ConfigFile = ".sops.yaml"
ConfigFile is the name of the sops config at the repository root.
const HashPrefixLen = 12
HashPrefixLen is how much of a hash claims prints.
Variables ¶
var Binary = "sops"
Binary is the sops executable; a variable for tests.
var MinVersion = [3]int{3, 9, 0}
MinVersion is the oldest sops claims secret works with (--filename-override).
Functions ¶
func CheckEncrypted ¶ added in v0.32.0
CheckEncrypted verifies that every value under data and stringData of ciphertext is a sops ENC[...] value, so a .sops.yaml whose encrypted_regex misses them can never put plaintext into git.
func CheckSOPSAvailable ¶
CheckSOPSAvailable verifies that the sops binary is installed and the SOPS_AGE_RECIPIENTS environment variable is set. It returns the recipients string on success.
func CheckSOPSInstalled ¶
func CheckSOPSInstalled() bool
CheckSOPSInstalled returns true if the sops binary is on PATH.
func Encrypt ¶
Encrypt encrypts plaintext YAML using sops with age encryption. It writes the plaintext to a temporary file, runs sops --encrypt, and returns the encrypted output.
func EncryptFor ¶ added in v0.32.0
func EncryptFor(ctx context.Context, repoRoot, rel string, plaintext []byte, redact []string) ([]byte, error)
EncryptFor encrypts plaintext (YAML) for rel: sops reads it from stdin and takes the recipients from the creation rule of repoRoot's .sops.yaml that matches rel. redact lists the values in plaintext (kept out of errors).
func FileRecipients ¶ added in v0.32.0
FileRecipients returns the age recipients in the sops metadata of an encrypted file (public keys, safe to print).
func GenerateSecretYAML ¶
func GenerateSecretYAML(data SecretData) ([]byte, error)
GenerateSecretYAML produces a Kubernetes Secret manifest in YAML format.
func IsEncrypted ¶ added in v0.32.0
IsEncrypted reports whether data carries sops metadata.
func Rotate ¶ added in v0.32.0
Rotate generates a new data key for rel and re-encrypts it in place (sops rotate --in-place); the file never exists as plaintext.
func SameValues ¶ added in v0.32.0
SameValues reports whether a and b hold the same keys with the same values.
func ShortRecipient ¶ added in v0.32.0
ShortRecipient abbreviates an age recipient for display: age1abcd…wxyz.
func UpdateKeys ¶ added in v0.32.0
UpdateKeys re-wraps the data key of rel for the recipients .sops.yaml names now (sops updatekeys); it needs a key that can decrypt rel.
func VersionAtLeast ¶ added in v0.32.0
VersionAtLeast reports whether v (x.y.z) is at least min.
func WriteFileAtomic ¶ added in v0.32.0
WriteFileAtomic writes data (ciphertext) to path via a temporary file in the same directory and a rename.
Types ¶
type AgeKeys ¶ added in v0.32.0
type AgeKeys struct {
Source string // where they come from (an env var or a file), never the key
Recipients []string // the public keys of the identities ("" when unknown)
Opaque bool // SOPS_AGE_KEY_CMD: the keys cannot be inspected
}
AgeKeys describes the age identities sops would use to decrypt.
func FindAgeKeys ¶ added in v0.32.0
FindAgeKeys looks for the age identities the way sops does: SOPS_AGE_KEY, SOPS_AGE_KEY_FILE, SOPS_AGE_KEY_CMD, then the default key file. It returns their public keys so callers can check them against the recipients of a rule; the private keys stay in this function.
func (*AgeKeys) CanDecrypt ¶ added in v0.32.0
CanDecrypt reports whether one of the keys is among recipients; unknown (true, false) for SOPS_AGE_KEY_CMD.
type Config ¶ added in v0.32.0
Config is a parsed .sops.yaml.
func LoadConfig ¶ added in v0.32.0
LoadConfig reads <repoRoot>/.sops.yaml. claims does not walk up from the file like sops can: the rules for secrets/ belong at the repository root, where sops (run there) finds them too.
func (*Config) RuleFor ¶ added in v0.32.0
RuleFor returns the rule sops applies to rel (slash-separated, relative to the repository root): the first one whose path_regex matches. A rule without path_regex matches everything, as in sops. No match is an error: claims never guesses recipients.
func (*Config) SharedRecipients ¶ added in v0.32.0
SharedRecipients returns the recipients common to every per-lab rule (path_regex secrets/<lab>/...): with two or more lab rules, these are the offline recovery recipient(s). Catch-all rules for other files below secrets/ do not count. nil when there are fewer than two lab rules.
type Manifest ¶ added in v0.32.0
Manifest is a Kubernetes Secret as claims secret reads and writes it. Values are kept as strings; data (base64) is decoded on read and written back as stringData, the canonical form of files below secrets/.
func NewManifest ¶ added in v0.32.0
NewManifest returns an Opaque Secret name/namespace with annotations.
func ParseManifest ¶ added in v0.32.0
ParseManifest parses decrypted YAML of a Secret.
func (*Manifest) Marshal ¶ added in v0.32.0
Marshal renders the Secret with all values as stringData.
func (*Manifest) SecretValues ¶ added in v0.32.0
SecretValues lists the values (for redaction).