config

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config stores the CLI settings, the session and the delete tokens.

Files live in $XDG_CONFIG_HOME/hemmelig (usually ~/.config/hemmelig). The CLI creates the directory with mode 0700 and the files with mode 0600, because they hold credentials.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteToken

func DeleteToken(baseURL, id string) string

DeleteToken returns the stored delete token for a secret, if any.

func Dir

func Dir() (string, error)

Dir returns the configuration directory. HEMMELIG_CONFIG_DIR overrides it, which the tests use.

func ForgetDeleteToken

func ForgetDeleteToken(baseURL, id string) error

ForgetDeleteToken removes the stored delete token for a secret.

func Path

func Path() (string, error)

Path returns the path of config.json.

func SaveDeleteToken

func SaveDeleteToken(baseURL, id, token string) error

SaveDeleteToken stores the delete token for a secret.

Types

type Config

type Config struct {
	URL     string   `json:"url,omitempty"`
	APIKey  string   `json:"apiKey,omitempty"`
	Session *Session `json:"session,omitempty"`
}

Config is the content of config.json.

func Load

func Load() (*Config, error)

Load reads config.json. A missing file gives an empty Config.

func (*Config) Save

func (c *Config) Save() error

Save writes config.json with mode 0600.

type Session

type Session struct {
	URL       string    `json:"url"`
	Cookie    string    `json:"cookie"`
	Username  string    `json:"username,omitempty"`
	CreatedAt time.Time `json:"createdAt"`
}

Session is a signed-in session from `hemmelig login`.

type Token

type Token struct {
	DeleteToken string    `json:"deleteToken"`
	SavedAt     time.Time `json:"savedAt"`
}

Token is a delete token for one secret.

type Tokens

type Tokens map[string]Token

Tokens maps "<base url>|<secret id>" to a delete token.

func LoadTokens

func LoadTokens() (Tokens, error)

LoadTokens reads tokens.json and drops tokens older than 30 days, because no secret lives longer than 28 days.

Jump to

Keyboard shortcuts

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