@@ -17,12 +17,22 @@ import (
1717 kbclient "sigs.k8s.io/controller-runtime/pkg/client"
1818)
1919
20+ const (
21+ // defaultDescribeTimeout is the default timeout for fetching backup details
22+ defaultDescribeTimeout = 5 * time .Minute
23+ )
24+
2025func NewDescribeCommand (f client.Factory , use string ) * cobra.Command {
2126 c := & cobra.Command {
2227 Use : use + " NAME" ,
2328 Short : "Describe a non-admin backup" ,
2429 Args : cobra .ExactArgs (1 ),
2530 RunE : func (cmd * cobra.Command , args []string ) error {
31+ timeout , err := cmd .Flags ().GetDuration ("timeout" )
32+ if err != nil {
33+ return fmt .Errorf ("failed to get timeout flag: %w" , err )
34+ }
35+
2636 backupName := args [0 ]
2737
2838 // Get the current namespace from kubectl context
@@ -51,21 +61,23 @@ func NewDescribeCommand(f client.Factory, use string) *cobra.Command {
5161 }
5262
5363 // Print in Velero-style format
54- printNonAdminBackupDetails (cmd , & nab )
64+ printNonAdminBackupDetails (cmd , & nab , kbClient , userNamespace , timeout )
5565
5666 return nil
5767 },
5868 Example : ` kubectl oadp nonadmin backup describe my-backup` ,
5969 }
6070
71+ c .Flags ().Duration ("timeout" , defaultDescribeTimeout , "Maximum time to wait for backup details to be available" )
72+
6173 output .BindFlags (c .Flags ())
6274 output .ClearOutputFlagDefault (c )
6375
6476 return c
6577}
6678
6779// printNonAdminBackupDetails prints backup details in Velero admin describe format
68- func printNonAdminBackupDetails (cmd * cobra.Command , nab * nacv1alpha1.NonAdminBackup ) {
80+ func printNonAdminBackupDetails (cmd * cobra.Command , nab * nacv1alpha1.NonAdminBackup , kbClient kbclient. Client , userNamespace string , timeout time. Duration ) {
6981 out := cmd .OutOrStdout ()
7082
7183 // Get Velero backup reference if available
@@ -350,8 +362,8 @@ func colorizePhase(phase string) string {
350362
351363// NonAdminDescribeBackup mirrors Velero's output.DescribeBackup functionality
352364// but works within non-admin RBAC boundaries using NonAdminDownloadRequest
353- func NonAdminDescribeBackup (cmd * cobra.Command , kbClient kbclient.Client , nab * nacv1alpha1.NonAdminBackup , userNamespace string ) error {
354- ctx , cancel := context .WithTimeout (context .Background (), 120 * time . Second )
365+ func NonAdminDescribeBackup (cmd * cobra.Command , kbClient kbclient.Client , nab * nacv1alpha1.NonAdminBackup , userNamespace string , timeout time. Duration ) error {
366+ ctx , cancel := context .WithTimeout (context .Background (), timeout )
355367 defer cancel ()
356368
357369 // Print basic backup information
0 commit comments