lifecycle
lifecycle copied to clipboard
Warning when attempting to delete cache image breaks formating
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
- This appears to be the only area where
fmt.Printfis used. I would expect this line to be using the provided logger. - The cmd/logger already handles missing new line characters. https://github.com/buildpacks/lifecycle/blob/746b0978f70ee1155381a6dcfa6190d9592aff92/cmd/logs.go#L81-L87
- It would be idea to be annotated as a "Warning".