Skip to content

Commit

Permalink
docker-archive: Add support for kaniko
Browse files Browse the repository at this point in the history
  • Loading branch information
avisiedo committed Oct 31, 2020
1 parent bed359c commit ec6b227
Showing 1 changed file with 24 additions and 5 deletions.
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

0 comments on commit ec6b227

Please sign in to comment.