file

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package file provides a file-based vault implementation. Secrets are stored as individual files in a directory.

Usage:

v, err := file.New(file.Config{
    Directory: "/path/to/secrets",
})
secret, err := v.Get(ctx, "api-key")  // reads /path/to/secrets/api-key

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Directory is the base directory for storing secrets.
	Directory string

	// Extension is the file extension for secret files (default: none).
	Extension string

	// JSONFormat stores secrets as JSON with metadata (default: false, plain text).
	JSONFormat bool

	// FileMode is the permission mode for secret files (default: 0600).
	FileMode os.FileMode

	// DirMode is the permission mode for directories (default: 0700).
	DirMode os.FileMode

	// ReadOnly prevents write and delete operations.
	ReadOnly bool
}

Config holds configuration for the file provider.

type Provider

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

Provider implements vault.Vault with file-based storage.

func New

func New(config Config) (*Provider, error)

New creates a new file provider with the given configuration.

func (*Provider) Capabilities

func (p *Provider) Capabilities() vault.Capabilities

Capabilities returns the provider capabilities.

func (*Provider) Close

func (p *Provider) Close() error

Close is a no-op for the file provider.

func (*Provider) Delete

func (p *Provider) Delete(ctx context.Context, path string) error

Delete removes a secret file.

func (*Provider) Exists

func (p *Provider) Exists(ctx context.Context, path string) (bool, error)

Exists checks if a secret file exists.

func (*Provider) Get

func (p *Provider) Get(ctx context.Context, path string) (*vault.Secret, error)

Get retrieves a secret from a file.

func (*Provider) List

func (p *Provider) List(ctx context.Context, prefix string) ([]string, error)

List returns all secret paths matching the prefix.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the provider name.

func (*Provider) Set

func (p *Provider) Set(ctx context.Context, path string, secret *vault.Secret) error

Set stores a secret to a file.

Jump to

Keyboard shortcuts

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