install: clarify --wait flag behavior, default false

Keep the existing opt-in behavior (consistent with velero backup create and velero restore create, where waiting is disabled by default and enabled with --wait), and clarify it in the command help text. Add tests pinning the --wait default (false) and flag parsing.

Signed-off-by: Mustafa Senoglu <mmustafasenoglu0@gmail.com>
This commit is contained in:
Mustafa Senoglu
2026-09-15 11:14:29 +03:00
parent 193cfdc58f
commit c1d6ff9c1d
3 changed files with 64 additions and 0 deletions
@@ -0,0 +1 @@
Add --wait flag to velero install to wait for Velero deployment to be ready
+1
View File
@@ -372,6 +372,7 @@ All namespaced resources will be placed in the 'velero' namespace by default.
The '--namespace' flag can be used to specify a different namespace to install into.
By default, the command returns immediately after creating resources.
Use '--wait' to wait for the Velero Deployment to be ready before proceeding.
Use '-o yaml' or '-o json' with '--dry-run' to output all generated resources as text instead of sending the resources to the server.
+62
View File
@@ -263,3 +263,65 @@ func TestNewCommandRunClosureOrder(t *testing.T) {
// looks up the ConfigMap in targetNS (succeeds), Run returns early via DryRun.
require.NoError(t, c.Execute())
}
// TestWaitDefaultsToFalse verifies that --wait defaults to false,
// consistent with velero backup create and velero restore create.
func TestWaitDefaultsToFalse(t *testing.T) {
o := NewInstallOptions()
assert.False(t, o.Wait, "--wait should default to false")
}
func TestWaitFlag(t *testing.T) {
tests := []struct {
name string
args []string
expectedWait bool
}{
{
name: "default: wait is false",
args: []string{},
expectedWait: false,
},
{
name: "--wait enables wait",
args: []string{"--wait"},
expectedWait: true,
},
{
name: "--wait=false disables wait",
args: []string{"--wait=false"},
expectedWait: false,
},
{
name: "--wait=true enables wait",
args: []string{"--wait=true"},
expectedWait: true,
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
o := NewInstallOptions()
o.NoDefaultBackupLocation = true
o.UseVolumeSnapshots = false
o.NoSecret = true
flags := pflag.NewFlagSet("test", pflag.ContinueOnError)
o.BindFlags(flags)
err := flags.Parse(tc.args)
require.NoError(t, err)
c := makeValidateCmd()
c.SetContext(context.Background())
f := &factorymocks.Factory{}
f.On("Namespace").Return("velero")
f.On("KubebuilderClient").Return(velerotest.NewFakeControllerRuntimeClient(t), nil)
require.NoError(t, o.Complete([]string{}, f))
err = o.Validate(c, []string{}, f)
require.NoError(t, err)
assert.Equal(t, tc.expectedWait, o.Wait)
})
}
}