Documentation
¶
Overview ¶
Package customcfg holds hand-written (NOT generated) configuration that the generated config.Config struct can't carry — named profiles, each with a server URL and (keychain-stored) secret — plus one-time migration from the legacy TS CLI. It lives in its own package and a separate file (~/.config/growthbook/cli.yaml) so it survives regeneration; the generated config layer is never edited.
Profile resolution sits in front of the generated credential chain (flag > env > keychain > config): the active profile injects its server URL into the --server-url flag and its secret into GBCLI_BEARER_AUTH, but only when the user hasn't supplied those explicitly — so explicit flags/env always win and the rest of the chain still applies when no profile is active.
Update / compatibility advisory (hand-written, NOT generated). Lives in the custom layer so it survives regeneration.
Principle (see the migration plan §F): the nudge must be *correct* — never push a user toward a CLI that targets endpoints their backend lacks. The orderable compatibility signal is the build DATE: nudge to a newer CLI only if the connected backend's build date is >= that CLI's generated-against date. semver is compared first (is a newer CLI even out?), then date. If either date is empty (dev builds), we degrade to semver and lean permissive.
Guardrails: advisory-only (never auto-updates), at most once/day, stderr only (so JSON on stdout stays clean), auto-off in CI / non-TTY, and opt-out via --no-update-check or GBCLI_NO_UPDATE_CHECK.
Index ¶
- Variables
- func BearerFromProfile() bool
- func DeleteProfileSecret(name string) error
- func GetProfileSecret(name string) string
- func MaybeCheckForUpdate(cmd *cobra.Command)
- func OnStartup(cmd *cobra.Command) error
- func Path() string
- func SetProfileSecret(name, secret string) error
- func Versioned404Hint(requestPath string) string
- type File
- type Profile
Constants ¶
This section is empty.
Variables ¶
var ( Version = "dev" Commit = "" SpecDate = "" )
Build metadata, injected via -ldflags at release (see .goreleaser.yaml). Empty in local/dev builds.
- Version: the CLI's own semver, e.g. "1.0.0"
- Commit: short git SHA of the CLI build (human-readable messages only)
- SpecDate: the generated-against date — the commit date (YYYY-MM-DD) of the backend spec.yaml the CLI was generated from. The orderable compat signal.
Functions ¶
func BearerFromProfile ¶
func BearerFromProfile() bool
BearerFromProfile reports whether the active profile supplied the bearer credential during startup.
func DeleteProfileSecret ¶
func GetProfileSecret ¶
GetProfileSecret / SetProfileSecret / DeleteProfileSecret manage per-profile secrets in the OS keychain.
func MaybeCheckForUpdate ¶
MaybeCheckForUpdate is the guarded entry point, called from OnStartup. It never blocks meaningfully (bounded network timeout, at most once/day) and never returns an error — an advisory must not break the user's command.
func OnStartup ¶
OnStartup runs custom startup logic from the root PersistentPreRunE (added via persistentEdits): one-time legacy migration, then active-profile resolution.
func Path ¶
func Path() string
Path returns the on-disk location of the custom config (cli.yaml), where profiles are stored. Exported for `whoami` to surface alongside config.yaml.
func SetProfileSecret ¶
func Versioned404Hint ¶
Versioned404Hint returns an actionable message for a 404 on a versioned endpoint — defense-in-depth pointing at the legacy group / a server upgrade. (Wiring it into the SDK error path is release infra; exposed for that use.)
Types ¶
type File ¶
type File struct {
Current string `yaml:"current,omitempty"`
Profiles map[string]Profile `yaml:"profiles,omitempty"`
MigratedFromLegacy bool `yaml:"migrated_from_legacy,omitempty"`
}
File is the on-disk custom config, kept beside the generated config.yaml.