secrets

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DiffResult

type DiffResult struct {
	Added     []string             // Keys only in .env
	Removed   []string             // Keys only in Cloud
	Changed   map[string][2]string // Key -> [LocalVal, CloudVal]
	Unchanged []string
}

DiffResult holds the differences between local and cloud secrets.

type EnvManager

type EnvManager struct {
	EnvPath        string
	EnvExamplePath string
}

EnvManager handles reading and writing .env files while preserving comments.

func NewEnvManager

func NewEnvManager() *EnvManager

NewEnvManager creates a manager for the current directory.

func (*EnvManager) Delete

func (m *EnvManager) Delete(key string) error

Delete removes a key from both files.

func (*EnvManager) Read

func (m *EnvManager) Read() (map[string]string, error)

Read returns all secrets from the .env file as a map.

func (*EnvManager) Write

func (m *EnvManager) Write(newSecrets map[string]string) error

Write merges the provided secrets into .env and updates .env.example.

type SecretMetadata

type SecretMetadata struct {
	Key       string `json:"key"`
	Value     string `json:"value,omitempty"` // Encrypted value
	UpdatedAt string `json:"updated_at"`
}

SecretMetadata holds the secret metadata from the API.

type Service

type Service struct {
	API *api.Client
	Env *EnvManager
}

Service coordinates all secret-related operations.

func NewService

func NewService(apiClient *api.Client) *Service

NewService creates a new secrets service.

func (*Service) BatchSet

func (s *Service) BatchSet(kv map[string]string) error

BatchSet adds or updates multiple secrets in a single API call.

func (*Service) Delete

func (s *Service) Delete(key string) error

Delete removes a secret from cloud, .env, and Keychain.

func (*Service) Diff

func (s *Service) Diff() (*DiffResult, error)

Diff compares local secrets (either .env or keychain) with cloud secrets.

func (*Service) Get

func (s *Service) Get(key string) (string, error)

Get retrieves and decrypts a single secret.

func (*Service) List

func (s *Service) List(showValues bool) ([]SecretMetadata, error)

List returns all secret keys for the project. If showValues is true, it decrypts them.

func (*Service) Pull

func (s *Service) Pull(targetKeys []string) error

Pull downloads secrets from the cloud and updates .env + Keychain. If targetKeys is nil, all secrets are pulled. If targetKeys is non-nil (even if empty), only those specific keys are pulled.

func (*Service) Push

func (s *Service) Push() error

Push uploads all local secrets (.env or keychain) to the cloud.

func (*Service) Set

func (s *Service) Set(key, value string) error

Set adds or updates a single secret.

Jump to

Keyboard shortcuts

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