Skip to content

feat: import-key/export-key + HULAK_MASTER_KEY fallback#183

Merged
xaaha merged 8 commits intomainfrom
131-hulak-env-import-keyexport-key-hulak_master_key-fallback
Apr 29, 2026
Merged

feat: import-key/export-key + HULAK_MASTER_KEY fallback#183
xaaha merged 8 commits intomainfrom
131-hulak-env-import-keyexport-key-hulak_master_key-fallback

Conversation

@xaaha
Copy link
Copy Markdown
Owner

@xaaha xaaha commented Apr 29, 2026

Summary

Closes #131

  • ResolveIdentity() — fallback chain: HULAK_MASTER_KEY env var → identity.txt file
  • All decrypt call sites switched from LoadIdentity()ResolveIdentity()
  • Friendly error wrapping when HULAK_MASTER_KEY doesn't match recipients
  • hulak env export-key with --out/-o flag
  • hulak env import-key with --stdin, --force, atomic tmp+rename
  • Extracted utils.AtomicWriteFile (used by both ImportKey and WriteStore)
  • Removed notImplemented stub — all env commands wired

Test plan

  • go test ./... passes
  • go vet ./... clean
  • E2E: hulak env export-key prints key with stderr warning
  • E2E: hulak env export-key --out /tmp/test.txt writes 0600 file
  • E2E: hulak env import-key /tmp/test.txt --force imports successfully
  • E2E: echo "$KEY" | hulak env import-key --stdin works
  • E2E: HULAK_MASTER_KEY=<valid-key> hulak env get KEY --env prod decrypts
  • E2E: HULAK_MASTER_KEY=<wrong-key> hulak env get KEY shows friendly error
  • E2E: HULAK_MASTER_KEY=age1... hulak env get KEY says "looks like a public key"

@xaaha xaaha linked an issue Apr 29, 2026 that may be closed by this pull request
@xaaha xaaha requested a review from pthapa1 April 29, 2026 02:52
@xaaha xaaha merged commit a59056e into main Apr 29, 2026
2 checks passed
@xaaha xaaha deleted the 131-hulak-env-import-keyexport-key-hulak_master_key-fallback branch April 29, 2026 16:01
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.

hulak env import-key/export-key + HULAK_MASTER_KEY fallback

2 participants