configfile

package
v0.2.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPrivateRetirementAlias = errors.New("private file and retirement tombstone refer to the same file")
View Source
var ErrTargetReplaced = errors.New("configuration target was replaced")

Functions

func CleanupSensitiveTemp

func CleanupSensitiveTemp(path string) error

CleanupSensitiveTemp removes a file created by CreateSensitiveTemp and its empty private staging directory. It is safe to call after the file has been atomically moved to its final destination.

func CreateSensitiveTemp

func CreateSensitiveTemp(dir, pattern string) (*os.File, error)

CreateSensitiveTemp creates a temporary file inside a freshly-created, current-user-only staging directory. The directory and file are both normalized and verified before the caller can write credential material.

func PreparePrivateDirectory

func PreparePrivateDirectory(path string) error

func RemovePrivateFile added in v0.2.2

func RemovePrivateFile(path string) error

RemovePrivateFile durably retires a validated current-user-only file from its canonical path before best-effort tombstone cleanup. Windows uses a write-through namespace move; Unix syncs the containing directory.

func ReplacementApplied added in v0.2.2

func ReplacementApplied(err error) bool

func SameTarget added in v0.2.2

func SameTarget(first, second string) (bool, error)

SameTarget reports whether two requested paths resolve to the same file. When both files are absent and differ only by case, it probes the containing filesystem instead of assuming case behavior from the operating system.

func SyncReplacement added in v0.2.2

func SyncReplacement(path string) error

SyncReplacement establishes a durability barrier for an atomic replacement that is already visible at path. Unix persists the containing directory; Windows flushes the installed file and its replacement metadata.

func ValidatePrivateFile

func ValidatePrivateFile(path string) error

Types

type PostCommitError added in v0.2.2

type PostCommitError struct{ Err error }

PostCommitError reports a failure that happened after an atomic replacement became visible. Callers that coordinate multiple files must reconcile the target contents instead of assuming the old file is still active.

func (*PostCommitError) Error added in v0.2.2

func (e *PostCommitError) Error() string

func (*PostCommitError) Unwrap added in v0.2.2

func (e *PostCommitError) Unwrap() error

type PrivateReplace

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

func (*PrivateReplace) Abort

func (p *PrivateReplace) Abort() error

func (*PrivateReplace) Commit

func (p *PrivateReplace) Commit(raw []byte) error

func (*PrivateReplace) CommitWithLock added in v0.2.2

func (p *PrivateReplace) CommitWithLock(ctx context.Context, timeout, retry time.Duration, raw []byte) error

type Target

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

Target is the stable filesystem target behind a requested configuration path. Resolving symlinks once and verifying them again under the sidecar lock prevents a writer from silently switching files during a transaction.

func Resolve

func Resolve(requestedPath string, createParent bool) (*Target, error)

func (*Target) AtomicWrite

func (t *Target) AtomicWrite(raw []byte, mode os.FileMode) error

func (*Target) AtomicWritePrivate

func (t *Target) AtomicWritePrivate(raw []byte) error

AtomicWritePrivate replaces a credential-bearing file with a canonical current-user-only file. Unlike AtomicWrite, it never preserves arbitrary security metadata from the old target.

func (*Target) BeginPrivateReplace

func (t *Target) BeginPrivateReplace(reserve int64) (*PrivateReplace, error)

BeginPrivateReplace prepares and reserves space for a private atomic replacement before a remote one-time credential rotation is attempted.

func (*Target) Path

func (t *Target) Path() string

func (*Target) Read

func (t *Target) Read() ([]byte, os.FileInfo, error)

func (*Target) ReadBoundedRegular added in v0.2.2

func (t *Target) ReadBoundedRegular(limit int64) ([]byte, os.FileInfo, error)

func (*Target) Verify

func (t *Target) Verify() error

func (*Target) WithLock

func (t *Target) WithLock(ctx context.Context, timeout, retry time.Duration, fn func() error) error

Jump to

Keyboard shortcuts

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