configfile

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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 ValidatePrivateFile

func ValidatePrivateFile(path string) error

Types

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

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) 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