lifecycle icon indicating copy to clipboard operation
lifecycle copied to clipboard

Warning when attempting to delete cache image breaks formating

Open jromero opened this issue 3 years ago • 0 comments
trafficstars

Summary

When an error occurs in attempting to delete the previous cache image, the formatting of the output breaks.

ie:

Reusing cache layer 'samples/java-maven:jdk'
Adding cache layer 'samples/java-maven:maven_m2'
Unable to delete previous cache image: DELETE https://index.docker.io/v2/jar013/cacheflag/manifests/sha256:6382cb6220d4858aacbe8985373110dd4f6b6d15d2324d6fc14024061e2c6630: UNSUPPORTED: The operation is unsupported.Successfully built image index.docker.io/jar013/cacheflag:0918

Notice that the message "Successfully built image index.docker.io/jar013/cacheflag:0918" is not in a new line.

Expected:

Reusing cache layer 'samples/java-maven:jdk'
Adding cache layer 'samples/java-maven:maven_m2'
Warning: Unable to delete previous cache image: DELETE https://index.docker.io/v2/jar013/cacheflag/manifests/sha256:6382cb6220d4858aacbe8985373110dd4f6b6d15d2324d6fc14024061e2c6630: UNSUPPORTED: The operation is unsupported.
Successfully built image index.docker.io/jar013/cacheflag:0918

Possible Solution

The area printing the error is here: https://github.com/buildpacks/lifecycle/blob/746b0978f70ee1155381a6dcfa6190d9592aff92/cache/image_cache.go#L117-L119

  1. This appears to be the only area where fmt.Printf is used. I would expect this line to be using the provided logger.
  2. The cmd/logger already handles missing new line characters. https://github.com/buildpacks/lifecycle/blob/746b0978f70ee1155381a6dcfa6190d9592aff92/cmd/logs.go#L81-L87
  3. It would be idea to be annotated as a "Warning".

jromero avatar Jul 12 '22 14:07 jromero