Skip to content

Commit fd2f9da

Browse files
docs(api-keys): address PR #1 review comments on language clarity
Address feedback from PR #1 review comments: 1. Fix Long description (line 19) - Remove confusing reference to 'application keys' - Clarify this command only manages API keys, not app keys 2. Clarify authentication requirements (line 42) - Update to specify OAuth2 OR 'API key + Application key' combination - Add note that you cannot delete an API key that's currently in use 3. Enhance delete command safety (line 161) - Add prominent DESTRUCTIVE OPERATION warning with visual separator - Change confirmation from 'y/Y' to require typing 'yes' exactly - Add comprehensive checklist of consequences - Update Short description to include '(DESTRUCTIVE)' label - Add detailed Long description explaining risks These changes improve clarity and safety without changing functionality. Addresses: PR #1 review comments by @ptte Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 35e4621 commit fd2f9da

1 file changed

Lines changed: 39 additions & 14 deletions

File tree

cmd/api_keys.go

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ import (
1616
var apiKeysCmd = &cobra.Command{
1717
Use: "api-keys",
1818
Short: "Manage API keys",
19-
Long: `Manage Datadog API keys and application keys.
19+
Long: `Manage Datadog API keys.
2020
21-
API keys authenticate requests to Datadog APIs. Application keys provide
22-
additional authentication for writing data.
21+
API keys authenticate requests to Datadog APIs. This command manages API keys
22+
only (not application keys).
2323
2424
CAPABILITIES:
2525
• List API keys
2626
• Get API key details
2727
• Create new API keys
28-
• Update API keys
29-
• Delete API keys
28+
• Update API keys (name only)
29+
• Delete API keys (requires confirmation)
3030
3131
EXAMPLES:
3232
# List all API keys
@@ -38,8 +38,12 @@ EXAMPLES:
3838
# Create new API key
3939
pup api-keys create --name="Production Key"
4040
41+
# Delete an API key (with confirmation prompt)
42+
pup api-keys delete key-id
43+
4144
AUTHENTICATION:
42-
Requires either OAuth2 authentication or existing API keys.`,
45+
Requires OAuth2 (via 'pup auth login') or a valid API key + Application key
46+
combination. Note: You cannot use an API key to delete itself.`,
4347
}
4448

4549
var apiKeysListCmd = &cobra.Command{
@@ -63,9 +67,20 @@ var apiKeysCreateCmd = &cobra.Command{
6367

6468
var apiKeysDeleteCmd = &cobra.Command{
6569
Use: "delete [key-id]",
66-
Short: "Delete an API key",
67-
Args: cobra.ExactArgs(1),
68-
RunE: runAPIKeysDelete,
70+
Short: "Delete an API key (DESTRUCTIVE)",
71+
Long: `Delete an API key permanently.
72+
73+
WARNING: This is a destructive operation that cannot be undone. Deleting an API
74+
key will immediately revoke access for any applications or services using it.
75+
76+
Before deleting, ensure:
77+
• No active services are using this key
78+
• You have alternative authentication configured
79+
• You cannot delete the API key currently being used for authentication
80+
81+
Use --auto-approve to skip the confirmation prompt (use with caution).`,
82+
Args: cobra.ExactArgs(1),
83+
RunE: runAPIKeysDelete,
6984
}
7085

7186
var (
@@ -168,16 +183,26 @@ func runAPIKeysDelete(cmd *cobra.Command, args []string) error {
168183

169184
keyID := args[0]
170185
if !cfg.AutoApprove {
171-
fmt.Printf("⚠️ WARNING: This will permanently delete API key %s\n", keyID)
172-
fmt.Print("Are you sure you want to continue? (y/N): ")
186+
fmt.Println("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
187+
fmt.Printf("⚠️ DESTRUCTIVE OPERATION WARNING ⚠️\n")
188+
fmt.Println("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
189+
fmt.Printf("\nYou are about to PERMANENTLY DELETE API key: %s\n", keyID)
190+
fmt.Println("\nThis action:")
191+
fmt.Println(" • Cannot be undone")
192+
fmt.Println(" • Will immediately revoke access for any services using this key")
193+
fmt.Println(" • May cause service disruptions if the key is in active use")
194+
fmt.Println("\nPlease confirm you have:")
195+
fmt.Println(" • Verified no active services depend on this key")
196+
fmt.Println(" • Documented or backed up the key information if needed")
197+
fmt.Print("\nType 'yes' to confirm deletion (or anything else to cancel): ")
173198
var response string
174199
if _, err := fmt.Scanln(&response); err != nil {
175200
// User cancelled or error reading input
176-
fmt.Println("\nOperation cancelled")
201+
fmt.Println("\n✓ Operation cancelled")
177202
return nil
178203
}
179-
if response != "y" && response != "Y" {
180-
fmt.Println("Operation cancelled")
204+
if response != "yes" {
205+
fmt.Println("Operation cancelled")
181206
return nil
182207
}
183208
}

0 commit comments

Comments
 (0)