Skip to content

Commit

Permalink
adds architecture flag and renames test dirs (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
UncleGedd authored Oct 25, 2023
1 parent 41acc64 commit 4d61aec
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 25 deletions.
1 change: 1 addition & 0 deletions src/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ func init() {
v.SetDefault(V_TMP_DIR, "")

rootCmd.PersistentFlags().StringVarP(&logLevel, "log-level", "l", v.GetString(V_LOG_LEVEL), lang.RootCmdFlagLogLevel)
rootCmd.PersistentFlags().StringVarP(&config.CLIArch, "architecture", "a", v.GetString(common.VArchitecture), lang.RootCmdFlagArch)
rootCmd.PersistentFlags().BoolVar(&config.SkipLogFile, "no-log-file", v.GetBool(V_NO_LOG_FILE), lang.RootCmdFlagSkipLogFile)
rootCmd.PersistentFlags().BoolVar(&message.NoProgress, "no-progress", v.GetBool(V_NO_PROGRESS), lang.RootCmdFlagNoProgress)
rootCmd.PersistentFlags().StringVar(&config.CommonOptions.CachePath, "zarf-cache", v.GetString(V_ZARF_CACHE), lang.RootCmdFlagCachePath)
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 @@ -14,6 +14,7 @@ const (
RootCmdFlagInsecure = "Allow access to insecure registries and disable other recommended security enforcements such as package checksum and signature validation. This flag should only be used if you have a specific reason and accept the reduced security posture."
RootCmdFlagLogLevel = "Log level when running UDS-CLI. Valid options are: warn, info, debug, trace"
RootCmdErrInvalidLogLevel = "Invalid log level. Valid options are: warn, info, debug, trace."
RootCmdFlagArch = "Architecture for UDS bundles and Zarf packages"

// bundle
CmdBundleShort = "Commands for creating, deploying, removing, pulling, and inspecting bundles"
Expand Down
4 changes: 1 addition & 3 deletions src/pkg/bundle/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,6 @@ func validateBundleVars(packages []types.BundleZarfPackage) error {
}

// CalculateBuildInfo calculates the build info for the bundle
//
// this is mainly mirrored from packager.writeYaml()
func (b *Bundler) CalculateBuildInfo() error {
now := time.Now()
b.bundle.Build.User = os.Getenv("USER")
Expand All @@ -240,7 +238,7 @@ func (b *Bundler) CalculateBuildInfo() error {
}
b.bundle.Build.Terminal = hostname

// --architecture flag > metadata.arch > build.arch / runtime.GOARCH (default)
// --architecture flag > metadata.arch > build.arch > runtime.GOARCH (default)
b.bundle.Build.Architecture = config.GetArch(b.bundle.Metadata.Architecture, b.bundle.Build.Architecture)
b.bundle.Metadata.Architecture = b.bundle.Build.Architecture

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ zarf-packages:
optional-components:
- git-server
- name: podinfo
path: "../zarf/podinfo"
path: "../../packages/podinfo"
ref: 0.0.1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:

zarf-packages:
- name: init
path: "../zarf"
path: "../../packages"
ref: v0.30.1
optional-components:
- git-server
2 changes: 1 addition & 1 deletion src/test/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (e2e *UDSE2ETest) GetUdsVersion(t *testing.T) string {
func (e2e *UDSE2ETest) DownloadZarfInitPkg(t *testing.T, zarfVersion string) {
filename := fmt.Sprintf("zarf-init-%s-%s.tar.zst", e2e.Arch, zarfVersion)
zarfReleaseURL := fmt.Sprintf("https://github.com/defenseunicorns/zarf/releases/download/%s/%s", zarfVersion, filename)
outputDir := "src/test/packages/zarf"
outputDir := "src/test/packages"

// Check if the file already exists
if _, err := os.Stat(outputDir + "/" + filename); err == nil {
Expand Down
38 changes: 19 additions & 19 deletions src/test/e2e/bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ func zarfPublish(t *testing.T, path string, reg string) {
const zarfVersion = "v0.30.1"

func TestCreateWithNoPath(t *testing.T) {
zarfPkgPath1 := "src/test/packages/zarf/no-cluster/output-var"
zarfPkgPath2 := "src/test/packages/zarf/no-cluster/receive-var"
zarfPkgPath1 := "src/test/packages/no-cluster/output-var"
zarfPkgPath2 := "src/test/packages/no-cluster/receive-var"
e2e.CreateZarfPkg(t, zarfPkgPath1)
e2e.CreateZarfPkg(t, zarfPkgPath2)

Expand All @@ -48,7 +48,7 @@ func TestCreateWithNoPath(t *testing.T) {
pkg = filepath.Join(zarfPkgPath2, fmt.Sprintf("zarf-package-receive-var-%s-0.0.1.tar.zst", e2e.Arch))
zarfPublish(t, pkg, "localhost:888")

err := os.Link(fmt.Sprintf("src/test/packages/02-simple-vars/%s", config.BundleYAML), config.BundleYAML)
err := os.Link(fmt.Sprintf("src/test/bundles/02-simple-vars/%s", config.BundleYAML), config.BundleYAML)
require.NoError(t, err)
defer os.Remove(config.BundleYAML)
defer os.Remove(fmt.Sprintf("uds-bundle-simple-vars-%s-0.0.1.tar.zst", e2e.Arch))
Expand All @@ -60,8 +60,8 @@ func TestCreateWithNoPath(t *testing.T) {
}

func TestBundleVariables(t *testing.T) {
zarfPkgPath1 := "src/test/packages/zarf/no-cluster/output-var"
zarfPkgPath2 := "src/test/packages/zarf/no-cluster/receive-var"
zarfPkgPath1 := "src/test/packages/no-cluster/output-var"
zarfPkgPath2 := "src/test/packages/no-cluster/receive-var"
e2e.CreateZarfPkg(t, zarfPkgPath1)
e2e.CreateZarfPkg(t, zarfPkgPath2)

Expand All @@ -74,10 +74,10 @@ func TestBundleVariables(t *testing.T) {
pkg = filepath.Join(zarfPkgPath2, fmt.Sprintf("zarf-package-receive-var-%s-0.0.1.tar.zst", e2e.Arch))
zarfPublish(t, pkg, "localhost:888")

bundleDir := "src/test/packages/02-simple-vars"
bundleDir := "src/test/bundles/02-simple-vars"
bundlePath := filepath.Join(bundleDir, fmt.Sprintf("uds-bundle-simple-vars-%s-0.0.1.tar.zst", e2e.Arch))

os.Setenv("UDS_CONFIG", filepath.Join("src/test/packages/02-simple-vars", "uds-config.yaml"))
os.Setenv("UDS_CONFIG", filepath.Join("src/test/bundles/02-simple-vars", "uds-config.yaml"))

create(t, bundleDir)
createRemote(t, bundleDir, "localhost:888")
Expand All @@ -93,7 +93,7 @@ func TestBundleWithLocalInitPkg(t *testing.T) {

e2e.DownloadZarfInitPkg(t, zarfVersion)

bundleDir := "src/test/packages/04-local-init"
bundleDir := "src/test/bundles/04-local-init"
bundlePath := filepath.Join(bundleDir, fmt.Sprintf("uds-bundle-local-init-%s-0.0.1.tar.zst", e2e.Arch))

create(t, bundleDir)
Expand All @@ -106,9 +106,9 @@ func TestBundleWithLocalAndRemotePkgs(t *testing.T) {
e2e.SetupWithCluster(t)
e2e.SetupDockerRegistry(t, 888)
defer e2e.TeardownRegistry(t, 888)
e2e.CreateZarfPkg(t, "src/test/packages/zarf/podinfo")
e2e.CreateZarfPkg(t, "src/test/packages/podinfo")

bundleDir := "src/test/packages/03-local-and-remote"
bundleDir := "src/test/bundles/03-local-and-remote"
bundlePath := filepath.Join(bundleDir, fmt.Sprintf("uds-bundle-local-and-remote-%s-0.0.1.tar.zst", e2e.Arch))

tarballPath := filepath.Join("build", fmt.Sprintf("uds-bundle-local-and-remote-%s-0.0.1.tar.zst", e2e.Arch))
Expand All @@ -130,20 +130,20 @@ func TestBundle(t *testing.T) {
e2e.SetupWithCluster(t)

e2e.DownloadZarfInitPkg(t, zarfVersion)
e2e.CreateZarfPkg(t, "src/test/packages/zarf/podinfo")
e2e.CreateZarfPkg(t, "src/test/packages/podinfo")

e2e.SetupDockerRegistry(t, 888)
defer e2e.TeardownRegistry(t, 888)
e2e.SetupDockerRegistry(t, 889)
defer e2e.TeardownRegistry(t, 889)

pkg := fmt.Sprintf("src/test/packages/zarf/zarf-init-%s-%s.tar.zst", e2e.Arch, zarfVersion)
pkg := fmt.Sprintf("src/test/packages/zarf-init-%s-%s.tar.zst", e2e.Arch, zarfVersion)
zarfPublish(t, pkg, "localhost:888")

pkg = fmt.Sprintf("src/test/packages/zarf/podinfo/zarf-package-podinfo-%s-0.0.1.tar.zst", e2e.Arch)
pkg = fmt.Sprintf("src/test/packages/podinfo/zarf-package-podinfo-%s-0.0.1.tar.zst", e2e.Arch)
zarfPublish(t, pkg, "localhost:889")

bundleDir := "src/test/packages/01-uds-bundle"
bundleDir := "src/test/bundles/01-uds-bundle"
bundlePath := filepath.Join(bundleDir, fmt.Sprintf("uds-bundle-example-%s-0.0.1.tar.zst", e2e.Arch))

create(t, bundleDir) // todo: allow creating from both the folder containing and direct reference to uds-bundle.yaml
Expand All @@ -157,17 +157,17 @@ func TestRemoteBundle(t *testing.T) {
e2e.SetupWithCluster(t)

e2e.DownloadZarfInitPkg(t, zarfVersion)
e2e.CreateZarfPkg(t, "src/test/packages/zarf/podinfo")
e2e.CreateZarfPkg(t, "src/test/packages/podinfo")

e2e.SetupDockerRegistry(t, 888)
defer e2e.TeardownRegistry(t, 888)
e2e.SetupDockerRegistry(t, 889)
defer e2e.TeardownRegistry(t, 889)

pkg := fmt.Sprintf("src/test/packages/zarf/zarf-init-%s-%s.tar.zst", e2e.Arch, zarfVersion)
pkg := fmt.Sprintf("src/test/packages/zarf-init-%s-%s.tar.zst", e2e.Arch, zarfVersion)
zarfPublish(t, pkg, "localhost:888")

pkg = fmt.Sprintf("src/test/packages/zarf/podinfo/zarf-package-podinfo-%s-0.0.1.tar.zst", e2e.Arch)
pkg = fmt.Sprintf("src/test/packages/podinfo/zarf-package-podinfo-%s-0.0.1.tar.zst", e2e.Arch)
zarfPublish(t, pkg, "localhost:889")

bundleRef := registry.Reference{
Expand All @@ -178,7 +178,7 @@ func TestRemoteBundle(t *testing.T) {
}

tarballPath := filepath.Join("build", fmt.Sprintf("uds-bundle-example-%s-0.0.1.tar.zst", e2e.Arch))
bundlePath := "src/test/packages/01-uds-bundle"
bundlePath := "src/test/bundles/01-uds-bundle"

createRemote(t, bundlePath, bundleRef.Registry)
pull(t, bundleRef.String(), tarballPath)
Expand All @@ -194,7 +194,7 @@ func create(t *testing.T, bundlePath string) {
}

func createSecure(t *testing.T, bundlePath string) {
cmd := strings.Split(fmt.Sprintf("create %s --confirm", bundlePath), " ")
cmd := strings.Split(fmt.Sprintf("create %s --confirm -a %s", bundlePath, e2e.Arch), " ")
_, _, err := e2e.UDS(cmd...)
require.NoError(t, err)
}
Expand Down
File renamed without changes.

0 comments on commit 4d61aec

Please sign in to comment.