Documentation
¶
Overview ¶
Package config resolves the credentials and endpoint used by pmock-cli.
Precedence (highest first):
flags (handled by the caller) PMOCK_ACCESS_KEY / PMOCK_SECRET_KEY / PMOCK_BASE_URL / PMOCK_TIMEOUT ~/.pmock-cli/config.json built-in defaults
The file is created with 0600 and its directory with 0700 because it holds a long-lived team secret.
Index ¶
Constants ¶
const ( // DefaultBaseURL is the host prefix; every spec path starts with /open/api. DefaultBaseURL = "https://user.pmock.com/api" // DefaultTimeout is the per-request budget. DefaultTimeout = 30 * time.Second EnvAccessKey = "PMOCK_ACCESS_KEY" EnvSecretKey = "PMOCK_SECRET_KEY" EnvBaseURL = "PMOCK_BASE_URL" EnvTimeout = "PMOCK_TIMEOUT" // EnvConfigFile overrides the config path (tests, CI, multiple profiles). EnvConfigFile = "PMOCK_CLI_CONFIG" )
Variables ¶
This section is empty.
Functions ¶
func EnvOverrides ¶
func EnvOverrides() []string
EnvOverrides lists the environment variables currently taking precedence.
func MaskAccessKey ¶
MaskAccessKey keeps the key recognizable without disclosing it.
Types ¶
type Config ¶
type Config struct {
AccessKey string `json:"accessKey,omitempty"`
SecretKey string `json:"secretKey,omitempty"`
BaseURL string `json:"baseUrl,omitempty"`
TimeoutSeconds int `json:"timeoutSeconds,omitempty"`
// Timeout is derived, never serialized.
Timeout time.Duration `json:"-"`
}
Config is the persisted and effective CLI configuration.
func LoadFile ¶
LoadFile reads only the config file, ignoring environment overrides. It is used by `config init` so a CI-injected credential does not get copied into the user's file.
func LoadForDisplay ¶
LoadForDisplay reads the file and applies environment overrides, tolerating a missing token (so `config show` works before setup).