Skip to content
This repository was archived by the owner on Mar 27, 2024. It is now read-only.

Single image analysis #20

Merged
merged 8 commits into from
Aug 18, 2017

Conversation

cftorres
Copy link
Contributor

@cftorres cftorres force-pushed the SingleImageAnalysis branch from 6ce491c to 6b359d2 Compare August 17, 2017 16:02
cmd/root.go Outdated
}

var wg sync.WaitGroup
wg.Add(2)
if len(args) == 1 {
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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

OutputText(diffType string) error
}

type MultiPackageDiffResult struct {
Copy link
Contributor

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.

Copy link
Contributor Author

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
Copy link
Contributor

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?

Copy link
Contributor Author

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 {
Copy link
Contributor

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)
Copy link
Contributor

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.

Copy link
Contributor Author

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()
Copy link
Contributor

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?

Copy link
Contributor Author

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...

@cftorres cftorres force-pushed the SingleImageAnalysis branch from 26e670c to 9d4ef87 Compare August 17, 2017 17:50
Copy link
Contributor

@nkubala nkubala left a 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?

@abbytiz
Copy link
Contributor

abbytiz commented Aug 17, 2017

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.

Copy link
Contributor

@nkubala nkubala left a 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:
Copy link
Contributor

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
Copy link
Contributor

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:
Copy link
Contributor

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:
Copy link
Contributor

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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filessystem -> filesystem

@cftorres
Copy link
Contributor Author

Edited README according to comments, let me know if good to merge!

@cftorres cftorres merged commit 57cb4b6 into GoogleContainerTools:master Aug 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add iDiff "analyze" command to analyze content of single image
3 participants