Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iDiff refactor with interfaces #243

Merged
merged 9 commits into from Jul 21, 2017

Conversation

cftorres
Copy link
Contributor

"linux": AptDiff,
"pip": PipDiff,
"node": NodeDiff,
type ImageDiff 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: This struct name is a little confusing to me just because ImageDiff makes me think the diff has been done but it hasn't yet... not super important just something to consider


strhistory := make([]string, len(history))
for i, layer := range history {
layerDescription := strings.TrimSpace(layer.CreatedBy)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: no need to instantiate a new string each time here. You can either declare the var outside the loop and overwrite each time, or just pass the results of strings.TrimSpace() directly to Sprintf().

// return err
// }
// return templateOutput(diff)
// }
Copy link
Contributor

Choose a reason for hiding this comment

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

remove this?

img1 := diff.Image1
img2 := diff.Image2
differ := diff.DiffType
eng := diff.UseDocker
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a little weird to me; it seems like UseDocker is more like a global state of the program rather than a field in a struct. Can we maybe have this as a util function somewhere and then call that where ever you use this field?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah honestly it was only included there because that's where all the other args (the two images and differ) are collected from the command line, but this eng bool that's currently required in a lot of our functions is in the process of being removed because @abbytiz is looking into Docker Registry stuff as per Dan's suggestion to remove Docker dependencies entirely... but in the meantime, should I go ahead and do that?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah ok. Yeah since this is a refactor anyway, I'd say go ahead and just pull it out into a util function. Then whenever @abbytiz removes the Docker dependency it'll be easy to just swap it out in that util function or just remove it entirely

@@ -7,7 +7,7 @@ import (
"os"
"path/filepath"
"regexp"
"strings"
// "strings"
Copy link
Contributor

Choose a reason for hiding this comment

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

remove

glog.Error(err.Error())
os.Exit(1)
}
if diff, err := differs.Diff(args[2], args[3], args[1], json, eng); err == nil {
fmt.Println(diff)
utils.SetDockerEngine(eng)
Copy link
Contributor

Choose a reason for hiding this comment

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

Eventually I think this should be determined automatically by the tool (and not rely on a flag being passed in by the user). This is fine for now though.

@cftorres cftorres merged commit 33c4f32 into GoogleCloudPlatform:master Jul 21, 2017
@cftorres cftorres deleted the DiffRefactorOutput branch July 21, 2017 16:33
cftorres added a commit to cftorres/runtimes-common that referenced this pull request Aug 2, 2017
* Differ + image refactor

* Output and DiffResult refactor

* Breaking up JSON and text outputs

* Refactored if branch chains to use reflection for image source determination

* Extracted out eng
cftorres added a commit to cftorres/runtimes-common that referenced this pull request Aug 2, 2017
* Differ + image refactor

* Output and DiffResult refactor

* Breaking up JSON and text outputs

* Refactored if branch chains to use reflection for image source determination

* Extracted out eng
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants