Skip to content

Commit

Permalink
Merge pull request #280 from reegnz/fix_untar
Browse files Browse the repository at this point in the history
Fix tar.gz support
  • Loading branch information
joaopapereira authored Sep 28, 2023
2 parents 3097997 + a77860c commit 15ded16
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/vendir/fetch/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
42 changes: 42 additions & 0 deletions test/e2e/http_tar_test.go
Original file line number Diff line number Diff line change
@@ -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)
})
}

0 comments on commit 15ded16

Please sign in to comment.