docker / app

Make your Docker Compose applications reusable, and share them on Docker Hub
Apache License 2.0
1.57k stars 177 forks source link

Added created date to app images #735

Closed zappy-shu closed 4 years ago

zappy-shu commented 4 years ago

- What I did

Added a created date field to the custom payload of the bundle.json which is used to display the time since the app image was built in human readable format on docker app image ls as the CREATED column.

- How I did it

Created a v1.0 struct for the custom payload in bundle.json that stores the creation date at build time. A constant is used to track which version of the custom payload is to be deserialized rather than using the docker app version. This is to make it easier to check which struct matches which versions.

As the entire bundle.json is deserialized at once the custom payload needs to be re-serialized before deserializing into the concrete type as it is stored as a simple map[string]interface{}.

The human readable output is done using the github.com/docker/go-units package, same as with docker image ls.

- How to verify it

Run a docker app build. The resulting bundle.json should have a custom section similar to the following:


    "custom": {
        "com.docker.app": {
            "payload": {
                "created": "2019-11-07T14:18:41.9539586Z"
            },
            "version": "1.0.0"
        }
    },

Note that the created field should be in UTC.

Running docker app image ls should print a CREATED column showing the amount of time since the app image was built or blank if the image was built using an older version of docker app.

Example output:

REPOSITORY TAG    APP IMAGE ID APP NAME    CREATED
test1      latest acb44aed7b77 hello-world 4 days ago
test2      latest acb44aed7b77 hello-world Less than a second ago
rumpl/nick <none> 1d1a57daebbf voting-app

- Description for the changelog

Added the creation date to the App bundle and prints the time since creation in the docker app image ls output

- A picture of a cute animal (not mandatory)

kitten-2019-11-12

codecov[bot] commented 4 years ago

Codecov Report

Merging #735 into master will increase coverage by 0.73%. The diff coverage is 41.17%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #735      +/-   ##
==========================================
+ Coverage    69.3%   70.03%   +0.73%     
==========================================
  Files          63       64       +1     
  Lines        3388     3651     +263     
==========================================
+ Hits         2348     2557     +209     
- Misses        731      747      +16     
- Partials      309      347      +38
Impacted Files Coverage Δ
internal/commands/root.go 63.95% <0%> (-8.42%) :arrow_down:
internal/commands/run.go 61.95% <100%> (+0.41%) :arrow_up:
internal/commands/validate.go 75% <100%> (+0.8%) :arrow_up:
internal/cliopts/installerContext.go 27.58% <100%> (+2.58%) :arrow_up:
internal/commands/inspect.go 16.66% <0%> (-0.62%) :arrow_down:
internal/packager/cnab.go 97.67% <0%> (-0.28%) :arrow_down:
internal/packager/custom.go 61.29% <0%> (ø)
internal/commands/image/rm.go 65.21% <0%> (+2.71%) :arrow_up:
internal/commands/image/list.go 87.67% <0%> (+3.99%) :arrow_up:
internal/commands/image/tag.go 91.07% <0%> (+6.07%) :arrow_up:
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 4e0989c...9fb9b2d. Read the comment docs.