secret

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package secret provides a file-permission-protected secret store for klausctl. Secrets are stored as a flat YAML map in ~/.config/klausctl/secrets.yaml with owner-only (0600) file permissions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateName

func ValidateName(name string) error

ValidateName checks that a secret name is safe for use as both a map key and a filename. Names must start with an alphanumeric character and contain only alphanumerics, dots, hyphens, or underscores.

Types

type Store

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

Store manages named secrets persisted as a YAML file with restricted file permissions.

func Load

func Load(path string) (*Store, error)

Load reads secrets from the given file path. If the file does not exist, an empty store is returned. An error is returned when the file exists but cannot be read or parsed, or when file permissions are too open.

func (*Store) Delete

func (s *Store) Delete(name string) error

Delete removes a named secret. Returns an error when the name is not found.

func (*Store) Get

func (s *Store) Get(name string) (string, error)

Get retrieves a secret by name. Returns an error when the name is not found.

func (*Store) List

func (s *Store) List() []string

List returns all secret names in sorted order.

func (*Store) Save

func (s *Store) Save() error

Save writes the current secrets to disk with 0600 permissions.

func (*Store) Set

func (s *Store) Set(name, value string) error

Set stores or updates a named secret. Returns an error if the name is invalid.

Jump to

Keyboard shortcuts

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