Documentation
¶
Index ¶
- Constants
- Variables
- func IsUnsupportedStoreVersion(err error) bool
- func TrimPrivKey(privKey string) string
- func TrimPubKey(pubKey string) string
- type Cryptor
- type EncryptedSecretFile
- type EncryptedSecretFiles
- type EncryptedSecrets
- type Option
- func WithConfirmationReader(reader util.ConsoleReader) Option
- func WithConsoleReader(reader util.ConsoleReader) Option
- func WithConsoleWriter(writer util.ConsoleWriter) Option
- func WithDetectGitDir() Option
- func WithGeneratedEd25519Keys(projectName, profile string) Option
- func WithGeneratedKeys(projectName, profile string) Option
- func WithGitRepo(gitRepo git.Repo) Option
- func WithKeysFromCurrentProfile() Option
- func WithKeysFromScConfig(profile string) Option
- func WithPrivateKey(key string) Option
- func WithPrivateKeyPath(filePath string) Option
- func WithProfile(profile string) Option
- func WithPublicKey(key string) Option
- func WithPublicKeyPath(filePath string) Option
- func WithWorkDir(wd string) Option
- type Registry
- type SshKey
Constants ¶
const CurrentSecretsSchemaVersion = 0
CurrentSecretsSchemaVersion is the highest secrets.yaml schema version this build understands. A store with no `schemaVersion` field is treated as version 0 (the original, current format). When a future format bumps this, OLDER binaries (which carry a lower CurrentSecretsSchemaVersion) refuse to read it — see the guard in unmarshalSecretsFile — instead of silently dropping the new fields on the next write. This reader must therefore ship and roll out fleet-wide BEFORE any higher-versioned store is ever written.
const EncryptedSecretFilesDataFileName = "secrets.yaml"
Variables ¶
var ErrSecretsStoreVersionUnsupported = errors.New("unsupported secrets store version")
ErrSecretsStoreVersionUnsupported is returned when the on-disk store declares a schema version newer than CurrentSecretsSchemaVersion. It MUST stay fatal on every read path — including ones that otherwise tolerate a missing/uninitialized store (root_cmd's IgnoreConfigDirError) — because reading a too-new store as empty and then writing would clobber it. Detect it with errors.Is.
Functions ¶
func IsUnsupportedStoreVersion ¶
IsUnsupportedStoreVersion reports whether err indicates the on-disk secrets store declares a newer schema version than this build understands. Read paths that otherwise tolerate a missing/uninitialized store (the CLI's IgnoreConfigDirError, the GitHub Actions "no client secrets -> use parent" fallbacks) MUST treat a true result as FATAL and never swallow it as "no secrets" — ignoring a too-new store risks a later write clobbering it.
func TrimPrivKey ¶
func TrimPubKey ¶
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
}
type EncryptedSecretFile ¶
type EncryptedSecretFiles ¶
type EncryptedSecretFiles struct {
// SchemaVersion is the secrets.yaml schema version. Absent/0 = the original
// format. A reader refuses any value above CurrentSecretsSchemaVersion (fail-closed).
SchemaVersion int `json:"schemaVersion,omitempty" yaml:"schemaVersion,omitempty"`
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 WithGeneratedKeys ¶
func WithGitRepo ¶
func WithKeysFromCurrentProfile ¶
func WithKeysFromCurrentProfile() Option