Skip to content

Commit

Permalink
feat: adds retries flag
Browse files Browse the repository at this point in the history
  • Loading branch information
UncleGedd committed Mar 28, 2024
1 parent 0d030d4 commit ca43a6e
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/cmd/uds.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/config/lang/lang.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/bundle/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions src/test/e2e/bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand All @@ -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")
Expand All @@ -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")
})

Expand All @@ -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")
Expand All @@ -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")
Expand Down
5 changes: 3 additions & 2 deletions src/test/e2e/commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
1 change: 1 addition & 0 deletions src/types/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ca43a6e

Please sign in to comment.