-
Notifications
You must be signed in to change notification settings - Fork 236
Conversation
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.
@vsoch thanks for sending this PR! Logic looks great, just a few small nits mostly related to style. Flag names, etc. all LGTM.
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.
@vsoch thanks again for another great PR!
Sweeet!! Oh man I am so excited to run this on our cluster! 😂 🎈 🐱 🥑 |
👍 I'm excited for you! Feel free to share any cool results you come up with 😄 I'll try and get a release out ASAP |
Thanks again! Here is a little exploratory analysis and writeup I did --> https://twitter.com/vsoch/status/1075886704266014720 container-diff made the extraction of the Dockerfile and container metadata possible! |
@vsoch super interesting writeup! I think it's awesome that you're not just using containers, but thinking about what they really are and what we can learn by understanding them on a fundamental level. and that you're using container-diff to do it 😆 |
Thank @nkubala ! I have another thing I'm working on (containertree) that also is using container diff to derive some better understanding, but I'm still working on the "prove it's useful with analysis examples" bit. I'll share more if/when I get there! |
oooh....my interest is piqued 👀 please do! |
This pull request will close #275, specifically allowing the user to specify a file to write to. Notes are included below.
What is the entrypoint for the user?
The application flow beings with the addition of a new variable,
outputFile
It's a string, the default being empty, that if not empty, will serve two purposes:
With any write to file it goes without saying we don't want to overwrite by default, but we can give the user a
--force
variable to push it.Variable Choices
I chose
output
for the command line flag (--output
) because it reads nicely into a sentence, e.g., "--output=/path/to/file.json" reads to output goes to this file path. I also chosew
for the single character (well, o was taken) but also becausew
can also stand for "write," sort of like thegofmt -w <file>
command. So "-w /path/to/file.json" reads to "write to this file path).What is the Client Flow?
The flag is revealed as an option
--output
if we doanalyze
ordiff
. Note that I also added aforce
option in the case that the file exists. The user can choose to overwrite it with--force
.And here is for diff, it's mostly the same.
I specifically didn't add a short hand for "force." If a user wants to overwrite a file, it's a pretty big deal, and if they might mess up the specification of one letter (and accidentally overwrite) I don't want to risk this.
Manual Testing
We can first test that, without any specification of
--output
, it still works (and prints to stdout).$ ./out/container-diff analyze ubuntu -----Size----- Analysis for ubuntu: IMAGE DIGEST SIZE ubuntu sha256:acd85db6e4b18aafa7fcde5480872909bd8e6d5fbd4e5e790ecc09acc06a8b78 68.6M
Now let's write to a text file.
$ cat /tmp/file.txt -----Size----- Analysis for ubuntu: IMAGE DIGEST SIZE ubuntu sha256:acd85db6e4b18aafa7fcde5480872909bd8e6d5fbd4e5e790ecc09acc06a8b78 68.6M
We can then try to write to the same file, it shouldn't allow us!
...unless we tell it to force! (Use the force, logrus)
(Note no error messages).
We can do all of the above but specify json output.
I think that's about it! I'm guessing you will want some tests? Let's have (high level discussion) on what we want to test (and recommendations for doing things like writing temporary files, organization and naming, etc.) and then I can give a GO at that too (pun, harhar).