Skip to content

fix(completion): complete parent-ID slots for database and storage sub-resources - #241

Merged
aru-amedeo merged 2 commits into
mainfrom
fix/completion-database-storage-resources
Jun 19, 2026
Merged

fix(completion): complete parent-ID slots for database and storage sub-resources#241
aru-amedeo merged 2 commits into
mainfrom
fix/completion-database-storage-resources

Conversation

@aru-amedeo

Copy link
Copy Markdown
Member

Summary

Extends the parent-slot completion fix from #240 to the database and storage families.

  • database dbaas database: completeDBaaSDatabaseID returned nil for args[0] (dbaas-id slot) ? now delegates to completeDBaaSID. Registered on create and list, which had no ValidArgsFunction.
  • database dbaas user: same fix ? completeDBaaSUserID now delegates at args[0]. Registered on create and list.
  • database dbaas grant: completeGrantID suppressed all completions below args[2] ? now chains DBaaS ? Database ? Grant IDs per slot. Registered on all four grant commands (create, list, get, delete), none of which had any ValidArgsFunction.
  • storage backup create: storageBackupCmd (the create command) takes [volume-id] as args[0] but had no completion; registered completeBlockStorageID.
  • storage restore create: new completeStorageRestoreCreateArgs ? completes backup IDs at args[0], block storage (volume) IDs at args[1]. Registered on storageRestoreCmd.

Security family: no changes ? key and kmip resolve their KMS parent via --kms-id flag (already read in completeKeyID/completeKmipID), and all create/list commands in that family take no positional args.

Slot completion after this fix

TAB position Command example Completes
args[0] database dbaas database list <TAB> DBaaS IDs
args[1] database dbaas database get <dbaas-id> <TAB> Database names (scoped to DBaaS)
args[0] database dbaas user list <TAB> DBaaS IDs
args[1] database dbaas user get <dbaas-id> <TAB> Usernames (scoped to DBaaS)
args[0] database dbaas grant list <TAB> DBaaS IDs
args[1] database dbaas grant list <dbaas-id> <TAB> Database names (scoped to DBaaS)
args[2] database dbaas grant get <dbaas-id> <db> <TAB> Grant IDs
args[0] storage backup <TAB> Volume IDs
args[0] storage restore <TAB> Backup IDs
args[1] storage restore <backup-id> <TAB> Volume IDs

Test plan

  • acloud database dbaas database list <TAB> ? DBaaS IDs (was: nothing)
  • acloud database dbaas database get <dbaas-id> <TAB> ? database names (was: nothing)
  • acloud database dbaas user list <TAB> ? DBaaS IDs (was: nothing)
  • acloud database dbaas grant list <TAB> ? DBaaS IDs (was: nothing)
  • acloud database dbaas grant list <dbaas-id> <TAB> ? database names (was: nothing)
  • acloud database dbaas grant get <dbaas-id> <db> <TAB> ? grant IDs (was: nothing, no registration)
  • acloud storage backup <TAB> ? volume IDs (was: filesystem)
  • acloud storage restore <TAB> ? backup IDs (was: filesystem)
  • acloud storage restore <backup-id> <TAB> ? volume IDs (was: nothing)
  • Existing completions unaffected: dbaas get <TAB> ? DBaaS IDs, storage restore get <backup-id> <TAB> ? restore IDs
  • make test-skip-client passes

?? Generated with Claude Code

…ub-resources

Database family:
- completeDBaaSDatabaseID: was returning nil for args[0] (dbaas-id slot);
  now delegates to completeDBaaSID. Registered on database create and list,
  which had no ValidArgsFunction.
- completeDBaaSUserID: same fix. Registered on user create and list.
- completeGrantID: was returning nil for args[0] and args[1]; now delegates
  to completeDBaaSID ? completeDBaaSDatabaseID in order. Registered on all
  four grant commands (create, list, get, delete), none of which had
  ValidArgsFunction.

Storage family:
- storage backup create (storageBackupCmd): the positional [volume-id] arg
  had no completion; registered completeBlockStorageID.
- storage restore create (storageRestoreCmd): [backup-id] [volume-id] args
  had no completion; added completeStorageRestoreCreateArgs which completes
  backup IDs at args[0] and block storage (volume) IDs at args[1].

Security family: no changes needed ? key and kmip resolve their KMS parent
via --kms-id flag (already read in completeKeyID/completeKmipID), and all
create/list commands in that family take no positional args.

Tests: added coverage for all new delegation paths and too-many-args guards
in completion_test.go.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.20%. Comparing base (209d563) to head (8e64164).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #241      +/-   ##
==========================================
+ Coverage   78.14%   78.20%   +0.05%     
==========================================
  Files          53       53              
  Lines       12569    12593      +24     
==========================================
+ Hits         9822     9848      +26     
+ Misses       1576     1575       -1     
+ Partials     1171     1170       -1     
Flag Coverage Δ
unittests 78.20% <100.00%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…resources

Network resources (from #240):
- subnet.md, securitygroup.md, vpcpeering.md: expand bare stubs into
  full examples showing parent-slot completion at args[0] and child-slot
  completion at args[1].
- securityrule.md, vpcpeeringroute.md: extend existing completion sections
  to show all three positional slots (were showing only the final slot).

Database resources (from #241):
- dbaas.database.md: add Shell Auto-completion section (dbaas-id ? database-name).
- dbaas.user.md: add Shell Auto-completion section (dbaas-id ? username).
- dbaas.grant.md: add Shell Auto-completion section (dbaas-id ? database-name ? grant-id).

Storage resources (from #241):
- backup.md: mark volume-id argument as supporting auto-completion.
- restore.md: document create-command hierarchical completion (backup-id
  then volume-id), in addition to the existing get/list/delete section.

getting-started.md:
- Expand Storage section to cover backup create and restore create completion.
- Add Database section showing sub-resource hierarchical completion examples.
- Update closing note to mention create and list commands now also complete.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@aru-amedeo
aru-amedeo merged commit d2275c4 into main Jun 19, 2026
12 checks passed
aru-amedeo pushed a commit that referenced this pull request Jun 19, 2026
Covers all changes since v0.5.1:
- feat: context auto-selection (#234)
- feat: clear-contexts prompt on profile switch (#236)
- fix: shell completion parent-ID slots for network sub-resources (#239/#240)
- fix: shell completion parent-ID slots for database/storage sub-resources (#241)
- fix: zone value in docs examples (#238)
- docs: English and Italian completion section updates

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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