From a8fdcb67102f3916c6f75a77ddd3c7905eb0b69f Mon Sep 17 00:00:00 2001 From: Darcy Cleaver Date: Fri, 5 Apr 2024 14:12:50 -0600 Subject: [PATCH 1/2] feat: adr, beta note, packages flag, skip sbom --- adr/0004-tui.md | 2 +- adr/0005-dev-mode.md | 25 +++++++++++++++++++++++++ src/cmd/dev.go | 3 +++ src/config/lang/lang.go | 3 ++- src/pkg/bundle/dev.go | 2 +- src/test/e2e/commands_test.go | 9 ++++++++- src/test/e2e/dev_test.go | 4 ++-- 7 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 adr/0005-dev-mode.md diff --git a/adr/0004-tui.md b/adr/0004-tui.md index cdf3502b..9bf57947 100644 --- a/adr/0004-tui.md +++ b/adr/0004-tui.md @@ -1,4 +1,4 @@ -# 3. Terminal User Interface (TUI) +# 4. Terminal User Interface (TUI) Date: 22 March 2024 diff --git a/adr/0005-dev-mode.md b/adr/0005-dev-mode.md new file mode 100644 index 00000000..173c556d --- /dev/null +++ b/adr/0005-dev-mode.md @@ -0,0 +1,25 @@ +# 5. Dev Mode + +Date: 05 April 2024 + +## Status +In Progress + +## Context + +Zarf currently has a dev command that helps speed up the zarf package development cycle, we want to provide similar capabilities to help speed up the UDS bundle development cycle. + +The current bundle development lifecycle is: + +1. Create a local zarf package or reference a remote zarf package +2. Create a `bundle.yaml` and add packages +3. Create a bundle with `uds create ` +4. Start up a cluster if one does not already exist +5. Run `uds zarf init` to initialize th cluster +6. Deploy the bundle with `uds deploy BUNDLE_TARBALL|OCI_REF]` + +## Decision + Introduce `uds dev deploy` which allows you to deploy a UDS bundle in dev mode. If a local zarf package is missing, this command will create that zarf package for you assuming that your `zarf.yaml` file and zarf package are expected in the same directory. It will then create your bundle and deploy your zarf packages in [YOLO](https://docs.zarf.dev/docs/faq#what-is-yolo-mode-and-why-would-i-use-it) mode, eliminating the need to do a `uds zarf init` + +## Consequences +Commands under `dev` are meant to be used in **development** environments, and are **not** meant to be used in **production** environments. There is still the possibility that a user will use `uds dev deploy` in a production environment, but the command name and documentation will make it clear that this is not the intended use case. diff --git a/src/cmd/dev.go b/src/cmd/dev.go index 232c4eb1..765cd701 100644 --- a/src/cmd/dev.go +++ b/src/cmd/dev.go @@ -24,6 +24,7 @@ var devDeployCmd = &cobra.Command{ Use: "deploy", Args: cobra.MaximumNArgs(1), Short: lang.CmdDevDeployShort, + Long: lang.CmdDevDeployLong, PreRun: func(_ *cobra.Command, args []string) { setBundleFile(args) }, @@ -44,6 +45,7 @@ var devDeployCmd = &cobra.Command{ config.CommonOptions.Confirm = true bundleCfg.CreateOpts.SourceDirectory = srcDir + configureZarf() // load uds-config if it exists @@ -78,4 +80,5 @@ func init() { initViper() rootCmd.AddCommand(devCmd) devCmd.AddCommand(devDeployCmd) + devDeployCmd.Flags().StringArrayVarP(&bundleCfg.DeployOpts.Packages, "packages", "p", []string{}, lang.CmdBundleDeployFlagPackages) } diff --git a/src/config/lang/lang.go b/src/config/lang/lang.go index 42eb1786..7d132bc3 100644 --- a/src/config/lang/lang.go +++ b/src/config/lang/lang.go @@ -83,5 +83,6 @@ const ( // uds dev CmdDevShort = "Commands useful for developing bundles" - CmdDevDeployShort = "Creates and deploys a dev UDS bundle from a given directory" + CmdDevDeployShort = "[beta] Creates and deploys a UDS bundle from a given directory in dev mode" + CmdDevDeployLong = "[beta] Creates and deploys a UDS bundle from a given directory in dev mode, setting package options like YOLO mode for faster iteration." ) diff --git a/src/pkg/bundle/dev.go b/src/pkg/bundle/dev.go index a93f35ee..69625414 100644 --- a/src/pkg/bundle/dev.go +++ b/src/pkg/bundle/dev.go @@ -47,7 +47,7 @@ func (b *Bundle) CreateZarfPkgs() { } // create local zarf package if it doesn't exist if !packageFound { - os.Args = []string{"zarf", "package", "create", path, "--confirm", "-o", path} + os.Args = []string{"zarf", "package", "create", path, "--confirm", "-o", path, "--skip-sbom"} zarfCLI.Execute() if err != nil { message.Fatalf(err, "Failed to create package %s: %s", pkg.Name, err.Error()) diff --git a/src/test/e2e/commands_test.go b/src/test/e2e/commands_test.go index 4a0984ef..896aeb4c 100644 --- a/src/test/e2e/commands_test.go +++ b/src/test/e2e/commands_test.go @@ -120,7 +120,14 @@ func deployWithTUI(t *testing.T, source string) (stdout string, stderr string) { } func devDeploy(t *testing.T, tarballPath string) (stdout string, stderr string) { - cmd := strings.Split(fmt.Sprintf("dev deploy %s --no-tea", tarballPath), " ") + cmd := strings.Split(fmt.Sprintf("dev deploy %s", tarballPath), " ") + stdout, stderr, err := e2e.UDS(cmd...) + require.NoError(t, err) + return stdout, stderr +} + +func devDeployPackages(t *testing.T, tarballPath string, packages string) (stdout string, stderr string) { + cmd := strings.Split(fmt.Sprintf("dev deploy %s --packages %s", tarballPath, packages), " ") stdout, stderr, err := e2e.UDS(cmd...) require.NoError(t, err) return stdout, stderr diff --git a/src/test/e2e/dev_test.go b/src/test/e2e/dev_test.go index f2b39fc4..c01fe8dd 100644 --- a/src/test/e2e/dev_test.go +++ b/src/test/e2e/dev_test.go @@ -41,11 +41,11 @@ func TestDevDeploy(t *testing.T) { bundleDir := "src/test/bundles/03-local-and-remote" bundlePath := filepath.Join(bundleDir, fmt.Sprintf("uds-bundle-test-local-and-remote-%s-0.0.1.tar.zst", e2e.Arch)) - devDeploy(t, bundleDir) + devDeployPackages(t, bundleDir, "podinfo") deployments, _, _ := e2e.UDS(cmd...) require.Contains(t, deployments, "podinfo") - require.Contains(t, deployments, "nginx") + require.NotContains(t, deployments, "nginx") remove(t, bundlePath) }) From 8aeb488c469ea83db1324b77cf776578a833c007 Mon Sep 17 00:00:00 2001 From: Darcy Cleaver Date: Mon, 8 Apr 2024 11:43:27 -0600 Subject: [PATCH 2/2] remove adr from pr --- adr/0005-dev-mode.md | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100644 adr/0005-dev-mode.md diff --git a/adr/0005-dev-mode.md b/adr/0005-dev-mode.md deleted file mode 100644 index 173c556d..00000000 --- a/adr/0005-dev-mode.md +++ /dev/null @@ -1,25 +0,0 @@ -# 5. Dev Mode - -Date: 05 April 2024 - -## Status -In Progress - -## Context - -Zarf currently has a dev command that helps speed up the zarf package development cycle, we want to provide similar capabilities to help speed up the UDS bundle development cycle. - -The current bundle development lifecycle is: - -1. Create a local zarf package or reference a remote zarf package -2. Create a `bundle.yaml` and add packages -3. Create a bundle with `uds create ` -4. Start up a cluster if one does not already exist -5. Run `uds zarf init` to initialize th cluster -6. Deploy the bundle with `uds deploy BUNDLE_TARBALL|OCI_REF]` - -## Decision - Introduce `uds dev deploy` which allows you to deploy a UDS bundle in dev mode. If a local zarf package is missing, this command will create that zarf package for you assuming that your `zarf.yaml` file and zarf package are expected in the same directory. It will then create your bundle and deploy your zarf packages in [YOLO](https://docs.zarf.dev/docs/faq#what-is-yolo-mode-and-why-would-i-use-it) mode, eliminating the need to do a `uds zarf init` - -## Consequences -Commands under `dev` are meant to be used in **development** environments, and are **not** meant to be used in **production** environments. There is still the possibility that a user will use `uds dev deploy` in a production environment, but the command name and documentation will make it clear that this is not the intended use case.