Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1322 component tarballs #1331

Merged
merged 4 commits into from
Feb 13, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add flag for decompressing component layer tars
YrrepNoj committed Feb 6, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 6961ee98eba08b4f7c718b1c706a0766ef3c1954
21 changes: 21 additions & 0 deletions src/cmd/tools.go
Original file line number Diff line number Diff line change
@@ -6,6 +6,8 @@ package cmd

import (
"os"
"path/filepath"
"strings"

"github.com/anchore/syft/cmd/syft/cli"
"github.com/defenseunicorns/zarf/src/config"
@@ -22,6 +24,7 @@ import (
)

var subAltNames []string
var decompressLayers bool

var toolsCmd = &cobra.Command{
Use: "tools",
@@ -64,6 +67,23 @@ var archiverDecompressCmd = &cobra.Command{
if err != nil {
message.Fatal(err, lang.CmdToolsArchiverDecompressErr)
}

// Decompress component layers in the destination path
if decompressLayers {
layersDir := filepath.Join(destinationPath, "components")

files, err := os.ReadDir(layersDir)
if err != nil {
message.Fatalf(err, "failed to read the layers of components")
}
for _, file := range files {
if strings.HasSuffix(file.Name(), "tar.zst") {
if err := archiver.Unarchive(filepath.Join(layersDir, file.Name()), layersDir); err != nil {
message.Fatalf(err, "failed to decompress the component layer")
}
}
}
}
},
}

@@ -173,6 +193,7 @@ func init() {

archiverCmd.AddCommand(archiverCompressCmd)
archiverCmd.AddCommand(archiverDecompressCmd)
archiverDecompressCmd.Flags().BoolVar(&decompressLayers, "decompress-all", false, "Decompress all layers in the archive")

cranePlatformOptions := config.GetCraneOptions(false)

2 changes: 1 addition & 1 deletion src/test/e2e/04_create_templating_test.go
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@ func TestCreateTemplating(t *testing.T) {
stdOut, stdErr, err := e2e.execZarfCommand("package", "create", "examples/package-variables", "--set", "CONFIG_MAP=simple-configmap.yaml", "--set", "ACTION=template", "--confirm", "--zarf-cache", cachePath)
require.NoError(t, err, stdOut, stdErr)

stdOut, stdErr, err = e2e.execZarfCommand("t", "archiver", "decompress", pkgName, decompressPath)
stdOut, stdErr, err = e2e.execZarfCommand("t", "archiver", "decompress", pkgName, decompressPath, "--decompress-all")
require.NoError(t, err, stdOut, stdErr)

// Check that the configmap exists and is readable
2 changes: 1 addition & 1 deletion src/test/e2e/22_git_and_flux_test.go
Original file line number Diff line number Diff line change
@@ -162,7 +162,7 @@ func testRemovingTagsOnCreate(t *testing.T) {

// Extract the built package so we can inspect the repositories that are included
extractedDirPath := "tmp-extraction"
stdOut, stdErr, err := e2e.execZarfCommand("tools", "archiver", "decompress", testPackagePath, extractedDirPath, "-l=trace")
stdOut, stdErr, err := e2e.execZarfCommand("tools", "archiver", "decompress", testPackagePath, extractedDirPath, "-l=trace", "--decompress-all")
defer e2e.cleanFiles(extractedDirPath)
require.NoError(t, err, stdOut, stdErr)