Skip to content

Commit

Permalink
Add a version label to containers.
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Nephin <[email protected]>
  • Loading branch information
dnephin committed May 9, 2015
1 parent 78a701b commit fe07044
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 4 deletions.
1 change: 0 additions & 1 deletion compose/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import unicode_literals
from .service import Service # noqa:flake8

__version__ = '1.3.0dev'
1 change: 1 addition & 0 deletions compose/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
ONE_OFF_LABEL = 'com.docker.compose.oneoff'
PROJECT_LABEL = 'com.docker.compose.project'
SERVICE_LABEL = 'com.docker.compose.service'
VERSION_LABEL = 'com.docker.compose.version'
3 changes: 3 additions & 0 deletions compose/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
from docker.errors import APIError
from docker.utils import create_host_config, LogConfig

from . import __version__
from .config import DOCKER_CONFIG_KEYS
from .const import (
CONTAINER_NUMBER_LABEL,
ONE_OFF_LABEL,
PROJECT_LABEL,
SERVICE_LABEL,
VERSION_LABEL,
)
from .container import Container
from .progress_stream import stream_output, StreamOutputError
Expand Down Expand Up @@ -551,6 +553,7 @@ def build_container_labels(label_options, service_labels, number, one_off=False)
labels = label_options or {}
labels.update(label.split('=', 1) for label in service_labels)
labels[CONTAINER_NUMBER_LABEL] = str(number)
labels[VERSION_LABEL] = __version__
return labels


Expand Down
4 changes: 2 additions & 2 deletions tests/integration/service_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import shutil
import six

from compose import Service
from compose.service import (
CannotBeScaledError,
build_extra_hosts,
ConfigError,
Service,
build_extra_hosts,
)
from compose.container import Container
from docker.errors import APIError
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/service_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import docker
from requests import Response

from compose import Service
from compose.service import Service
from compose.container import Container
from compose.const import SERVICE_LABEL, PROJECT_LABEL, ONE_OFF_LABEL
from compose.service import (
Expand Down

0 comments on commit fe07044

Please sign in to comment.