-
Notifications
You must be signed in to change notification settings - Fork 236
Compare layers of images #233
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[ | ||
{ | ||
"Image": "gcr.io/gcp-runtimes/diff-layer-base", | ||
"AnalyzeType": "FileLayer", | ||
"Analysis": [ | ||
[ | ||
{ | ||
"Name": "/first", | ||
"Size": 6 | ||
} | ||
], | ||
[ | ||
{ | ||
"Name": "/second", | ||
"Size": 7 | ||
} | ||
], | ||
[ | ||
{ | ||
"Name": "/third", | ||
"Size": 6 | ||
} | ||
] | ||
] | ||
} | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
[ | ||
{ | ||
"Image1": "gcr.io/gcp-runtimes/diff-layer-base", | ||
"Image2": "gcr.io/gcp-runtimes/diff-layer-modified", | ||
"DiffType": "FileLayer", | ||
"Diff": { | ||
"DirDiffs": [ | ||
{ | ||
"Adds": null, | ||
"Dels": null, | ||
"Mods": null | ||
}, | ||
{ | ||
"Adds": [ | ||
{ | ||
"Name": "/modified", | ||
"Size": 9 | ||
} | ||
], | ||
"Dels": [ | ||
{ | ||
"Name": "/second", | ||
"Size": 7 | ||
} | ||
], | ||
"Mods": null | ||
} | ||
] | ||
} | ||
} | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -216,3 +216,55 @@ func (r FileAnalyzeResult) OutputText(analyzeType string, format string) error { | |
} | ||
return TemplateOutputFromFormat(strResult, "FileAnalyze", format) | ||
} | ||
|
||
type FileLayerAnalyzeResult AnalyzeResult | ||
|
||
func (r FileLayerAnalyzeResult) OutputStruct() interface{} { | ||
analysis, valid := r.Analysis.([][]util.DirectoryEntry) | ||
if !valid { | ||
logrus.Error("Unexpected structure of Analysis. Should be of type []DirectoryEntry") | ||
return errors.New("Could not output FileAnalyzer analysis result") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this error will get outputted somewhere further up the stack right? Can you just do an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, what error do you mean? There isn't a specific error to wrap, which is why I think all the AnalyzeResults are returning new ones. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah sorry, I meant to combine these errors into one and return them without logging anything here. I see that you're just following the pattern from what was already here though, so it's fine for now. We should clean this error handling up later. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool, sounds good |
||
} | ||
|
||
for _, a := range analysis { | ||
if SortSize { | ||
directoryBy(directorySizeSort).Sort(a) | ||
} else { | ||
directoryBy(directoryNameSort).Sort(a) | ||
} | ||
} | ||
|
||
r.Analysis = analysis | ||
return r | ||
} | ||
|
||
func (r FileLayerAnalyzeResult) OutputText(analyzeType string, format string) error { | ||
analysis, valid := r.Analysis.([][]util.DirectoryEntry) | ||
if !valid { | ||
logrus.Error("Unexpected structure of Analysis. Should be of type []DirectoryEntry") | ||
return errors.New("Could not output FileAnalyzer analysis result") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment w.r.t. error here |
||
} | ||
|
||
var strDirectoryEntries [][]StrDirectoryEntry | ||
|
||
for _, a := range analysis { | ||
if SortSize { | ||
directoryBy(directorySizeSort).Sort(a) | ||
} else { | ||
directoryBy(directoryNameSort).Sort(a) | ||
} | ||
strAnalysis := stringifyDirectoryEntries(a) | ||
strDirectoryEntries = append(strDirectoryEntries, strAnalysis) | ||
} | ||
|
||
strResult := struct { | ||
Image string | ||
AnalyzeType string | ||
Analysis [][]StrDirectoryEntry | ||
}{ | ||
Image: r.Image, | ||
AnalyzeType: r.AnalyzeType, | ||
Analysis: strDirectoryEntries, | ||
} | ||
return TemplateOutputFromFormat(strResult, "FileLayerAnalyze", format) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As part of switching to go-containerregistry, I removed all the whiteout handling in
unpackTar
(since it gets handled implicitly bymutate.Extract
). I don't think it should cause any problems here since a tombstoned file would be treated like any normal file would, but just making a note of that here in case you can think of any cases where it would be an issue.