mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-08-16 04:06:06 +00:00
Add dynamic resource autocompletion to Velero CLI
Register cobra completion callbacks for all commands that accept existing Velero resource names. A centralized completeNames helper uses apimachinery's meta.ExtractList/Accessor to list resources with a 3-second timeout, filter by prefix, and deduplicate already-typed arguments. Wires ValidArgsFunction on 20 commands and RegisterFlagCompletionFunc on 9 flags across backup, restore, schedule, backuplocation, snapshotlocation, repo, and debug. Closes #9782 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Joseph <jvaikath@redhat.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
f73888abbd
commit
3c49bbec75
@@ -38,6 +38,7 @@ import (
|
||||
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
|
||||
"github.com/vmware-tanzu/velero/pkg/client"
|
||||
"github.com/vmware-tanzu/velero/pkg/cmd"
|
||||
"github.com/vmware-tanzu/velero/pkg/cmd/cli"
|
||||
)
|
||||
|
||||
//go:embed cshd-scripts/velero.cshd
|
||||
@@ -171,6 +172,10 @@ specs of resources created by velero server, and optionally the logs of backup a
|
||||
},
|
||||
}
|
||||
o.bindFlags(c.Flags())
|
||||
|
||||
_ = c.RegisterFlagCompletionFunc("backup", cli.CompleteBackupNames(f))
|
||||
_ = c.RegisterFlagCompletionFunc("restore", cli.CompleteRestoreNames(f))
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user