From b7d5f3a5d67a4cec23dcb5f98f343f4b6356e1ab Mon Sep 17 00:00:00 2001 From: UncleGedd <42304551+UncleGedd@users.noreply.github.com> Date: Mon, 6 Nov 2023 10:05:00 -0600 Subject: [PATCH] fix: use system Zarf so that init works (#166) --- src/cmd/root.go | 3 +++ src/test/bundles/04-init/uds-bundle.yaml | 4 +++- src/test/bundles/05-gitrepo/uds-bundle.yaml | 10 ++++++++++ src/test/e2e/bundle_test.go | 13 ++++++++++++- src/test/packages/gitrepo/zarf.yaml | 10 ++++++++++ 5 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 src/test/bundles/05-gitrepo/uds-bundle.yaml create mode 100644 src/test/packages/gitrepo/zarf.yaml diff --git a/src/cmd/root.go b/src/cmd/root.go index 5656ecd0..348220b5 100644 --- a/src/cmd/root.go +++ b/src/cmd/root.go @@ -93,6 +93,9 @@ func init() { rootCmd.PersistentFlags().StringVar(&config.CommonOptions.CachePath, "zarf-cache", v.GetString(V_ZARF_CACHE), lang.RootCmdFlagCachePath) rootCmd.PersistentFlags().StringVar(&config.CommonOptions.TempDirectory, "tmpdir", v.GetString(V_TMP_DIR), lang.RootCmdFlagTempDir) rootCmd.PersistentFlags().BoolVar(&config.CommonOptions.Insecure, "insecure", v.GetBool(V_INSECURE), lang.RootCmdFlagInsecure) + + // use system Zarf because of internal commands being using during zarf init (such as creating gitea users) + zarfConfig.ActionsUseSystemZarf = true } func cliSetup() { diff --git a/src/test/bundles/04-init/uds-bundle.yaml b/src/test/bundles/04-init/uds-bundle.yaml index c290c2ff..8f82a420 100644 --- a/src/test/bundles/04-init/uds-bundle.yaml +++ b/src/test/bundles/04-init/uds-bundle.yaml @@ -12,6 +12,8 @@ zarf-packages: ref: v0.31.0 optional-components: - git-server - - name: init-adf + - name: init repository: ghcr.io/defenseunicorns/packages/init ref: v0.31.0 + optional-components: + - git-server diff --git a/src/test/bundles/05-gitrepo/uds-bundle.yaml b/src/test/bundles/05-gitrepo/uds-bundle.yaml new file mode 100644 index 00000000..a588b3ac --- /dev/null +++ b/src/test/bundles/05-gitrepo/uds-bundle.yaml @@ -0,0 +1,10 @@ +kind: UDSBundle +metadata: + name: gitrepo + description: tests that the gitrepo from Zarf init works as expected + version: 0.0.1 + +zarf-packages: + - name: gitrepo + path: "../../packages/gitrepo" + ref: 0.0.1 diff --git a/src/test/e2e/bundle_test.go b/src/test/e2e/bundle_test.go index 2018f6df..09d230bc 100644 --- a/src/test/e2e/bundle_test.go +++ b/src/test/e2e/bundle_test.go @@ -52,7 +52,7 @@ func TestCreateWithNoPath(t *testing.T) { defer os.Remove(fmt.Sprintf("uds-bundle-simple-vars-%s-0.0.1.tar.zst", e2e.Arch)) // create - cmd := strings.Split(fmt.Sprintf("bundle create --confirm --insecure"), " ") + cmd := strings.Split(fmt.Sprintf("create --confirm --insecure"), " ") _, _, err = e2e.UDS(cmd...) require.NoError(t, err) } @@ -168,6 +168,17 @@ func TestRemoteBundle(t *testing.T) { deployAndRemoveRemote(t, bundleRef.String(), tarballPath) } +func TestBundleWithGitRepo(t *testing.T) { + deployZarfInit(t) + e2e.CreateZarfPkg(t, "src/test/packages/gitrepo") + bundleDir := "src/test/bundles/05-gitrepo" + bundlePath := filepath.Join(bundleDir, fmt.Sprintf("uds-bundle-gitrepo-%s-0.0.1.tar.zst", e2e.Arch)) + + create(t, bundleDir) + deploy(t, bundlePath) + remove(t, bundlePath) +} + func create(t *testing.T, bundlePath string) { cmd := strings.Split(fmt.Sprintf("create %s --confirm --insecure", bundlePath), " ") _, _, err := e2e.UDS(cmd...) diff --git a/src/test/packages/gitrepo/zarf.yaml b/src/test/packages/gitrepo/zarf.yaml new file mode 100644 index 00000000..1a06bc39 --- /dev/null +++ b/src/test/packages/gitrepo/zarf.yaml @@ -0,0 +1,10 @@ +kind: ZarfPackageConfig +metadata: + name: gitrepo + version: 0.0.1 + +components: + - name: dubbd-repo + required: true + repos: + - https://github.com/defenseunicorns/uds-package-dubbd \ No newline at end of file