Skip to content

Conversation

@keyz-tk
Copy link
Contributor

@keyz-tk keyz-tk commented May 23, 2023

Summary

See tkhq/go-sdk#10 and tkhq/go-sdk#11 for the SDK parts

Fixes #34

Test Plan

# Generate key via the old CLI
$ turnkey generate-api-key --organization e53d8453-aa58-4f2c-ad36-195f41fd756e
{
   "privateKeyFile": "/Users/keyan/Library/Application Support/turnkey/keys/default.private",
   "publicKey": "03328da93a7d6cc578321daeb87801315c1b59894149233f051e72c17c200a1298",
   "publicKeyFile": "/Users/keyan/Library/Application Support/turnkey/keys/default.public"
}

# Inspect old files
$ ls ~/Library/Application\ Support/turnkey/keys
default.meta    default.private default.public

# Run new CLI; migration script kicks off
$ ./build/turnkey gen
Legacy keys directory detected; will migrate keys to new location
- Legacy: /Users/keyan/Library/Application Support/turnkey/keys
- New: /Users/keyan/.config/turnkey/keys

Moved `default.meta` to /Users/keyan/.config/turnkey/keys/default.meta
Moved `default.private` to /Users/keyan/.config/turnkey/keys/default.private
Moved `default.public` to /Users/keyan/.config/turnkey/keys/default.public

Successfully migrated legacy keys directory.

{
   "error": "please supply an organization ID (UUID)"
}

# Legacy folder is now empty
$ ls ~/Library/Application\ Support/turnkey/keys
ls: /Users/keyan/Library/Application Support/turnkey/keys: No such file or directory

# New folder now contains `default.meta`, `default.private`, and `default.public`

# Running new CLI again: it no longer triggers the migration script
$ ./build/turnkey gen
{
   "error": "please supply an organization ID (UUID)"
}

# This one fails, because `default` already exists after the migration
$ ./build/turnkey gen --organization e53d8453-aa58-4f2c-ad36-195f41fd756e
{
   "error": "failed to store new API keypair: a keypair named \"default\" already exists; exiting"
}

$ ./build/turnkey gen --organization e53d8453-aa58-4f2c-ad36-195f41fd756e --key-name something-new
{
   "privateKeyFile": "/Users/keyan/.config/turnkey/keys/something-new.private",
   "publicKey": "03a1d88de7724b0d8d34a82aa6c681e2c42d315038d3ce80e8a788de9969bd6de0",
   "publicKeyFile": "/Users/keyan/.config/turnkey/keys/something-new.public"
}

Copy link
Collaborator

@r-n-o r-n-o left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@r-n-o r-n-o merged commit 5e2c831 into main May 24, 2023
@Ulexus Ulexus deleted the macos-path branch June 5, 2023 15:32
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.

On macOS, write to ~/.config/turnkey/

3 participants