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

add --label flag support to img build #178

Merged
merged 2 commits into from
Oct 23, 2018

Conversation

westonsteimel
Copy link
Contributor

@westonsteimel westonsteimel commented Oct 18, 2018

Adds support for img build --label per #168.

@westonsteimel
Copy link
Contributor Author

I tested by building this Dockerfile with the following

$ img build --label "version=1.68.0" --label "date=2018-10-19" -t westonsteimel/img-label-test .

I then loaded it into docker, ran docker inspect, and observed that the date and version labels had been added in the output

$ img save westonsteimel/img-label-test | docker load
$ docker inspect westonsteimel/img-label-test
[
    {
        "Id": "sha256:ceb18563e6bceefaa835ec1a27e682f941439075540a7fff8fe81dea370f6d20",
        "RepoTags": [
            "westonsteimel/img-label-test:latest"
        ],
        "RepoDigests": [],
        "Parent": "",
        "Comment": "buildkit.dockerfile.v0",
        "Created": "2018-10-09T23:49:00.403370381+01:00",
        "Container": "",
        "ContainerConfig": {
            "Hostname": "",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": null,
            "Cmd": null,
            "Image": "",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": null
        },
        "DockerVersion": "",
        "Author": "",
        "Config": {
            "Hostname": "",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "BOOST_VERSION=1.68.0"
            ],
            "Cmd": [
                "sh"
            ],
            "ArgsEscaped": true,
            "Image": "",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {
                "Description": "Boost C++ libraries on Alpine Linux",
                "date": "2018-10-19",
                "version": "1.68.0"
            }
        },
        "Architecture": "amd64",
        "Os": "linux",
        "Size": 142137617,
        "VirtualSize": 142137617,
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/4bb676b4df9a0d1ed8dd7855931e19917a501944e5af5a12e7672db2177adc66/diff",
                "MergedDir": "/var/lib/docker/overlay2/f2a907da5395d4365cd0a1825d95493ec1887ff3e2d53b25305955925a241686/merged",
                "UpperDir": "/var/lib/docker/overlay2/f2a907da5395d4365cd0a1825d95493ec1887ff3e2d53b25305955925a241686/diff",
                "WorkDir": "/var/lib/docker/overlay2/f2a907da5395d4365cd0a1825d95493ec1887ff3e2d53b25305955925a241686/work"
            },
            "Name": "overlay2"
        },
        "RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:df64d3292fd6194b7865d7326af5255db6d81e9df29f48adde61a918fbd8c332",
                "sha256:eadd0972a6d0c0259010fdb40e4266f4a8362cac8fe1fe71a606a9e88580dd68"
            ]
        },
        "Metadata": {
            "LastTagTime": "0001-01-01T00:00:00Z"
        }
    }
]

@jessfraz
Copy link
Collaborator

ah cool can you add a test to the test file for build as well! thanks!

@westonsteimel
Copy link
Contributor Author

Sure, I can give it a go. I'm a bit unsure of how to view the metadata in order to check that the labels have been applied following the build without docker inspect though.

@jessfraz
Copy link
Collaborator

jessfraz commented Oct 23, 2018 via email

@codecov
Copy link

codecov bot commented Oct 23, 2018

Codecov Report

Merging #178 into master will not change coverage.
The diff coverage is 0%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #178   +/-   ##
=====================================
  Coverage       0%     0%           
=====================================
  Files          13     13           
  Lines         729    735    +6     
=====================================
- Misses        729    735    +6
Impacted Files Coverage Δ
build.go 0% <0%> (ø) ⬆️

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 151b450...5c6e8a2. Read the comment docs.

@westonsteimel
Copy link
Contributor Author

Thanks, I've added a test. Does it seem reasonable enough?

@jessfraz
Copy link
Collaborator

thanks so much!

@jessfraz jessfraz merged commit 5089133 into genuinetools:master Oct 23, 2018
@jessfraz
Copy link
Collaborator

oh if you have time want to update the readme too, just realized :) thanks again!

@westonsteimel
Copy link
Contributor Author

No problem. Yeah, I can update the readme in about an hour or so.

@jessfraz
Copy link
Collaborator

jessfraz commented Oct 23, 2018 via email

@westonsteimel westonsteimel deleted the label-option branch October 23, 2018 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants