Skip to content

Commit

Permalink
fix: use system Zarf so that init works (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
UncleGedd authored Nov 6, 2023
1 parent 5194aff commit b7d5f3a
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
4 changes: 3 additions & 1 deletion src/test/bundles/04-init/uds-bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 10 additions & 0 deletions src/test/bundles/05-gitrepo/uds-bundle.yaml
Original file line number Diff line number Diff line change
@@ -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
13 changes: 12 additions & 1 deletion src/test/e2e/bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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...)
Expand Down
10 changes: 10 additions & 0 deletions src/test/packages/gitrepo/zarf.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b7d5f3a

Please sign in to comment.