Skip to content

refactor: simplify key command config handling - #1420

Merged
gjermundgaraba merged 1 commit into
fix/key-clifrom
refactor/key-cli-config
Aug 25, 2026
Merged

refactor: simplify key command config handling#1420
gjermundgaraba merged 1 commit into
fix/key-clifrom
refactor/key-cli-config

Conversation

@gjermundgaraba

Copy link
Copy Markdown
Contributor

Summary

  • keep key-only commands independent of the config file
  • preflight config population and roll back new keys when config persistence fails
  • make config replacement atomic and remove one-caller config helpers

Tests

  • make lint-fix
  • go test ./internal/config ./cmd/ibc -count=1

@gjermundgaraba
gjermundgaraba requested a review from a team as a code owner August 25, 2026 07:33
@greptile-apps

greptile-apps Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR separates key-only commands from config loading, preflights optional signer population, rolls back newly written keys when config persistence fails, and replaces direct config writes with temporary-file renames.

  • Removes optional-config setup from key creation, import, display, and listing.
  • Consolidates key storage and optional signer registration in saveNamedKey.
  • Preserves existing config permissions while replacing config files atomically.
  • Adds focused tests for config population, alias conflicts, invalid config, and rollback.

Confidence Score: 4/5

The config replacement behavior should be fixed before merging because persisting configuration through a symlink silently breaks the link and leaves its target stale.

The new temporary-file rename changes established path semantics for every config-writing command by replacing an existing symbolic link with a regular file.

Files Needing Attention: link/internal/config/config.go

Important Files Changed

Filename Overview
link/cmd/ibc/keys.go Consolidates key persistence and optional config population with preflight alias checks and rollback on config-write failure.
link/internal/config/config.go Introduces temporary-file replacement for config writes, but the rename replaces existing configuration symlinks rather than updating their targets.
link/cmd/ibc/config.go Removes the optional-config helper and applies the database flag override directly during required config setup.
link/cmd/ibc/main.go Delegates required private-key flag validation to Cobra.
link/cmd/ibc/keys_test.go Adds coverage for signer population, alias conflicts, invalid configuration, and key rollback.

Reviews (1): Last reviewed commit: "simplify key command config handling" | Re-trigger Greptile

Comment thread link/internal/config/config.go
@swift1337
swift1337 force-pushed the fix/key-cli branch 2 times, most recently from ee1ad8e to b80eee7 Compare August 25, 2026 10:23
Signed-off-by: Gjermund Garaba <gjermund@garaba.net>
@gjermundgaraba
gjermundgaraba force-pushed the refactor/key-cli-config branch from d01a3c0 to 3985ae9 Compare August 25, 2026 12:33
@gjermundgaraba gjermundgaraba changed the title Simplify key command config handling refactor: simplify key command config handling Aug 25, 2026
@gjermundgaraba gjermundgaraba mentioned this pull request Aug 25, 2026
3 tasks
@gjermundgaraba
gjermundgaraba merged commit c9fcec8 into fix/key-cli Aug 25, 2026
10 checks passed
@gjermundgaraba
gjermundgaraba deleted the refactor/key-cli-config branch August 25, 2026 14:26
swift1337 added a commit that referenced this pull request Aug 25, 2026
* allow `ibc keys *` w/o config

* add -p shorthand for --populate-config

* simplify

* streamline --populate-config logic; fail on existing key

* simplify key command config handling (#1420)

Signed-off-by: Gjermund Garaba <gjermund@garaba.net>

---------

Signed-off-by: Gjermund Garaba <gjermund@garaba.net>
Co-authored-by: Gjermund Garaba <gjermund@garaba.net>
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.

2 participants