secrets

package
v0.0.0-...-fd6796e Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const EncryptedSecretFilesDataFileName = "secrets.yaml"

Variables

This section is empty.

Functions

func TrimPrivKey

func TrimPrivKey(privKey string) string

func TrimPubKey

func TrimPubKey(pubKey string) string

TrimPubKey normalizes SSH public keys by ignoring aliases/comments SSH keys have format: <key-type> <key-data> optional-comment/alias We only keep the key-type and key-data parts to ensure keys with different aliases but same key data are treated identically for encryption/decryption

Types

type Cryptor

type Cryptor interface {
	GenerateKeyPairWithProfile(projectName, profile string) error
	GenerateEd25519KeyPairWithProfile(projectName, profile string) error
	ReadProfileConfig() error
	AddFile(path string) error
	RemoveFile(path string) error
	DecryptAll(forceChanged bool) error
	EncryptChanged(force bool, forceChanged bool) error
	ReadSecretFiles() error
	MarshalSecretsFile() error
	GetSecretFiles() EncryptedSecretFiles
	GetAndDecryptFileContent(relPath string) ([]byte, error)
	PublicKey() string
	PrivateKey() string
	Workdir() string
	// AddPublicKey allow another public key to encrypt secrets
	AddPublicKey(pubKey string) error
	// RemovePublicKey remove public key from encrypting secrets
	RemovePublicKey(pubKey string) error
	// GetKnownPublicKeys return all public keys
	GetKnownPublicKeys() []string

	Options() []Option
	GitRepo() git.Repo
}

func NewCryptor

func NewCryptor(workDir string, opts ...Option) (Cryptor, error)

type EncryptedSecretFile

type EncryptedSecretFile struct {
	Path          string   `json:"path" yaml:"path"`
	EncryptedData []string `json:"encryptedData" yaml:"encryptedData"`
}

type EncryptedSecretFiles

type EncryptedSecretFiles struct {
	Registry Registry                    `json:"registry" yaml:"registry"`
	Secrets  map[string]EncryptedSecrets `json:"secrets" yaml:"secrets"`
}

type EncryptedSecrets

type EncryptedSecrets struct {
	Files     []EncryptedSecretFile `json:"secrets" yaml:"secrets"`
	PublicKey SshKey                `json:"publicKeys" yaml:"publicKeys"`

	// not to be serialized
	PrivateKey SshKey `json:"-" yaml:"-"`
}

func (*EncryptedSecrets) AddFileIfNotExist

func (es *EncryptedSecrets) AddFileIfNotExist(f EncryptedSecretFile)

func (*EncryptedSecrets) GetEncryptedContent

func (es *EncryptedSecrets) GetEncryptedContent(path string) []string

func (*EncryptedSecrets) RemoveFile

func (es *EncryptedSecrets) RemoveFile(f EncryptedSecretFile)

type Option

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

func WithConfirmationReader

func WithConfirmationReader(reader util.ConsoleReader) Option

func WithConsoleReader

func WithConsoleReader(reader util.ConsoleReader) Option

func WithConsoleWriter

func WithConsoleWriter(writer util.ConsoleWriter) Option

func WithDetectGitDir

func WithDetectGitDir() Option

func WithGeneratedEd25519Keys

func WithGeneratedEd25519Keys(projectName, profile string) Option

func WithGeneratedKeys

func WithGeneratedKeys(projectName, profile string) Option

func WithGitRepo

func WithGitRepo(gitRepo git.Repo) Option

func WithKeysFromCurrentProfile

func WithKeysFromCurrentProfile() Option

func WithKeysFromScConfig

func WithKeysFromScConfig(profile string) Option

func WithPrivateKey

func WithPrivateKey(key string) Option

func WithPrivateKeyPath

func WithPrivateKeyPath(filePath string) Option

func WithProfile

func WithProfile(profile string) Option

func WithPublicKey

func WithPublicKey(key string) Option

func WithPublicKeyPath

func WithPublicKeyPath(filePath string) Option

func WithWorkDir

func WithWorkDir(wd string) Option

type Registry

type Registry struct {
	Files []string `json:"files" yaml:"files"`
}

type SshKey

type SshKey struct {
	Data []byte `json:"data" yaml:"data"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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