secrets

package
v0.1.0-dev.20260223223859 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package secrets handles encryption/decryption operations via SOPS. It implements the design from ADR-050: Writ Encrypted Files via SOPS.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecryptData

func DecryptData(data []byte, sourcePath string) ([]byte, error)

DecryptData decrypts SOPS-encrypted data using the source path to determine format. SOPS handles key resolution via .sops.yaml + environment variables:

  • SOPS_AGE_KEY: age key contents
  • SOPS_AGE_KEY_FILE: path to age key file
  • ~/.config/sops/age/keys.txt: default age key location

func DecryptFile

func DecryptFile(src, dst string, mode os.FileMode) error

DecryptFile decrypts a SOPS-encrypted file and writes to target with the specified permissions. If the file is already plaintext (smudge filter active), it copies as-is.

func IsEncrypted

func IsEncrypted(data []byte) bool

IsEncrypted checks if data is a SOPS-encrypted envelope. Returns false if the data is plaintext (e.g., smudge filter decrypted it).

func IsSecretFile

func IsSecretFile(filename string) bool

IsSecretFile checks if a filename indicates an encrypted file. This checks extensions, not file content.

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles encryption/decryption operations via SOPS.

func NewManager

func NewManager(sourceRoot string) (*Manager, error)

NewManager creates a Manager that searches for .sops.yaml starting from sourceRoot, walking up the directory tree. Returns nil (not an error) if no .sops.yaml is found.

func (*Manager) ConfigPath

func (m *Manager) ConfigPath() string

ConfigPath returns the path to the .sops.yaml file, or empty string if none.

func (*Manager) Decryptor

func (m *Manager) Decryptor() func(source string, data []byte) ([]byte, error)

Decryptor returns a decryption function suitable for the execution. The returned function takes a source path and encrypted data, returning plaintext. It handles .sops files via SOPS.

func (*Manager) HasConfig

func (m *Manager) HasConfig() bool

HasConfig returns true if a .sops.yaml was found.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL