-
Notifications
You must be signed in to change notification settings - Fork 237
Single image analysis #20
Single image analysis #20
Conversation
6ce491c
to
6b359d2
Compare
cmd/root.go
Outdated
} | ||
|
||
var wg sync.WaitGroup | ||
wg.Add(2) | ||
if len(args) == 1 { |
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.
It makes more sense to me to have analyze as a separate command (such that the logic wouldn't be in root.go) both for clarity and for example in case of future additional commands. If someone adds a command and pattern matches, they seem forced into expanding this if else structure. The primary logic already seems separated out so is there a reason not to pull it into it's own command file?
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.
I just thought only one command would be preferable for our tool... @nkubala @aaron-prindle do you have any thoughts as to whether we should split this up into a separate command?
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.
I actually think this structure is fine. We should probably at least put a comment here saying semantically what each case means (analyze
= one image, diff
= two), and then put something about it in the usage/--help
command. I do like the tool choosing which path to take based on how many images you provide it though, seems intuitive to me
utils/diff_output_utils.go
Outdated
OutputText(diffType string) error | ||
} | ||
|
||
type MultiPackageDiffResult struct { |
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.
nit: Did MultiVersionPackageDiffResult lose the "Version" part intentionally when it became MultiPackageAnalyzeResult? Also is SingleVersionDiffResult now SinglePackageAnalyzeResult? These names seem significantly less clear to me since the real crux of MultiVersion is that it supports multiple versions of the same package. Also SinglePackageAnalyzeResult seems like it would be an analysis of one package, rather than an analysis of all packages, given that each exists with a single version in the image.
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.
I think I just omitted the "Version" part to shorten it because it seemed really long, but I can put it back... SingleVersionDiffResult never existed, I believe you called it PackageDiffResult and it's still there, but for consistency sake I can make it SingleVersionPackageDiffResult. These all just seem very long.
@@ -110,10 +110,8 @@ func pullImageFromRepo(image string) (string, string, error) { | |||
} | |||
|
|||
type HistDiff struct { | |||
Image1 string |
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.
Where are the names being stored now?
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.
I pulled them out into the DiffResult instead because they were previously in this Diff field of the DiffResult, and they didn't seem to be part of the actual diff per se
cmd/root.go
Outdated
} | ||
|
||
var wg sync.WaitGroup | ||
wg.Add(2) | ||
if len(args) == 1 { |
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.
I actually think this structure is fine. We should probably at least put a comment here saying semantically what each case means (analyze
= one image, diff
= two), and then put something about it in the usage/--help
command. I do like the tool choosing which path to take based on how many images you provide it though, seems intuitive to me
cmd/root.go
Outdated
image, err := utils.ImagePrepper{imageArg}.GetImage() | ||
if err != nil { | ||
glog.Error(err.Error()) | ||
os.Exit(1) |
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.
not sure if this is new to this PR, but GetImage()
extracts the image filesystem and saves it on disk right? if so, calling os.Exit(1)
here will skip the cleanup of that image if the user didn't want it around. probably want to defer an image cleanup in the root command, and then return an error here.
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.
done
cmd/root.go
Outdated
glog.Error(err) | ||
} | ||
} | ||
fmt.Println() |
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.
nit: use glog/the output buffer here?
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.
Oh I actually don't even think this is necessary because there's a newline in the template, so I'll just get rid of it...
26e670c
to
9d4ef87
Compare
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.
sorry if i'm missing it, but can you add a test for this?
If I'm not mistaken this PR changes some names that are referenced in the Output section of the ReadMe and the Custom Differ Quickstart section. Also the new flag and it's usage should similarly be documented. |
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.
code looks good, please update the docs/readme with the new names and the added flag
README.md
Outdated
@@ -32,9 +33,19 @@ Download the [container-diff-windows-amd64.exe](https://storage.googleapis.com/c | |||
|
|||
## Quickstart | |||
|
|||
To use container-diff you need two Docker images (in the form of an ID, tarball, or URL from a repo). Once you have those images you can run any of the following differs: | |||
To use container-diff to perform single image analysis, you need one Docker image (in the form of an ID, tarball, or URL from a repo). Once you have that images you can run any of the following analyzers: |
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.
nit: Once you have that, you can run (notice inserted comma and removed "images")
@@ -190,46 +240,43 @@ Version differences: None | |||
``` | |||
|
|||
|
|||
## Make your own differ | |||
## Make your own analyzer |
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.
The updates here look really good and seem really clear. Great work!
README.md
Outdated
@@ -32,9 +33,19 @@ Download the [container-diff-windows-amd64.exe](https://storage.googleapis.com/c | |||
|
|||
## Quickstart | |||
|
|||
To use container-diff you need two Docker images (in the form of an ID, tarball, or URL from a repo). Once you have those images you can run any of the following differs: | |||
To use container-diff to perform single image analysis, you need one Docker image (in the form of an ID, tarball, or URL from a repo). Once you have that images you can run any of the following analyzers: |
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.
nit (for clarity): single image analysis -> analysis on a single image
README.md
Outdated
@@ -71,30 +83,79 @@ To use the docker client instead of shelling out to your local docker daemon, ad | |||
|
|||
```container-diff <img1> <img2> -e``` | |||
|
|||
## Analysis Result Format | |||
|
|||
The jsons for analysis results are in the follow 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.
follow -> following
README.md
Outdated
|
||
The files system differ has the following json output structure: | ||
The filessystem differ has the following json output structure: |
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.
filessystem -> filesystem
Edited README according to comments, let me know if good to merge! |
fixes #8
@aaron-prindle @nkubala @abbytiz