config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package config stores connection profiles — named endpoints such as "staging" or "prod" — in one JSON file with mode 0600, since it holds passwords. The local container is the built-in "local" profile and is never stored.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultPath added in v0.2.0

func DefaultPath() string

DefaultPath is <user config dir>/dbclone/profiles.json.

func ValidName added in v0.2.0

func ValidName(name string) error

ValidName checks a new profile name.

Types

type Profile added in v0.2.0

type Profile struct {
	Name   string            `json:"name"`
	Values map[string]string `json:"values"`
}

type Store added in v0.2.0

type Store struct {
	Path     string    `json:"-"`
	Profiles []Profile `json:"profiles"`
}

func Load

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

Load reads the store; a missing file is an empty store.

func (*Store) Delete added in v0.2.0

func (s *Store) Delete(name string)

func (*Store) Endpoint added in v0.2.0

func (s *Store) Endpoint(name string) (driver.Endpoint, error)

Endpoint resolves a profile name, "local" included.

func (*Store) Get added in v0.2.0

func (s *Store) Get(name string) (Profile, bool)

func (*Store) ImportLegacy added in v0.2.0

func (s *Store) ImportLegacy(path string) (bool, error)

ImportLegacy turns an old .env.staging file into a "staging" profile, once. It reports whether a profile was added.

func (*Store) Names added in v0.2.0

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

Names returns the profile names, sorted.

func (*Store) Put added in v0.2.0

func (s *Store) Put(old string, p Profile)

Put adds p, or replaces the profile called old (old may equal p.Name).

func (*Store) Save added in v0.2.0

func (s *Store) Save() error

Save writes the store with mode 0600 — it holds passwords.

Jump to

Keyboard shortcuts

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