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

docker-archive: Add support for kaniko #327

Merged
Merged
Changes from all commits
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
29 changes: 24 additions & 5 deletions dive/image/docker/image_archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ package docker

import (
"archive/tar"
"compress/gzip"
"fmt"
"github.com/wagoodman/dive/dive/filetree"
"github.com/wagoodman/dive/dive/image"
"io"
"io/ioutil"
"os"
"path"
"strings"

"github.com/wagoodman/dive/dive/filetree"
"github.com/wagoodman/dive/dive/image"
)

type ImageArchive struct {
Expand Down Expand Up @@ -48,20 +50,37 @@ func NewImageArchive(tarFile io.ReadCloser) (*ImageArchive, error) {

if strings.HasSuffix(name, ".tar") {
currentLayer++
layerReader := tar.NewReader(tarReader)
tree, err := processLayerTar(name, layerReader)
if err != nil {
return img, err
}

// add the layer to the image
img.layerMap[tree.Name] = tree

} else if strings.HasSuffix(name, ".tar.gz") || strings.HasSuffix(name, "tgz") {
currentLayer++

// Add gzip reader
gz, err := gzip.NewReader(tarReader)
if err != nil {
return img, err
}
layerReader := tar.NewReader(tarReader)
tree, err := processLayerTar(name, layerReader)

// Add tar reader
layerReader := tar.NewReader(gz)

// Process layer
tree, err := processLayerTar(name, layerReader)
if err != nil {
return img, err
}

// add the layer to the image
img.layerMap[tree.Name] = tree

} else if strings.HasSuffix(name, ".json") {
} else if strings.HasSuffix(name, ".json") || strings.HasPrefix(name, "sha256:") {
fileBuffer, err := ioutil.ReadAll(tarReader)
if err != nil {
return img, err
Expand Down