reference layer data for source of truth on index

This commit is contained in:
Alex Goodman 2019-02-18 08:48:14 -05:00
parent 96e9e2561d
commit 46aff8bcc4
No known key found for this signature in database
GPG Key ID: 743640FAA11698A1
3 changed files with 6 additions and 7 deletions

View File

@ -303,7 +303,6 @@ func (node *FileNode) compare(other *FileNode) DiffType {
if node.Name != other.Name {
panic("comparing mismatched nodes")
}
// TODO: fails on nil
return node.Data.FileInfo.Compare(other.Data.FileInfo)
}

View File

@ -140,18 +140,18 @@ func (image *dockerImageAnalyzer) Analyze() (*AnalysisResult, error) {
// as you iterate chronologically through history (ignoring history items that have no layer contents)
layerIdx := len(image.trees) - 1
tarPathIdx := 0
for idx := 0; idx < len(config.History); idx++ {
for histIdx := 0; histIdx < len(config.History); histIdx++ {
// ignore empty layers, we are only observing layers with content
if config.History[idx].EmptyLayer {
if config.History[histIdx].EmptyLayer {
continue
}
tree := image.trees[(len(image.trees)-1)-layerIdx]
config.History[idx].Size = uint64(tree.FileSize)
config.History[histIdx].Size = uint64(tree.FileSize)
image.layers[layerIdx] = &dockerLayer{
history: config.History[idx],
index: layerIdx,
history: config.History[histIdx],
index: tarPathIdx,
tree: image.trees[layerIdx],
tarPath: manifest.LayerTarPaths[tarPathIdx],
}

View File

@ -17,7 +17,7 @@ func newExport(analysis *image.AnalysisResult) *export {
idx := (len(analysis.Layers) - 1) - revIdx
data.Layer[idx] = exportLayer{
Index: idx,
Index: layer.Index(),
DigestID: layer.Id(),
SizeBytes: layer.Size(),
Command: layer.Command(),