diff --git a/src/cmd/uds.go b/src/cmd/uds.go index 68dd49815..4357284fa 100644 --- a/src/cmd/uds.go +++ b/src/cmd/uds.go @@ -294,6 +294,7 @@ func init() { deployCmd.Flags().BoolVarP(&config.CommonOptions.Confirm, "confirm", "c", false, lang.CmdBundleDeployFlagConfirm) deployCmd.Flags().StringArrayVarP(&bundleCfg.DeployOpts.Packages, "packages", "p", []string{}, lang.CmdBundleDeployFlagPackages) deployCmd.Flags().BoolVarP(&bundleCfg.DeployOpts.Resume, "resume", "r", false, lang.CmdBundleDeployFlagResume) + deployCmd.Flags().IntVar(&bundleCfg.DeployOpts.Retries, "retries", 1, lang.CmdBundleDeployFlagRetries) // inspect cmd flags rootCmd.AddCommand(inspectCmd) diff --git a/src/config/lang/lang.go b/src/config/lang/lang.go index ef06a452c..03e17d4f9 100644 --- a/src/config/lang/lang.go +++ b/src/config/lang/lang.go @@ -37,6 +37,7 @@ const ( CmdBundleDeployFlagPackages = "Specify which zarf packages you would like to deploy from the bundle. By default all zarf packages in the bundle are deployed." CmdBundleDeployFlagResume = "Only deploys packages from the bundle which haven't already been deployed" CmdBundleDeployFlagSet = "Specify deployment variables to set on the command line (KEY=value)" + CmdBundleDeployFlagRetries = "Specify the number of retries for package deployments (applies to all pkgs in a bundle)" // bundle inspect CmdBundleInspectShort = "Display the metadata of a bundle" diff --git a/src/pkg/bundle/deploy.go b/src/pkg/bundle/deploy.go index 006b7dd18..64187b5af 100644 --- a/src/pkg/bundle/deploy.go +++ b/src/pkg/bundle/deploy.go @@ -106,7 +106,7 @@ func deployPackages(packages []types.Package, resume bool, b *Bundle) error { OptionalComponents: strings.Join(pkg.OptionalComponents, ","), PublicKeyPath: publicKeyPath, SetVariables: pkgVars, - Retries: 1, + Retries: b.cfg.DeployOpts.Retries, } valuesOverrides, err := b.loadChartOverrides(pkg, pkgVars) diff --git a/src/test/e2e/bundle_test.go b/src/test/e2e/bundle_test.go index aa6bf7c45..1a1bde238 100644 --- a/src/test/e2e/bundle_test.go +++ b/src/test/e2e/bundle_test.go @@ -151,7 +151,7 @@ func TestPackagesFlag(t *testing.T) { cmd := strings.Split("zarf tools kubectl get deployments -A -o=jsonpath='{.items[*].metadata.name}'", " ") t.Run("Test only podinfo deploy (local pkg)", func(t *testing.T) { - deployPackagesFlag(bundlePath, "podinfo") + deployPackagesFlag(t, bundlePath, "podinfo") deployments, _, _ := e2e.UDS(cmd...) require.Contains(t, deployments, "podinfo") require.NotContains(t, deployments, "nginx") @@ -162,7 +162,7 @@ func TestPackagesFlag(t *testing.T) { }) t.Run("Test only nginx deploy and remove (remote pkg)", func(t *testing.T) { - deployPackagesFlag(bundlePath, "nginx") + deployPackagesFlag(t, bundlePath, "nginx") deployments, _, _ := e2e.UDS(cmd...) require.Contains(t, deployments, "nginx") require.NotContains(t, deployments, "podinfo") @@ -174,7 +174,7 @@ func TestPackagesFlag(t *testing.T) { }) t.Run("Test both podinfo and nginx deploy and remove", func(t *testing.T) { - deployPackagesFlag(bundlePath, "podinfo,nginx") + deployPackagesFlag(t, bundlePath, "podinfo,nginx") deployments, _, _ := e2e.UDS(cmd...) require.Contains(t, deployments, "podinfo") require.Contains(t, deployments, "nginx") @@ -186,7 +186,7 @@ func TestPackagesFlag(t *testing.T) { }) t.Run("Test invalid package deploy", func(t *testing.T) { - _, stderr := deployPackagesFlag(bundlePath, "podinfo,nginx,peanuts") + _, stderr := deployPackagesFlag(t, bundlePath, "podinfo,nginx,peanuts") require.Contains(t, stderr, "invalid zarf packages specified by --packages") }) @@ -209,7 +209,7 @@ func TestResumeFlag(t *testing.T) { getDeploymentsCmd := strings.Split("zarf tools kubectl get deployments -A -o=jsonpath='{.items[*].metadata.name}'", " ") // Deploy only podinfo (local pkg) - deployPackagesFlag(bundlePath, "podinfo") + deployPackagesFlag(t, bundlePath, "podinfo") deployments, _, _ := e2e.UDS(getDeploymentsCmd...) require.Contains(t, deployments, "podinfo") require.NotContains(t, deployments, "nginx") @@ -227,7 +227,7 @@ func TestResumeFlag(t *testing.T) { require.Contains(t, deployments, "nginx") // Deploy only nginx (remote pkg) - deployPackagesFlag(bundlePath, "nginx") + deployPackagesFlag(t, bundlePath, "nginx") deployments, _, _ = e2e.UDS(getDeploymentsCmd...) require.Contains(t, deployments, "nginx") require.NotContains(t, deployments, "podinfo") diff --git a/src/test/e2e/commands_test.go b/src/test/e2e/commands_test.go index c5209da3d..4dc244fe9 100644 --- a/src/test/e2e/commands_test.go +++ b/src/test/e2e/commands_test.go @@ -119,9 +119,10 @@ func runCmd(t *testing.T, input string) (stdout string, stderr string) { return stdout, stderr } -func deployPackagesFlag(tarballPath string, packages string) (stdout string, stderr string) { +func deployPackagesFlag(t *testing.T, tarballPath string, packages string) (stdout string, stderr string) { cmd := strings.Split(fmt.Sprintf("deploy %s --confirm -l=debug --packages %s --no-tea", tarballPath, packages), " ") - stdout, stderr, _ = e2e.UDS(cmd...) + stdout, stderr, err := e2e.UDS(cmd...) + require.NoError(t, err) return stdout, stderr } diff --git a/src/types/options.go b/src/types/options.go index e8c6d2563..1b2f41f40 100644 --- a/src/types/options.go +++ b/src/types/options.go @@ -34,6 +34,7 @@ type BundleDeployOptions struct { Variables map[string]map[string]interface{} `yaml:"variables,omitempty"` SharedVariables map[string]interface{} `yaml:"shared,omitempty"` ZarfPackageNameMap map[string]string `yaml:"-" json:"-"` + Retries int `yaml:"retries"` } // BundleInspectOptions is the options for the bundler.Inspect() function