sops

package
v0.1.0-dev.20260914030948 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package sops provides SOPS decryption and encryption detection over the getsops library. Decryption is config-free — the encrypted file carries its own recipients and is unlocked with ambient identities — so the client holds no configuration. (Encryption discovery and signing live elsewhere: encryption per-file via getsops.)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsEncrypted

func IsEncrypted(data []byte) bool

IsEncrypted reports whether data contains SOPS metadata or age armor.

Parameters:

  • data: content to inspect

Returns:

  • bool: true if the data appears to be SOPS-encrypted

func IsSecretFile

func IsSecretFile(filename string) bool

IsSecretFile reports whether a filename indicates a SOPS-encrypted file.

Parameters:

  • filename: filename to check (path or basename)

Returns:

  • bool: true if the filename ends with .sops, .sops.yaml, or .sops.json

Types

type Client

type Client struct{}

Client provides SOPS operations over getsops. It carries no configuration: decryption needs none.

func (*Client) Decrypt

func (c *Client) Decrypt(data []byte, sourcePath string) ([]byte, error)

Decrypt decrypts SOPS-encrypted data. Format is inferred from sourcePath extension. Plaintext data passes through unchanged.

Parameters:

  • data: encrypted (or plaintext) content
  • sourcePath: original file path used to determine SOPS format

Returns:

  • []byte: decrypted content (or unchanged plaintext)
  • error: decryption error

func (*Client) Decryptor

func (c *Client) Decryptor() func(source string, data []byte) ([]byte, error)

Decryptor returns a decryption function matching the signature expected by the execution engine: func(source string, data []byte) ([]byte, error).

Returns:

  • func(string, []byte) ([]byte, error): decryption function

type Encrypter

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

Encrypter encrypts cleartext for the SOPS recipients resolved from the `.sops.yaml` governing a target path.

It owns the per-session config-discovery cache — `visited` memoizes the upward [locate] walk per start directory, so a subtree's chain is computed once. One Encrypter is held per encryption provider, which is itself per-RuntimeEnvironment; concurrent encryption runs under gather, so the cache is mutex-guarded. getsops does all crypto: this type only locates the config and drives the getsops encrypt flow.

func NewEncrypter

func NewEncrypter() *Encrypter

NewEncrypter returns an Encrypter with an empty discovery cache.

Returns:

  • `*Encrypter`: a ready encrypter.

func (*Encrypter) Encrypt

func (e *Encrypter) Encrypt(data []byte, sourcePath, rootDir string) ([]byte, error)

Encrypt encrypts data for the SOPS recipients governing sourcePath and returns the encrypted SOPS document.

Discovery walks up from sourcePath's directory to rootDir, then the XDG fallback, to locate the `.sops.yaml` chain (via [locate], cached). getsops resolves the first config whose creation rule matches sourcePath into recipients, and the document is emitted in the format inferred from sourcePath.

Parameters:

  • `data`: the cleartext to encrypt.
  • `sourcePath`: the target file's path; selects the creation rule and the document format.
  • `rootDir`: the upper boundary for the `.sops.yaml` walk (the RuntimeEnvironment Root directory).

Returns:

  • `[]byte`: the encrypted SOPS document.
  • `error`: discovery, resolution, or encryption failure.

Jump to

Keyboard shortcuts

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