Skip to content

Conversation

@OliverTrautvetter
Copy link
Member

Feat: Auto-upgrade and output legacy API Keys

Implements logic in the OMS CLI to detect and handle legacy API keys. The CLI will now automatically query the OMS Portal to retrieve the missing Key ID, generate the new concatenated API key (key_id + key), and output the new format to the user. This simplifies the user experience during the key migration.


CU Card (ClickUp Task)

It("should detect the old format and attempt to upgrade", func() {
cmd := exec.Command(cliPath, "version")
cmd.Env = append(os.Environ(),
"OMS_PORTAL_API_KEY=U4jsSHoDsOFGyEkPrWpsE", // 22 characters
Copy link
Member

Choose a reason for hiding this comment

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

can we use something that's more obviously not a real API KEY like fakeapikeywith22charsa?

}
opts.OmsPortalApiKey = newApiKey

fmt.Fprintf(os.Stderr, "Successfully upgraded API key to new format!\n")
Copy link
Member

Choose a reason for hiding this comment

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

I think this output is confusing and should be removed. This command will use the new env var, but outside, nothing will change right? So it's more a performance optimization for this specific execution of oms-cli. Not sure if it's even worth doing?

fmt.Fprintf(os.Stderr, "Attempting to upgrade to the new format...\n\n")

portalClient := portal.NewPortalClient()
newApiKey, err := portalClient.GetApiKeyByHeader(apiKey)
Copy link
Member

Choose a reason for hiding this comment

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

I think it should be possible to concatenate the new API key in the client and only query the key ID from the portal, WDYT?

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.

3 participants