config

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package config resolves linkedin configuration with a manual flag > env > file > default precedence (no Viper, per the cliwright house pattern). LinkedIn's public API needs no credentials, so a profile is optional; when present it holds only non-secret settings (host overrides, whether a bearer token is stored). Any token lives in the OS keyring.

Index

Constants

View Source
const DefaultProfile = "default"

DefaultProfile is used when no profile is selected anywhere.

Variables

This section is empty.

Functions

func Dir

func Dir() (string, error)

Dir returns the configuration directory: $XDG_CONFIG_HOME/linkedin if set, else ~/.linkedin-cli.

func FirstNonEmpty

func FirstNonEmpty(vals ...string) string

FirstNonEmpty returns the first non-empty string — the manual precedence helper used across linkedin instead of a config framework.

func Path

func Path() (string, error)

Path returns the config file path.

func ValidateBaseURL

func ValidateBaseURL(raw string) error

ValidateBaseURL requires an http/https URL with a host and rejects cleartext http:// for a non-loopback host.

func ValidateProfileName

func ValidateProfileName(name string) error

ValidateProfileName rejects empty names and traversal-dangerous characters.

Types

type Config

type Config struct {
	CurrentProfile string             `yaml:"current_profile,omitempty"`
	Profiles       map[string]Profile `yaml:"profiles,omitempty"`
	Aliases        map[string]string  `yaml:"aliases,omitempty"`
	// contains filtered or unexported fields
}

Config is the on-disk configuration.

func Load

func Load() (*Config, error)

Load reads the config file, returning an empty (but valid) Config if it does not exist.

func LoadFrom

func LoadFrom(p string) (*Config, error)

LoadFrom reads a config from an explicit path (used in tests).

func (*Config) FilePath

func (c *Config) FilePath() string

FilePath returns where this config reads/writes.

func (*Config) Profile

func (c *Config) Profile(name string) (Profile, bool)

Profile returns the named profile (and whether it exists).

func (*Config) ProfileNames

func (c *Config) ProfileNames() []string

ProfileNames returns the profile names (unsorted; callers sort for display).

func (*Config) ResolveProfileName

func (c *Config) ResolveProfileName(flag string) string

ResolveProfileName applies precedence: explicit flag > LINKEDIN_PROFILE > current_profile > default.

func (*Config) Save

func (c *Config) Save() error

Save writes the config atomically (temp-in-same-dir + rename), dir 0700 / file 0600.

func (*Config) SetProfile

func (c *Config) SetProfile(name string, p Profile) error

SetProfile creates or replaces a profile after validating its name and any base URLs.

type Profile

type Profile struct {
	VoyagerBaseURL string `yaml:"voyager_base_url,omitempty" json:"voyager_base_url,omitempty"`
	WebBaseURL     string `yaml:"web_base_url,omitempty" json:"web_base_url,omitempty"`
	HasCookies     bool   `yaml:"has_cookies,omitempty" json:"has_cookies,omitempty"`     // a session cookie pair is stored in the keyring
	CookieSource   string `yaml:"cookie_source,omitempty" json:"cookie_source,omitempty"` // where the stored cookies came from (e.g. "chrome (Default)")
}

Profile holds the non-secret settings for one LinkedIn context. The optional bearer token lives in the keyring under this profile's key, never here.

Jump to

Keyboard shortcuts

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