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

fix: Resolve no clean images detected issue; Remove extra blank image name #1055

Merged
merged 2 commits into from
Jul 4, 2023

Conversation

Akash-Nayak
Copy link
Contributor

Fixes- #1054

$ move2kube collect -a dockerswarm --log-level debug

INFO[0000] Begin collection                             
INFO[0000] [*collector.ImagesCollector] Begin collection 
DEBU[0000] images : [quay.io/konveyor/move2kube-ui:latest nginx:stable-alpine ] 
DEBU[0000] UserID not available in image metadata for [quay.io/konveyor/move2kube-ui:latest] 
DEBU[0000] UserID not available in image metadata for [nginx:stable-alpine]       
WARN[0000] Image [] not available in local image repo. Run "docker pull " 
INFO[0000] [*collector.ImagesCollector] Done            
INFO[0000] Collection done                              
INFO[0000] Collect Output in [/Users/akash/github/move2kube-demos/m2k_collect]. Copy this directory into the source directory to be used for planning.

There was a image with blank name getting appended to the images list because of \n character at the end of outputStr - [quay.io/konveyor/move2kube-ui:latest nginx:stable-alpine ].

Signed-off-by: Akash Nayak akash19nayak@gmail.com

@github-actions
Copy link

Thanks for making a pull request! 😃
One of the maintainers will review and advise on the next steps.

@github-actions github-actions bot added the fix label Jun 28, 2023
@Akash-Nayak Akash-Nayak requested a review from seshapad June 28, 2023 08:22
@ashokponkumar ashokponkumar enabled auto-merge (squash) June 28, 2023 08:24
Copy link
Contributor

@HarikrishnanBalagopal HarikrishnanBalagopal left a comment

Choose a reason for hiding this comment

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

Can we use json as the format? https://stackoverflow.com/questions/50285252/docker-images-output-as-json-using-format
It outputs in JSONL format

$ docker images --format '{{json .}}'
{"Containers":"N/A","CreatedAt":"2021-12-01 19:05:10 +0530 IST","CreatedSince":"19 months ago","Digest":"\u003cnone\u003e","ID":"cc3b650a3f92","Repository":"registry.access.redhat.com/ubi8/go-toolset","SharedSize":"N/A","Size":"1.09GB","Tag":"1.16.7","UniqueSize":"N/A","VirtualSize":"1.086GB"}
{"Containers":"N/A","CreatedAt":"2021-11-16 17:33:48 +0530 IST","CreatedSince":"19 months ago","Digest":"\u003cnone\u003e","ID":"c04867c5b867","Repository":"quay.io/keycloak/keycloak","SharedSize":"N/A","Size":"717MB","Tag":"15.0.2","UniqueSize":"N/A","VirtualSize":"716.6MB"}
{"Containers":"N/A","CreatedAt":"2021-09-24 04:09:54 +0530 IST","CreatedSince":"21 months ago","Digest":"\u003cnone\u003e","ID":"df5477cea558","Repository":"hello-world","SharedSize":"N/A","Size":"9.06kB","Tag":"latest","UniqueSize":"N/A","VirtualSize":"9.056kB"}
{"Containers":"N/A","CreatedAt":"2021-01-25 22:46:49 +0530 IST","CreatedSince":"2 years ago","Digest":"\u003cnone\u003e","ID":"dd91347f1318","Repository":"gcr.io/cassandra-operator/cassandra-operator","SharedSize":"N/A","Size":"41.9MB","Tag":"latest","UniqueSize":"N/A","VirtualSize":"41.9MB"}
{"Containers":"N/A","CreatedAt":"2016-10-22 02:11:46 +0530 IST","CreatedSince":"6 years ago","Digest":"\u003cnone\u003e","ID":"1999482cb0a5","Repository":"mongo","SharedSize":"N/A","Size":"391MB","Tag":"2.6","UniqueSize":"N/A","VirtualSize":"391MB"}
{"Containers":"N/A","CreatedAt":"1980-01-01 05:30:01 +0530 IST","CreatedSince":"43 years ago","Digest":"\u003cnone\u003e","ID":"98ac5ea57540","Repository":"paketobuildpacks/builder","SharedSize":"N/A","Size":"1.97GB","Tag":"full","UniqueSize":"N/A","VirtualSize":"1.966GB"}

@codecov
Copy link

codecov bot commented Jun 28, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (ed1eb73) 14.43% compared to head (8ac5b4f) 14.43%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1055   +/-   ##
=======================================
  Coverage   14.43%   14.43%           
=======================================
  Files          86       86           
  Lines        8176     8175    -1     
=======================================
  Hits         1180     1180           
+ Misses       6690     6689    -1     
  Partials      306      306           
Impacted Files Coverage Δ
collector/imagescollector.go 0.00% <0.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@Akash-Nayak
Copy link
Contributor Author

Akash-Nayak commented Jun 28, 2023

Can we use json as the format? https://stackoverflow.com/questions/50285252/docker-images-output-as-json-using-format It outputs in JSONL format

$ docker images --format '{{json .}}'
{"Containers":"N/A","CreatedAt":"2021-12-01 19:05:10 +0530 IST","CreatedSince":"19 months ago","Digest":"\u003cnone\u003e","ID":"cc3b650a3f92","Repository":"registry.access.redhat.com/ubi8/go-toolset","SharedSize":"N/A","Size":"1.09GB","Tag":"1.16.7","UniqueSize":"N/A","VirtualSize":"1.086GB"}
{"Containers":"N/A","CreatedAt":"2021-11-16 17:33:48 +0530 IST","CreatedSince":"19 months ago","Digest":"\u003cnone\u003e","ID":"c04867c5b867","Repository":"quay.io/keycloak/keycloak","SharedSize":"N/A","Size":"717MB","Tag":"15.0.2","UniqueSize":"N/A","VirtualSize":"716.6MB"}
{"Containers":"N/A","CreatedAt":"2021-09-24 04:09:54 +0530 IST","CreatedSince":"21 months ago","Digest":"\u003cnone\u003e","ID":"df5477cea558","Repository":"hello-world","SharedSize":"N/A","Size":"9.06kB","Tag":"latest","UniqueSize":"N/A","VirtualSize":"9.056kB"}
{"Containers":"N/A","CreatedAt":"2021-01-25 22:46:49 +0530 IST","CreatedSince":"2 years ago","Digest":"\u003cnone\u003e","ID":"dd91347f1318","Repository":"gcr.io/cassandra-operator/cassandra-operator","SharedSize":"N/A","Size":"41.9MB","Tag":"latest","UniqueSize":"N/A","VirtualSize":"41.9MB"}
{"Containers":"N/A","CreatedAt":"2016-10-22 02:11:46 +0530 IST","CreatedSince":"6 years ago","Digest":"\u003cnone\u003e","ID":"1999482cb0a5","Repository":"mongo","SharedSize":"N/A","Size":"391MB","Tag":"2.6","UniqueSize":"N/A","VirtualSize":"391MB"}
{"Containers":"N/A","CreatedAt":"1980-01-01 05:30:01 +0530 IST","CreatedSince":"43 years ago","Digest":"\u003cnone\u003e","ID":"98ac5ea57540","Repository":"paketobuildpacks/builder","SharedSize":"N/A","Size":"1.97GB","Tag":"full","UniqueSize":"N/A","VirtualSize":"1.966GB"}

Using the '{{json .}}' format in place of '{{.Repository}}:{{.Tag}}', it captures lot of extra information that we do not require, so should we still go for the json format.

$ docker images --format '{{.Repository}}:{{.Tag}}'            
quay.io/konveyor/move2kube-ui:latest
nginx:stable-alpine
$ docker images --format '{{json .}}'
{"Containers":"N/A","CreatedAt":"2023-06-22 14:13:14 +0530 IST","CreatedSince":"6 days ago","Digest":"\u003cnone\u003e","ID":"a192738e1b92","Repository":"quay.io/konveyor/move2kube-ui","SharedSize":"N/A","Size":"212MB","Tag":"latest","UniqueSize":"N/A","VirtualSize":"212.1MB"}
{"Containers":"N/A","CreatedAt":"2023-06-15 08:29:26 +0530 IST","CreatedSince":"13 days ago","Digest":"\u003cnone\u003e","ID":"ba1fca8fb480","Repository":"nginx","SharedSize":"N/A","Size":"40.7MB","Tag":"stable-alpine","UniqueSize":"N/A","VirtualSize":"40.7MB"}

@@ -143,14 +143,17 @@ func getAllImageNames() ([]string, error) {
logrus.Warnf("Error while running docker image list : %s", err)
return nil, err
}
images := strings.Split(string(outputStr), "\n")
Copy link
Member

Choose a reason for hiding this comment

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

There is no empty string check for outputStr. Do you want to add a check?

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.

… name

Signed-off-by: Akash Nayak <akash19nayak@gmail.com>
…k image name

Signed-off-by: Akash Nayak <akash19nayak@gmail.com>
auto-merge was automatically disabled July 4, 2023 09:39

Head branch was pushed to by a user without write access

@Akash-Nayak Akash-Nayak force-pushed the fix-empty-image-name branch from ca61731 to 8ac5b4f Compare July 4, 2023 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants