feat(config): per-instance config files keyed on URL subdomain #26
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/per-instance-config"
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
Redesigns the multi-instance config layout that landed in PR #19 so adding a new YouTrack instance never overwrites an existing one. Each instance gets its own YAML file keyed on the URL subdomain:
auth loginderives the instance name from the first hostname label of--base-url. Logging in to a new URL writes a new file. Thedefault:pointer is set on the first login and is NOT silently changed afterwards: a secondauth loginleaves the default alone.Resolution order
Highest priority first:
--instance <name>(renamed from--configuration)$YOUTRACK_CLI_INSTANCE(renamed from$YOUTRACK_CLI_ACTIVE_CONFIG)default:field inconfig.yml--config <path>bypasses everything and reads a single file directly (mostly for tests).CLI surface changes
The
config configurations {create,activate,list,describe,delete}subcommand group is dropped per the design call:auth loginis the creation path;--instanceis the per-command override; switching the default isvim ~/.config/youtrack-cli/config.yml. The list / describe / delete verbs are listed in TODO for a futureyt auth listif they earn their keep.Rename map
--configuration <name>--instance <name>$YOUTRACK_CLI_ACTIVE_CONFIG$YOUTRACK_CLI_INSTANCEConfigurations(store)Instancessrc/config/store.rssrc/config/instances.rsConfigSource::Configuration(s)ConfigSource::Instance(s)configuration_override: Option<&str>instance_override: Option<&str>configurations/config_<name>.yamlconfig-<instance>.ymlactive_config(single-line text)config.ymlwithdefault: <name>Migration of the pre-feature layout
Not auto-migrated. Existing users with
configurations/config_<name>.yaml+active_configsee the same "no instance configured" hint a fresh-install user sees. Manual migration:URL parsing details
Uses
url::Url::host()so the typed enum (Domain/Ipv4/Ipv6) drives the IP-vs-domain decision. Rejects IPv4 literals, bracketed IPv6 literals, and single-label hosts (localhost, raw IPs) with a message telling the user to pass--instance <name>explicitly. Derived names are lowercased and validated against the same gcloud rules already in place (lowercase letter prefix, then lowercase letters / digits / hyphens).Verification
cargo fmt --checkclean.cargo clippy --all-targets -- -D warningsclean.cargo test --all-targets: 178 tests pass (8 store tests removed for dropped methods, 10 new tests for URL derivation + pointer round-trip + name validation, 6 fewer overall because the deletedconfig configurationssubcommand test module went with it).yt --helpshows--instance; noconfig configurationssubgroup remains.Test plan
yt auth login --base-url https://niceguyit.myjetbrains.com. Confirm~/.config/youtrack-cli/config-niceguyit.ymlexists with the token and~/.config/youtrack-cli/config.ymlcontainsdefault: niceguyit.yt auth login --base-url https://prod.youtrack.cloud. Confirm~/.config/youtrack-cli/config-prod.ymlis new,config-niceguyit.ymlis unchanged, andconfig.ymlstill saysdefault: niceguyit.yt --instance prod listreads fromconfig-prod.ymlwithout touching the default.vim ~/.config/youtrack-cli/config.yml, changedefault:toprod, thenyt listuses prod.yt auth login --base-url https://localhost:8080fails with the "single-label" hint and tells the user to pass--instance <name>.yt auth login --base-url https://localhost:8080 --instance devsucceeds and writesconfig-dev.yml.