From d7d23c1d438f4af31ae153136639384d2ba3de83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Reegn?= Date: Tue, 8 Aug 2023 17:54:13 +0200 Subject: [PATCH 1/3] Fix tar.gz support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Zoltán Reegn --- pkg/vendir/fetch/archive.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/vendir/fetch/archive.go b/pkg/vendir/fetch/archive.go index 8bfc4d66..d5ec475e 100644 --- a/pkg/vendir/fetch/archive.go +++ b/pkg/vendir/fetch/archive.go @@ -155,6 +155,9 @@ func (t Archive) tryTarWithGzip(path, dstPath string, gzipped bool) (bool, error return true, err } + case tar.TypeXGlobalHeader: + continue + default: return false, fmt.Errorf("Unknown file '%s' (%d)", header.Name, header.Typeflag) } From df04bbc45e62e4409a5daabdfa4efb2e59ea62e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Reegn?= Date: Wed, 20 Sep 2023 19:20:57 +0200 Subject: [PATCH 2/3] Add e2e test for untar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Zoltán Reegn --- test/e2e/http_tar_test.go | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 test/e2e/http_tar_test.go diff --git a/test/e2e/http_tar_test.go b/test/e2e/http_tar_test.go new file mode 100644 index 00000000..5d5118b2 --- /dev/null +++ b/test/e2e/http_tar_test.go @@ -0,0 +1,39 @@ +package e2e + +import ( + "fmt" + "os" + "strings" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestHttpTarGz(t *testing.T) { + env := BuildEnv(t) + logger := Logger{} + vendir := Vendir{t, env.BinaryPath, logger} + dstPath, err := os.MkdirTemp("", "vendir-e2e-http-targz-dst") + require.NoError(t, err) + // defer os.RemoveAll(dstPath) + + yaml := ` +apiVersion: vendir.k14s.io/v1alpha1 +kind: Config +directories: +- path: vendor + contents: + - path: github.com/carvel-dev/vendir + http: + url: https://github.com/carvel-dev/vendir/archive/refs/tags/v0.34.4.tar.gz + ` + + logger.Section("sync tar.gz made with git archive", func() { + _, err := vendir.RunWithOpts([]string{"sync", "-f", "-"}, RunOpts{Dir: dstPath, StdinReader: strings.NewReader(yaml), AllowError: true}) + require.NoError(t, err) + _, err = os.Stat(fmt.Sprintf("%s/%s", dstPath, "vendor/github.com/carvel-dev/vendir/v0.34.4.tar.gz")) + require.Error(t, err) + _, err = os.Stat(fmt.Sprintf("%s/%s", dstPath, "vendor/github.com/carvel-dev/vendir/vendir-0.34.4/cmd/vendir/vendir.go")) + require.NoError(t, err) + }) +} From a77860cbcbcc7488b3af2d9d8aeffbf48a8f3221 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Reegn?= Date: Thu, 21 Sep 2023 17:21:40 +0200 Subject: [PATCH 3/3] Fix minor issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Zoltán Reegn --- test/e2e/http_tar_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/e2e/http_tar_test.go b/test/e2e/http_tar_test.go index 5d5118b2..c4503e53 100644 --- a/test/e2e/http_tar_test.go +++ b/test/e2e/http_tar_test.go @@ -1,3 +1,6 @@ +// Copyright 2023 VMware, Inc. +// SPDX-License-Identifier: Apache-2.0 + package e2e import ( @@ -15,7 +18,7 @@ func TestHttpTarGz(t *testing.T) { vendir := Vendir{t, env.BinaryPath, logger} dstPath, err := os.MkdirTemp("", "vendir-e2e-http-targz-dst") require.NoError(t, err) - // defer os.RemoveAll(dstPath) + defer os.RemoveAll(dstPath) yaml := ` apiVersion: vendir.k14s.io/v1alpha1