diff --git a/Makefile b/Makefile index 7d8e3530ae..b689348c54 100644 --- a/Makefile +++ b/Makefile @@ -74,6 +74,10 @@ package-example-single-big-bang-package: ## Create the Zarf package for single-b package-example-gitops-data: cd examples/gitops-data && ../../$(ZARF_BIN) package create --confirm && mv zarf-package-* ../../build/ +.PHONY: package-example-tiny-kafka +package-example-tiny-kafka: + cd examples/tiny-kafka && ../../$(ZARF_BIN) package create --confirm && mv zarf-package-* ../../build/ + .PHONY: test-cloud-e2e-example-game test-cloud-e2e-example-game: ## Runs the Doom game as an E2E test in the cloud. Requires access to an AWS account. Costs money. Make sure you ran the `build-cli`, `init-package`, and `package-example-game` targets first cd test/e2e && go test ./... -run TestE2eExampleGame -v -timeout 1200s @@ -97,7 +101,7 @@ test-cloud-e2e-git-based-helm-chart: ################ END Pending removal post-merge .PHONY: test-cloud-e2e-general-cli -test-cloud-e2e-general-cli: ## Runs tests of the CLI that don't need a cluster +test-cloud-e2e-general-cli: package-example-tiny-kafka ## Runs tests of the CLI that don't need a cluster cd test/e2e && go test ./... -run TestGeneralCli -v -timeout 1200s .PHONY: test-e2e diff --git a/cli/internal/packager/common.go b/cli/internal/packager/common.go index a27401a4ae..e8facc96ce 100644 --- a/cli/internal/packager/common.go +++ b/cli/internal/packager/common.go @@ -4,7 +4,6 @@ import ( "crypto/sha256" "encoding/hex" "fmt" - "github.com/defenseunicorns/zarf/cli/types" "io" "io/ioutil" "net/http" @@ -13,6 +12,8 @@ import ( "strings" "time" + "github.com/defenseunicorns/zarf/cli/types" + "github.com/goccy/go-yaml" "github.com/AlecAivazis/survey/v2" @@ -78,16 +79,18 @@ func confirmAction(configPath string, userMessage string) bool { utils.ColorPrintYAML(text) // Display prompt if not auto-confirmed + var confirmFlag bool if config.DeployOptions.Confirm { message.Infof("%s Zarf package confirmed", userMessage) + return config.DeployOptions.Confirm } else { prompt := &survey.Confirm{ Message: userMessage + " this Zarf package?", } - _ = survey.AskOne(prompt, &config.DeployOptions.Confirm) + _ = survey.AskOne(prompt, &confirmFlag) } - return config.DeployOptions.Confirm + return confirmFlag } func getValidComponents(allComponents []types.ZarfComponent, requestedComponentNames []string) []types.ZarfComponent { @@ -99,7 +102,7 @@ func getValidComponents(allComponents []types.ZarfComponent, requestedComponentN // If the component is not required check if the user wants it deployed if !confirmComponent { // Check if this is one of the components that has been requested - if len(requestedComponentNames) > 0 { + if len(requestedComponentNames) > 0 || config.DeployOptions.Confirm { for index, requestedComponent := range requestedComponentNames { if strings.ToLower(requestedComponent) == component.Name { confirmComponent = true diff --git a/test/e2e/e2e_general_cli_test.go b/test/e2e/e2e_general_cli_test.go index 54b80d209d..74afbe1316 100644 --- a/test/e2e/e2e_general_cli_test.go +++ b/test/e2e/e2e_general_cli_test.go @@ -19,6 +19,8 @@ func TestGeneralCli(t *testing.T) { // Upload the Zarf artifacts teststructure.RunTestStage(e2e.testing, "UPLOAD", func() { e2e.syncFileToRemoteServer("../../build/zarf", fmt.Sprintf("/home/%s/build/zarf", e2e.username), "0700") + e2e.syncFileToRemoteServer("../../build/zarf-init.tar.zst", fmt.Sprintf("/home/%s/build/zarf-init.tar.zst", e2e.username), "0700") + e2e.syncFileToRemoteServer("../../build/zarf-package-kafka-strimzi-demo.tar.zst", fmt.Sprintf("/home/%s/build/zarf-package-kafka-strimzi-demo.tar.zst", e2e.username), "0700") }) teststructure.RunTestStage(e2e.testing, "TEST", func() { @@ -57,6 +59,14 @@ func TestGeneralCli(t *testing.T) { output, err = e2e.runSSHCommand("cd /home/%s/build && ./zarf pki regenerate --host some_unique_server", e2e.username) require.Error(e2e.testing, err, output) + // Initialize Zarf for the next set of tests + output, err = e2e.runSSHCommand("sudo bash -c 'cd /home/%s/build && ./zarf init --confirm --components k3s'", e2e.username) + require.NoError(e2e.testing, err, output) + + // Verify that we do not timeout when passing the `--confirm` flag without specifying the `--components` flag + output, err = e2e.runSSHCommand("sudo timeout 120 sudo bash -c 'cd /home/%s/build && ./zarf package deploy zarf-package-kafka-strimzi-demo.tar.zst --confirm' || false", e2e.username) + require.NoError(e2e.testing, err, output) + // Test that `zarf package deploy` doesn't die when given a URL // NOTE: Temporarily commenting this out because this seems out of scope for a general cli test. Having this included also means we would have to fully standup a `zarf init` command. // TODO: Move this to it's own e2e test.