Skip to content

feat(config): migrate config.toml profiles to the keychain and state.toml#246

Merged
LorrisSaintGenez merged 2 commits into
feat/migration-triggerfrom
feat/migration-body
Jun 12, 2026
Merged

feat(config): migrate config.toml profiles to the keychain and state.toml#246
LorrisSaintGenez merged 2 commits into
feat/migration-triggerfrom
feat/migration-body

Conversation

@LorrisSaintGenez

@LorrisSaintGenez LorrisSaintGenez commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

What

Second step of GROUT-363, stacked on #245: Config.Migrate() gets its body.

  • Per config.toml profile: api_key (+ crawler_api_key if set) is stored in the OS keychain under the profile's application ID
  • One state.toml entry per application with alias = <profile name>; api_key_uuid left empty (unknown for legacy keys, API lookup comes later)
  • current_application_id = the default = true profile's application
  • Keychain first, state.toml last (atomic temp + rename via State.Save): a keychain failure aborts before state.toml exists, so the migration retries on the next run
  • An empty config.toml still writes an empty state.toml, so the trigger turns off instead of re-firing on every command

config.toml itself is never modified.

Test

# on a machine with legacy config.toml profiles
rm -f ~/.config/algolia/state.toml
go run ./cmd/algolia indices list      # any command triggers the migration
cat ~/.config/algolia/state.toml       # aliases + current_application_id
# macOS: the migrated key is in the keychain (replace <APP_ID>; go-keyring stores it base64-encoded)
security find-generic-password -s algolia-cli -a "app:<APP_ID>" -w | sed "s/^go-keyring-base64://" | base64 -d

GROUT-363

…toml

Per profile: api_key (+ crawler_api_key if set) goes to the OS keychain
under the profile's application ID, state.toml gets an entry with
alias = profile name, and current_application_id is taken from the
default = true profile. api_key_uuid stays empty for legacy keys.

Keychain first, state.toml last (atomic temp + rename): a keychain
failure leaves state.toml absent so the migration retries on the next
run. An empty config.toml still writes an empty state.toml so the
trigger turns off.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@codacy-production

codacy-production Bot commented Jun 12, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 23 complexity · 3 duplication

Metric Results
Complexity 23
Duplication 3

View in Codacy

TIP This summary will be updated as you push new changes.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
@LorrisSaintGenez LorrisSaintGenez marked this pull request as ready for review June 12, 2026 21:08
@LorrisSaintGenez LorrisSaintGenez merged commit d73969b into feat/migration-trigger Jun 12, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant