secrets

package
v0.2.21 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package secrets provides secure storage for environment variables and secrets. This file is stored separately from config.json and should be gitignored.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultSecretsPath

func DefaultSecretsPath() (string, error)

DefaultSecretsPath returns the path to the default secrets file

Types

type Store

type Store struct {
	// EnvironmentVariables maps environment names to their variables
	EnvironmentVariables map[string]map[string]string `json:"environmentVariables"`
	// contains filtered or unexported fields
}

Store manages environment variables in a separate secrets file

func Load

func Load() (*Store, error)

Load loads secrets from the default path

func LoadFromDir

func LoadFromDir(dir string) (*Store, error)

LoadFromDir loads secrets from a specific directory

func LoadFromFile

func LoadFromFile(filePath string) (*Store, error)

LoadFromFile loads secrets from a specific file path

func NewStore

func NewStore() *Store

NewStore creates a new Store instance

func (*Store) AddEnvironment

func (s *Store) AddEnvironment(name string, vars map[string]string) error

AddEnvironment adds a new environment

func (*Store) GetEnvironment

func (s *Store) GetEnvironment(envName string) map[string]string

GetEnvironment returns the combined environment variables for the given environment name. It merges $shared variables with the specified environment, with environment values taking precedence.

func (*Store) GetVariable

func (s *Store) GetVariable(env, name string) (string, bool)

GetVariable gets a variable from a specific environment

func (*Store) GetVariables

func (s *Store) GetVariables(env string) (map[string]string, bool)

GetVariables returns all variables for a specific environment

func (*Store) HasEnvironment

func (s *Store) HasEnvironment(name string) bool

HasEnvironment checks if an environment exists

func (*Store) ListEnvironments

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

ListEnvironments returns a list of available environment names (excluding $shared)

func (*Store) Path

func (s *Store) Path() string

Path returns the current secrets file path

func (*Store) RemoveEnvironment

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

RemoveEnvironment removes an environment

func (*Store) Save

func (s *Store) Save() error

Save saves the secrets to the file

func (*Store) SetVariable

func (s *Store) SetVariable(env, name, value string) error

SetVariable sets a variable in an environment

func (*Store) UnsetVariable

func (s *Store) UnsetVariable(env, name string) error

UnsetVariable removes a variable from an environment

Jump to

Keyboard shortcuts

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