Skip to content

Commit

Permalink
Remove .tar extension from blob and config file names
Browse files Browse the repository at this point in the history
The config file was being saved as digest.tar for the directory transport.
This is misleading as the config file is not a tar archive.
Dropped the .tar extension from all files now, including blobs.
The user can use a tool like file to determine the format of the files in the directory.

Signed-off-by: umohnani8 <umohnani@redhat.com>
  • Loading branch information
umohnani8 committed Feb 20, 2018
1 parent 701221f commit 2f131cc
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion directory/directory_dest.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/sirupsen/logrus"
)

const version = "Directory Transport Version: 1.0\n"
const version = "Directory Transport Version: 1.1\n"

// ErrNotContainerImageDir indicates that the directory doesn't match the expected contents of a directory created
// using the 'dir' transport
Expand Down
4 changes: 2 additions & 2 deletions directory/directory_src.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ func (s *dirImageSource) GetManifest(instanceDigest *digest.Digest) ([]byte, str
func (s *dirImageSource) GetBlob(info types.BlobInfo) (io.ReadCloser, int64, error) {
r, err := os.Open(s.ref.layerPath(info.Digest))
if err != nil {
return nil, 0, nil
return nil, -1, err
}
fi, err := r.Stat()
if err != nil {
return nil, 0, nil
return nil, -1, err
}
return r, fi.Size(), nil
}
Expand Down
5 changes: 2 additions & 3 deletions directory/directory_transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ import (
"path/filepath"
"strings"

"github.com/pkg/errors"

"github.com/containers/image/directory/explicitfilepath"
"github.com/containers/image/docker/reference"
"github.com/containers/image/image"
"github.com/containers/image/transports"
"github.com/containers/image/types"
"github.com/opencontainers/go-digest"
"github.com/pkg/errors"
)

func init() {
Expand Down Expand Up @@ -173,7 +172,7 @@ func (ref dirReference) manifestPath() string {
// layerPath returns a path for a layer tarball within a directory using our conventions.
func (ref dirReference) layerPath(digest digest.Digest) string {
// FIXME: Should we keep the digest identification?
return filepath.Join(ref.path, digest.Hex()+".tar")
return filepath.Join(ref.path, digest.Hex())
}

// signaturePath returns a path for a signature within a directory using our conventions.
Expand Down
2 changes: 1 addition & 1 deletion directory/directory_transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func TestReferenceLayerPath(t *testing.T) {
defer os.RemoveAll(tmpDir)
dirRef, ok := ref.(dirReference)
require.True(t, ok)
assert.Equal(t, tmpDir+"/"+hex+".tar", dirRef.layerPath("sha256:"+hex))
assert.Equal(t, tmpDir+"/"+hex, dirRef.layerPath("sha256:"+hex))
}

func TestReferenceSignaturePath(t *testing.T) {
Expand Down

0 comments on commit 2f131cc

Please sign in to comment.