feat(config): named configurations for multi-instance support #19
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/configurations-multi-instance"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Adds named configurations for multi-instance support, following the
gcloudpattern. Each YouTrack instance is a separate profile; commands target the active one by default and any individual command can override it without changing what's active.Disk layout
$XDG_CONFIG_HOME/youtrack-cli/configurations/config_<name>.yamlper profile (mode 0600).$XDG_CONFIG_HOME/youtrack-cli/active_configsingle-line pointer to the active profile (mode 0600).Resolution order
Highest priority first:
--configuration <name>global flag$YOUTRACK_CLI_ACTIVE_CONFIGenv varactive_configpointer file--config <path>still works and bypasses the named-configuration store entirely, reading a single YAML file. Used by tests and as an escape hatch.New subcommands
First-run / friendly UX
yt auth login --base-url <url>on a fresh install (noactive_configpointer, no profiles) auto-creates and activates a profile nameddefault. So getting started is still one command. With an explicit--configurationor an already-active profile, login writes to that profile and never silently rewires which one is active.Migration of the pre-feature single
config.yamlNOT auto-migrated, per the explicit decision on this PR. Existing users hitting a read command will see:
The legacy
~/.config/youtrack-cli/config.yamlis left in place; users can either rerunauth login(clean slate, creates a newdefault) or manually move the file toconfigurations/config_default.yamland writedefaultintoactive_config.Plumbing
src/config.rs->src/config/(withmod.rskeeping theConfigstruct + filesystem helpers andstore.rsadding the named-configuration layer).Config::load_active(path_override, configuration_override) -> (Config, ConfigSource). Every command'srunnow takes aconfiguration_override: Option<&str>and funnels through it.config setwrites back viaConfigSource::save_to, so it lands in whichever file the load came from.Config::default_path()is removed: there is no single canonical config path anymore.Verification
cargo fmt --checkclean.cargo clippy --all-targets -- -D warningsclean.cargo test --all-targets: 160 tests pass (24 new on this branch).yt --helpshows--configuration <CONFIGURATION>+ env var.yt config configurations --helpshows the 5-verb surface.Coverage on this PR: gcloud-style name validation (empty / uppercase / underscore / leading-digit rejected), full resolution priority order, pure resolver returns
Nonewhen nothing set, CRUD on the store (create + duplicate refusal, activate + activate-unknown error, delete-active refusal, delete-inactive success), 0600 mode on the active pointer file, list / describe end-to-end including masked + unmasked token output.Test plan
yt auth login --base-url https://<instance>creates~/.config/youtrack-cli/configurations/config_default.yaml, writesdefaultintoactive_config, and the profile is usable immediately.yt config configurations create prodcreates a second profile and switches to it.yt --configuration default listuses thedefaultprofile for one command without touchingactive_config.yt config configurations listshows both profiles with*on the active one.yt config configurations delete <active>is refused; deleting the other one succeeds.~/.config/youtrack-cli/config.yamlbut noconfigurations/dir, the firstyt listerrors with the migration hint and the legacy file is untouched.yt updateself-replacing binary updater #24