userconfig

package
v0.3.2 Latest Latest
Warning

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

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

Documentation

Overview

Package userconfig persists per-user, non-secret state in a small JSON file at os.UserConfigDir()/pipedrive-mcp/config.json. The keyring stores the API token; this file stores the domain pointer so subsequent server runs don't need PIPEDRIVE_COMPANY_DOMAIN re-supplied on every invocation.

File contents are intentionally minimal. Anything secret stays in the keyring; anything operational stays in env vars. This file is for the "which workspace did I last log in to" pointer, the same role `~/.config/gh/hosts.yml` plays for `gh`.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearDefaultDomainIfMatches

func ClearDefaultDomainIfMatches(path, domain string) error

ClearDefaultDomainIfMatches clears DefaultDomain only when it equals domain. Used by `logout` so we don't accidentally clear a different workspace's pointer when the user logs out of one of several stored tokens.

func DefaultPath

func DefaultPath() (string, error)

DefaultPath returns os.UserConfigDir()/pipedrive-mcp/config.json.

func Save

func Save(path string, f File) error

Save writes f to path atomically (write-then-rename in the same dir) with 0600 perms on the file and 0700 on the parent dir. A kill -9 mid-write would otherwise leave a half-truncated file.

func SetDefaultDomain

func SetDefaultDomain(path, domain string) error

SetDefaultDomain reads the file at path, updates DefaultDomain, and writes it back. Convenience for the `login` subcommand.

Types

type File

type File struct {
	DefaultDomain string `json:"default_domain,omitempty"`
}

File is the JSON shape persisted on disk. omitempty so a cleared file is `{}`, not `{"default_domain":""}` — readable when inspected by hand.

func Load

func Load(path string) (File, error)

Load reads the file at path. A missing file is the steady state on a fresh install — Load returns a zero File and a nil error in that case so callers don't need to special-case first-run.

Jump to

Keyboard shortcuts

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