secrets

package
v1.18.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MPL-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SOPSFormatter    = "sops"
	SOPSFormatYAML   = "yaml"
	SOPSFormatJSON   = "json"
	SOPSFormatDotenv = "dotenv"
)
View Source
const EncryptedFileName = "secrets.enc"
View Source
const EnvBackend = "DEVSY_SECRETS_BACKEND"
View Source
const EnvPassphrase = "DEVSY_SECRETS_PASSPHRASE" // #nosec G101 -- env var name, not a credential.
View Source
const IndexFileName = "secrets.yaml"
View Source
const KeyFileName = "secrets.key"
View Source
const LocalSourceName = "local"

Variables

View Source
var ErrSecretNotFound = errors.New("secret not found")

Functions

func CleanProjectSourcePath

func CleanProjectSourcePath(value string) (string, error)

CleanProjectSourcePath validates a repository-controlled source path and returns a normalized repository-relative slash path.

func ModifySourceConfigs

func ModifySourceConfigs(
	devsyConfig *config.Config,
	mutate func(sources []SourceConfig) ([]SourceConfig, error),
) error

ModifySourceConfigs serializes external source modifications across processes by holding the secret-sources lock while loading, mutating, and writing configuration.

func ParseSecretsFile

func ParseSecretsFile(path string) (map[string]string, error)

func RegisterConfiguredSource

func RegisterConfiguredSource(resolver *Resolver, sourceConfig SourceConfig) error

func ResolveProjectSourcePath

func ResolveProjectSourcePath(root, value string) (string, error)

ResolveProjectSourcePath converts a repository-controlled relative path to a local path while enforcing containment, including after symlink resolution.

func SaveSourceConfigs

func SaveSourceConfigs(devsyConfig *config.Config, sources []SourceConfig) error

SaveSourceConfigs writes external source metadata for the active context.

func ValidateName added in v1.10.0

func ValidateName(name string) error

func ValidateProjectConfig

func ValidateProjectConfig(cfg *ProjectConfig) error

func ValidateSourceName

func ValidateSourceName(name string) error

Types

type Backend added in v1.10.0

type Backend string
const (
	BackendAuto    Backend = "auto"
	BackendKeyring Backend = "keyring"
	BackendFile    Backend = "file"
)

type Kind added in v1.10.0

type Kind string

Kind distinguishes secrets (values in the backend) from env vars (inline).

const (
	KindSecret Kind = "secret"
	KindEnv    Kind = "env"
)

type LocalSource

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

LocalSource adapts the Devsy Store to the generic source interface.

func NewLocalSource

func NewLocalSource(store Store, contextName string) *LocalSource

func (*LocalSource) Get

type ProjectConfig

type ProjectConfig struct {
	SecretSources []SourceConfig `json:"secretSources,omitempty" yaml:"secretSources,omitempty"`
	Secrets       []string       `json:"secrets,omitempty"       yaml:"secrets,omitempty"`
}

ProjectConfig is the repository-owned subset of Devsy configuration used by secret discovery.

func LoadProjectConfigFromRoot

func LoadProjectConfigFromRoot(root string) (*ProjectConfig, bool, error)

LoadProjectConfigFromRoot loads repository-owned config from a local checkout. A missing configuration is not an error.

func LoadProjectConfigFromRootWithOptions

func LoadProjectConfigFromRootWithOptions(
	root, devContainerPath, devContainerID string,
) (*ProjectConfig, bool, error)

LoadProjectConfigFromRootWithOptions loads repository-owned config from a local checkout, checking the specified devcontainer path, conventional root devcontainer locations, and profile-specific devcontainer directories for customizations.devsy.

func ParseProjectConfig

func ParseProjectConfig(data []byte) (*ProjectConfig, error)

type Redactor added in v1.10.0

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

func NewRedactor added in v1.10.0

func NewRedactor(secretsEnv []string) *Redactor

NewRedactor masks the values (not keys) of KEY=VALUE entries; empty values are ignored.

func (*Redactor) Redact added in v1.10.0

func (r *Redactor) Redact(s string) string

type ResolvedSecret

type ResolvedSecret struct {
	Name      string
	Value     string
	Sensitive bool
	Source    string
}

ResolvedSecret is the runtime value returned by a secret source.

type Resolver

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

Resolver routes a SecretRef to an explicitly registered source instance.

func NewResolver

func NewResolver() *Resolver

func NewResolverForConfig

func NewResolverForConfig(devsyConfig *config.Config) (*Resolver, error)

NewResolverForConfig constructs the local Devsy source plus all external sources registered in the active local context.

func (*Resolver) Register

func (r *Resolver) Register(name, typeName string, source Source) error

func (*Resolver) Resolve

func (r *Resolver) Resolve(ctx context.Context, ref SecretRef) (ResolvedSecret, error)

type SOPSSource

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

SOPSSource resolves values from one SOPS-encrypted document. A source is command-scoped: decrypted values are cached in memory for the lifetime of the source instance.

func NewSOPSDataSource

func NewSOPSDataSource(name, logicalPath, format string, encrypted []byte) *SOPSSource

NewSOPSDataSource is used for repository inspection where the encrypted file is read directly from a Git revision without being materialized on disk.

func NewSOPSSource

func NewSOPSSource(name, filePath, format string) *SOPSSource

func (*SOPSSource) Get

func (s *SOPSSource) Get(ctx context.Context, name string) (ResolvedSecret, error)

func (*SOPSSource) Validate

func (s *SOPSSource) Validate(ctx context.Context) error

Validate forces decryption and document validation without exposing values.

type SecretMeta added in v1.10.0

type SecretMeta struct {
	Name     string    `json:"name"`
	Context  string    `json:"context"`
	Kind     Kind      `json:"kind"`
	Value    string    `json:"value,omitempty"`
	Created  time.Time `json:"created"`
	LastUsed time.Time `json:"lastUsed,omitzero"`

	Orphaned bool `json:"-"`
}

func (SecretMeta) Sensitive added in v1.10.0

func (m SecretMeta) Sensitive() bool

type SecretRef

type SecretRef struct {
	Type   string
	Source string
	Name   string
}

SecretRef identifies a named secret and the source instance that owns it. Unqualified references resolve from the local Devsy store. Qualified references use TYPE:SOURCE/NAME, for example sops:project/API_TOKEN.

func ParseRef

func ParseRef(value string) (SecretRef, error)

func (SecretRef) String

func (r SecretRef) String() string

type Source

type Source interface {
	Get(ctx context.Context, name string) (ResolvedSecret, error)
}

Source resolves externally or locally owned secret values.

type SourceConfig

type SourceConfig struct {
	Name   string `json:"name"             yaml:"name"`
	Type   string `json:"type"             yaml:"type"`
	Path   string `json:"path,omitempty"   yaml:"path,omitempty"`
	Format string `json:"format,omitempty" yaml:"format,omitempty"`
}

SourceConfig describes an external secret source. It contains references only; secret values and decryption credentials are never persisted here.

func AddSourceConfig

func AddSourceConfig(sources []SourceConfig, source SourceConfig) ([]SourceConfig, error)

func FindSourceConfig

func FindSourceConfig(sources []SourceConfig, name string) (SourceConfig, bool)

func LoadSourceConfigs

func LoadSourceConfigs(devsyConfig *config.Config) ([]SourceConfig, error)

LoadSourceConfigs loads external sources registered for the active context.

func RemoveSourceConfig

func RemoveSourceConfig(sources []SourceConfig, name string) ([]SourceConfig, bool)

type Store added in v1.10.0

type Store interface {
	Set(context, name, value string, kind Kind) error
	Get(context, name string) (string, error)
	Meta(context, name string) (SecretMeta, error)
	List(context string) ([]SecretMeta, error)
	Delete(context, name string) error
}

func NewStoreForConfig added in v1.10.0

func NewStoreForConfig(devsyConfig *config.Config) (Store, error)

Jump to

Keyboard shortcuts

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