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) } diff --git a/test/e2e/http_tar_test.go b/test/e2e/http_tar_test.go new file mode 100644 index 00000000..c4503e53 --- /dev/null +++ b/test/e2e/http_tar_test.go @@ -0,0 +1,42 @@ +// Copyright 2023 VMware, Inc. +// SPDX-License-Identifier: Apache-2.0 + +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) + }) +}