Browse Source

Merge pull request #1915 from dnephin/add_pre_commit_hooks

Add pre commit hooks
Aanand Prasad 10 years ago
parent
commit
17682c58db
68 changed files with 280 additions and 222 deletions
  1. 18 0
      .pre-commit-config.yaml
  2. 2 4
      CHANGELOG.md
  3. 3 0
      Dockerfile
  4. 1 1
      README.md
  5. 12 7
      compose/cli/command.py
  6. 3 2
      compose/cli/docker_client.py
  7. 5 3
      compose/cli/docopt_command.py
  8. 1 0
      compose/cli/errors.py
  9. 3 1
      compose/cli/formatter.py
  10. 3 3
      compose/cli/log_printer.py
  11. 11 7
      compose/cli/main.py
  12. 1 0
      compose/cli/multiplexer.py
  13. 6 4
      compose/cli/utils.py
  14. 1 2
      compose/cli/verbose_proxy.py
  15. 9 10
      compose/config/__init__.py
  16. 9 13
      compose/config/config.py
  17. 1 2
      compose/config/interpolation.py
  18. 5 3
      compose/config/validation.py
  19. 5 3
      compose/container.py
  20. 2 1
      compose/legacy.py
  21. 1 1
      compose/progress_stream.py
  22. 9 4
      compose/project.py
  23. 22 18
      compose/service.py
  24. 3 2
      compose/utils.py
  25. 6 6
      docs/README.md
  26. 1 1
      docs/index.md
  27. 8 8
      docs/install.md
  28. 3 4
      docs/pre-process.sh
  29. 0 1
      docs/production.md
  30. 1 1
      docs/rails.md
  31. 1 1
      docs/reference/build.md
  32. 1 1
      docs/reference/docker-compose.md
  33. 3 3
      docs/reference/index.md
  34. 1 1
      docs/reference/kill.md
  35. 1 1
      docs/reference/overview.md
  36. 1 1
      docs/reference/port.md
  37. 1 1
      docs/reference/pull.md
  38. 1 5
      docs/reference/run.md
  39. 1 1
      docs/reference/scale.md
  40. 3 3
      docs/wordpress.md
  41. 2 3
      docs/yml.md
  42. 4 4
      requirements-dev.txt
  43. 1 1
      requirements.txt
  44. 1 1
      script/test-versions
  45. 5 2
      setup.py
  46. 1 1
      tests/fixtures/extends/nonexistent-path-base.yml
  47. 1 1
      tests/fixtures/extends/nonexistent-path-child.yml
  48. 1 1
      tests/fixtures/longer-filename-composefile/docker-compose.yaml
  49. 5 4
      tests/integration/cli_test.py
  50. 2 2
      tests/integration/legacy_test.py
  51. 2 2
      tests/integration/project_test.py
  52. 2 2
      tests/integration/resilience_test.py
  53. 16 18
      tests/integration/service_test.py
  54. 5 5
      tests/integration/state_test.py
  55. 5 4
      tests/integration/testcases.py
  56. 3 2
      tests/unit/cli/docker_client_test.py
  57. 2 2
      tests/unit/cli/verbose_proxy_test.py
  58. 3 2
      tests/unit/cli_test.py
  59. 3 2
      tests/unit/config_test.py
  60. 2 2
      tests/unit/container_test.py
  61. 2 1
      tests/unit/interpolation_test.py
  62. 3 2
      tests/unit/log_printer_test.py
  63. 2 2
      tests/unit/progress_stream_test.py
  64. 7 6
      tests/unit/project_test.py
  65. 15 16
      tests/unit/service_test.py
  66. 2 1
      tests/unit/sort_service_test.py
  67. 3 2
      tests/unit/split_buffer_test.py
  68. 11 1
      tox.ini

+ 18 - 0
.pre-commit-config.yaml

@@ -0,0 +1,18 @@
+- repo: git://github.com/pre-commit/pre-commit-hooks
+  sha: 'v0.4.2'
+  hooks:
+    - id: check-added-large-files
+    - id: check-docstring-first
+    - id: check-merge-conflict
+    - id: check-yaml
+    - id: debug-statements
+    - id: end-of-file-fixer
+    - id: flake8
+    - id: name-tests-test
+      exclude: 'tests/integration/testcases.py'
+    - id: requirements-txt-fixer
+    - id: trailing-whitespace
+- repo: git://github.com/asottile/reorder_python_imports
+  sha: 3d86483455ab5bd06cc1069fdd5ac57be5463f10
+  hooks:
+    - id: reorder-python-imports

+ 2 - 4
CHANGELOG.md

@@ -202,7 +202,7 @@ The highlights:
  - There is a new `fig restart` command which restarts a service's containers.
 
  - Fig creates multiple containers in service by appending a number to the service name (e.g. `db_1`, `db_2`, etc). As a convenience, Fig will now give the first container an alias of the service name (e.g. `db`).
-   
+
    This link alias is also a valid hostname and added to `/etc/hosts` so you can connect to linked services using their hostname. For example, instead of resolving the environment variables `DB_PORT_5432_TCP_ADDR` and `DB_PORT_5432_TCP_PORT`, you could just use the hostname `db` and port `5432` directly.
 
  - Volume definitions now support `ro` mode, expanding `~` and expanding environment variables.
@@ -250,7 +250,7 @@ Thanks @ryanbrainard and @d11wtq!
 ------------------
 
  - Fig now starts links when you run `fig run` or `fig up`.
-   
+
    For example, if you have a `web` service which depends on a `db` service, `fig run web ...` will start the `db` service.
 
  - Environment variables can now be resolved from the environment that Fig is running in. Just specify it as a blank variable in your `fig.yml` and, if set, it'll be resolved:
@@ -410,5 +410,3 @@ Big thanks to @tomstuart, @EnTeQuAk, @schickling, @aronasorman and @GeoffreyPlit
 ------------------
 
 Initial release.
-
-

+ 3 - 0
Dockerfile

@@ -14,6 +14,7 @@ RUN set -ex; \
         curl \
         lxc \
         iptables \
+        libsqlite3-dev \
     ; \
     rm -rf /var/lib/apt/lists/*
 
@@ -68,6 +69,8 @@ RUN pip install -r requirements.txt
 ADD requirements-dev.txt /code/
 RUN pip install -r requirements-dev.txt
 
+RUN pip install tox==2.1.1
+
 ADD . /code/
 RUN python setup.py install
 

+ 1 - 1
README.md

@@ -54,4 +54,4 @@ Want to help build Compose? Check out our [contributing documentation](https://g
 Releasing
 ---------
 
-Releases are built by maintainers, following an outline of the [release process](https://github.com/docker/compose/blob/master/RELEASE_PROCESS.md).
+Releases are built by maintainers, following an outline of the [release process](https://github.com/docker/compose/blob/master/RELEASE_PROCESS.md).

+ 12 - 7
compose/cli/command.py

@@ -1,20 +1,25 @@
-from __future__ import unicode_literals
 from __future__ import absolute_import
-from requests.exceptions import ConnectionError, SSLError
+from __future__ import unicode_literals
+
 import logging
 import os
 import re
+
 import six
+from requests.exceptions import ConnectionError
+from requests.exceptions import SSLError
 
+from . import errors
+from . import verbose_proxy
+from .. import __version__
 from .. import config
 from ..project import Project
 from ..service import ConfigError
-from .docopt_command import DocoptCommand
-from .utils import call_silently, is_mac, is_ubuntu
 from .docker_client import docker_client
-from . import verbose_proxy
-from . import errors
-from .. import __version__
+from .docopt_command import DocoptCommand
+from .utils import call_silently
+from .utils import is_mac
+from .utils import is_ubuntu
 
 log = logging.getLogger(__name__)
 

+ 3 - 2
compose/cli/docker_client.py

@@ -1,7 +1,8 @@
+import os
+import ssl
+
 from docker import Client
 from docker import tls
-import ssl
-import os
 
 
 def docker_client():

+ 5 - 3
compose/cli/docopt_command.py

@@ -1,9 +1,11 @@
-from __future__ import unicode_literals
 from __future__ import absolute_import
-import sys
+from __future__ import unicode_literals
 
+import sys
 from inspect import getdoc
-from docopt import docopt, DocoptExit
+
+from docopt import docopt
+from docopt import DocoptExit
 
 
 def docopt_full_help(docstring, *args, **kwargs):

+ 1 - 0
compose/cli/errors.py

@@ -1,4 +1,5 @@
 from __future__ import absolute_import
+
 from textwrap import dedent
 
 

+ 3 - 1
compose/cli/formatter.py

@@ -1,6 +1,8 @@
-from __future__ import unicode_literals
 from __future__ import absolute_import
+from __future__ import unicode_literals
+
 import os
+
 import texttable
 
 

+ 3 - 3
compose/cli/log_printer.py

@@ -1,11 +1,11 @@
-from __future__ import unicode_literals
 from __future__ import absolute_import
-import sys
+from __future__ import unicode_literals
 
+import sys
 from itertools import cycle
 
-from .multiplexer import Multiplexer
 from . import colors
+from .multiplexer import Multiplexer
 from .utils import split_buffer
 
 

+ 11 - 7
compose/cli/main.py

@@ -1,28 +1,32 @@
 from __future__ import print_function
 from __future__ import unicode_literals
-from inspect import getdoc
-from operator import attrgetter
+
 import logging
 import re
 import signal
 import sys
+from inspect import getdoc
+from operator import attrgetter
 
-from docker.errors import APIError
 import dockerpty
+from docker.errors import APIError
 
 from .. import __version__
 from .. import legacy
-from ..const import DEFAULT_TIMEOUT
-from ..project import NoSuchService, ConfigurationError
-from ..service import BuildError, NeedsBuildError
 from ..config import parse_environment
+from ..const import DEFAULT_TIMEOUT
 from ..progress_stream import StreamOutputError
+from ..project import ConfigurationError
+from ..project import NoSuchService
+from ..service import BuildError
+from ..service import NeedsBuildError
 from .command import Command
 from .docopt_command import NoSuchCommand
 from .errors import UserError
 from .formatter import Formatter
 from .log_printer import LogPrinter
-from .utils import yesno, get_version_info
+from .utils import get_version_info
+from .utils import yesno
 
 log = logging.getLogger(__name__)
 console_handler = logging.StreamHandler(sys.stderr)

+ 1 - 0
compose/cli/multiplexer.py

@@ -1,4 +1,5 @@
 from __future__ import absolute_import
+
 from threading import Thread
 
 try:

+ 6 - 4
compose/cli/utils.py

@@ -1,14 +1,16 @@
-from __future__ import unicode_literals
 from __future__ import absolute_import
 from __future__ import division
+from __future__ import unicode_literals
 
-from .. import __version__
 import datetime
-from docker import version as docker_py_version
 import os
 import platform
-import subprocess
 import ssl
+import subprocess
+
+from docker import version as docker_py_version
+
+from .. import __version__
 
 
 def yesno(prompt, default=None):

+ 1 - 2
compose/cli/verbose_proxy.py

@@ -1,8 +1,7 @@
-
 import functools
-from itertools import chain
 import logging
 import pprint
+from itertools import chain
 
 import six
 

+ 9 - 10
compose/config/__init__.py

@@ -1,10 +1,9 @@
-from .config import (
-    DOCKER_CONFIG_KEYS,
-    ConfigDetails,
-    ConfigurationError,
-    find,
-    load,
-    parse_environment,
-    merge_environment,
-    get_service_name_from_net,
-)  # flake8: noqa
+# flake8: noqa
+from .config import ConfigDetails
+from .config import ConfigurationError
+from .config import DOCKER_CONFIG_KEYS
+from .config import find
+from .config import get_service_name_from_net
+from .config import load
+from .config import merge_environment
+from .config import parse_environment

+ 9 - 13
compose/config/config.py

@@ -1,23 +1,19 @@
 import logging
 import os
 import sys
-import yaml
 from collections import namedtuple
-import six
 
-from compose.cli.utils import find_candidates_in_parent_dirs
+import six
+import yaml
 
+from .errors import CircularReference
+from .errors import ComposeFileNotFound
+from .errors import ConfigurationError
 from .interpolation import interpolate_environment_variables
-from .errors import (
-    ConfigurationError,
-    CircularReference,
-    ComposeFileNotFound,
-)
-from .validation import (
-    validate_against_schema,
-    validate_service_names,
-    validate_top_level_object
-)
+from .validation import validate_against_schema
+from .validation import validate_service_names
+from .validation import validate_top_level_object
+from compose.cli.utils import find_candidates_in_parent_dirs
 
 
 DOCKER_CONFIG_KEYS = [

+ 1 - 2
compose/config/interpolation.py

@@ -1,11 +1,10 @@
+import logging
 import os
 from string import Template
 
 import six
 
 from .errors import ConfigurationError
-
-import logging
 log = logging.getLogger(__name__)
 
 

+ 5 - 3
compose/config/validation.py

@@ -1,9 +1,11 @@
-from functools import wraps
+import json
 import os
+from functools import wraps
 
 from docker.utils.ports import split_port
-import json
-from jsonschema import Draft4Validator, FormatChecker, ValidationError
+from jsonschema import Draft4Validator
+from jsonschema import FormatChecker
+from jsonschema import ValidationError
 
 from .errors import ConfigurationError
 

+ 5 - 3
compose/container.py

@@ -1,10 +1,12 @@
-from __future__ import unicode_literals
 from __future__ import absolute_import
+from __future__ import unicode_literals
 
-import six
 from functools import reduce
 
-from .const import LABEL_CONTAINER_NUMBER, LABEL_SERVICE
+import six
+
+from .const import LABEL_CONTAINER_NUMBER
+from .const import LABEL_SERVICE
 
 
 class Container(object):

+ 2 - 1
compose/legacy.py

@@ -2,7 +2,8 @@ import logging
 import re
 
 from .const import LABEL_VERSION
-from .container import get_container_name, Container
+from .container import Container
+from .container import get_container_name
 
 
 log = logging.getLogger(__name__)

+ 1 - 1
compose/progress_stream.py

@@ -1,6 +1,6 @@
+import codecs
 import json
 import os
-import codecs
 
 
 class StreamOutputError(Exception):

+ 9 - 4
compose/project.py

@@ -1,12 +1,17 @@
-from __future__ import unicode_literals
 from __future__ import absolute_import
-from functools import reduce
+from __future__ import unicode_literals
+
 import logging
+from functools import reduce
 
 from docker.errors import APIError
 
-from .config import get_service_name_from_net, ConfigurationError
-from .const import DEFAULT_TIMEOUT, LABEL_PROJECT, LABEL_SERVICE, LABEL_ONE_OFF
+from .config import ConfigurationError
+from .config import get_service_name_from_net
+from .const import DEFAULT_TIMEOUT
+from .const import LABEL_ONE_OFF
+from .const import LABEL_PROJECT
+from .const import LABEL_SERVICE
 from .container import Container
 from .legacy import check_for_legacy_containers
 from .service import Service

+ 22 - 18
compose/service.py

@@ -1,33 +1,37 @@
-from __future__ import unicode_literals
 from __future__ import absolute_import
-from collections import namedtuple
+from __future__ import unicode_literals
+
 import logging
-import re
 import os
+import re
 import sys
+from collections import namedtuple
 from operator import attrgetter
 
 import six
 from docker.errors import APIError
-from docker.utils import create_host_config, LogConfig
-from docker.utils.ports import build_port_bindings, split_port
+from docker.utils import create_host_config
+from docker.utils import LogConfig
+from docker.utils.ports import build_port_bindings
+from docker.utils.ports import split_port
 
 from . import __version__
-from .config import DOCKER_CONFIG_KEYS, merge_environment
-from .const import (
-    DEFAULT_TIMEOUT,
-    LABEL_CONTAINER_NUMBER,
-    LABEL_ONE_OFF,
-    LABEL_PROJECT,
-    LABEL_SERVICE,
-    LABEL_VERSION,
-    LABEL_CONFIG_HASH,
-)
+from .config import DOCKER_CONFIG_KEYS
+from .config import merge_environment
+from .config.validation import VALID_NAME_CHARS
+from .const import DEFAULT_TIMEOUT
+from .const import LABEL_CONFIG_HASH
+from .const import LABEL_CONTAINER_NUMBER
+from .const import LABEL_ONE_OFF
+from .const import LABEL_PROJECT
+from .const import LABEL_SERVICE
+from .const import LABEL_VERSION
 from .container import Container
 from .legacy import check_for_legacy_containers
-from .progress_stream import stream_output, StreamOutputError
-from .utils import json_hash, parallel_execute
-from .config.validation import VALID_NAME_CHARS
+from .progress_stream import stream_output
+from .progress_stream import StreamOutputError
+from .utils import json_hash
+from .utils import parallel_execute
 
 log = logging.getLogger(__name__)
 

+ 3 - 2
compose/utils.py

@@ -3,10 +3,11 @@ import hashlib
 import json
 import logging
 import sys
+from Queue import Empty
+from Queue import Queue
+from threading import Thread
 
 from docker.errors import APIError
-from Queue import Queue, Empty
-from threading import Thread
 
 
 log = logging.getLogger(__name__)

+ 6 - 6
docs/README.md

@@ -1,8 +1,8 @@
 # Contributing to the Docker Compose documentation
 
-The documentation in this directory is part of the [https://docs.docker.com](https://docs.docker.com) website.  Docker uses [the Hugo static generator](http://gohugo.io/overview/introduction/) to convert project Markdown files to a static HTML site. 
+The documentation in this directory is part of the [https://docs.docker.com](https://docs.docker.com) website.  Docker uses [the Hugo static generator](http://gohugo.io/overview/introduction/) to convert project Markdown files to a static HTML site.
 
-You don't need to be a Hugo expert to contribute to the compose documentation. If you are familiar with Markdown, you can modify the content in the `docs` files.  
+You don't need to be a Hugo expert to contribute to the compose documentation. If you are familiar with Markdown, you can modify the content in the `docs` files.
 
 If you want to add a new file or change the location of the document in the menu, you do need to know a little more.
 
@@ -23,7 +23,7 @@ If you want to add a new file or change the location of the document in the menu
         docker run --rm -it  -e AWS_S3_BUCKET -e NOCACHE -p 8000:8000 -e DOCKERHOST "docs-base:test-tooling" hugo server --port=8000 --baseUrl=192.168.59.103 --bind=0.0.0.0
         ERROR: 2015/06/13 MenuEntry's .Url is deprecated and will be removed in Hugo 0.15. Use .URL instead.
         0 of 4 drafts rendered
-        0 future content 
+        0 future content
         12 pages created
         0 paginator pages created
         0 tags created
@@ -52,7 +52,7 @@ The top of each Docker Compose documentation file contains TOML metadata. The me
     parent="smn_workw_compose"
     weight=2
     +++
-    <![end-metadata]-->  
+    <![end-metadata]-->
 
 The metadata alone has this structure:
 
@@ -64,7 +64,7 @@ The metadata alone has this structure:
     parent="smn_workw_compose"
     weight=2
     +++
-    
+
 The `[menu.main]` section refers to navigation defined [in the main Docker menu](https://github.com/docker/docs-base/blob/hugo/config.toml). This metadata says *add a menu item called* Extending services in Compose *to the menu with the* `smn_workdw_compose` *identifier*.  If you locate the menu in the configuration, you'll find *Create multi-container applications* is the menu title.
 
 You can move an article in the tree by specifying a new parent. You can shift the location of the item by changing its weight.  Higher numbers are heavier and shift the item to the bottom of menu. Low or no numbers shift it up.
@@ -73,5 +73,5 @@ You can move an article in the tree by specifying a new parent. You can shift th
 ## Other key documentation repositories
 
 The `docker/docs-base` repository contains [the Hugo theme and menu configuration](https://github.com/docker/docs-base). If you open the `Dockerfile` you'll see the `make docs` relies on this as a base image for building the Compose documentation.
-    
+
 The `docker/docs.docker.com` repository contains [build system for building the Docker documentation site](https://github.com/docker/docs.docker.com). Fork this repository to build the entire documentation site.

+ 1 - 1
docs/index.md

@@ -161,7 +161,7 @@ Now, when you run `docker-compose up`, Compose will pull a Redis image, build an
     web_1   |  * Running on http://0.0.0.0:5000/
     web_1   |  * Restarting with stat
 
-If you're using [Docker Machine](https://docs.docker.com/machine), then `docker-machine ip MACHINE_VM` will tell you its address and you can open `http://MACHINE_VM_IP:5000` in a browser. 
+If you're using [Docker Machine](https://docs.docker.com/machine), then `docker-machine ip MACHINE_VM` will tell you its address and you can open `http://MACHINE_VM_IP:5000` in a browser.
 
 If you're not using Boot2docker and are on linux, then the web app should now be listening on port 5000 on your Docker daemon host. If http://0.0.0.0:5000 doesn't resolve, you can also try localhost:5000.
 

+ 8 - 8
docs/install.md

@@ -14,7 +14,7 @@ weight=4
 
 You can run Compose on OS X and 64-bit Linux.  It is currently not supported on
 the Windows operating system. To install Compose, you'll need to install Docker
-first. 
+first.
 
 Depending on how your system is configured, you may require `sudo` access to
 install Compose. If your system requires `sudo`, you will receive "Permission
@@ -26,13 +26,13 @@ To install Compose, do the following:
 1. Install Docker Engine version 1.7.1 or greater:
 
      * <a href="https://docs.docker.com/installation/mac/" target="_blank">Mac OS X installation</a> (installs both Engine and Compose)
-     
+
      * <a href="https://docs.docker.com/installation/ubuntulinux/" target="_blank">Ubuntu installation</a>
-     
+
      * <a href="https://docs.docker.com/installation/" target="_blank">other system installations</a>
- 
+
 2. Mac OS X users are done installing. Others should continue to the next step.
-   
+
 3. Go to the <a href="https://github.com/docker/compose/releases" target="_blank">repository release page</a>.
 
 4. Enter the `curl` command in your termial.
@@ -40,9 +40,9 @@ To install Compose, do the following:
      The command has the following format:
 
         curl -L https://github.com/docker/compose/releases/download/VERSION_NUM/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
-   
+
      If you have problems installing with `curl`, you can use `pip` instead: `pip install -U docker-compose`
-      
+
 4. Apply executable permissions to the binary:
 
         $ chmod +x /usr/local/bin/docker-compose
@@ -85,7 +85,7 @@ To uninstall Docker Compose if you installed using `curl`:
 To uninstall Docker Compose if you installed using `pip`:
 
     $ pip uninstall docker-compose
-    
+
 >**Note**: If you get a "Permission denied" error using either of the above
 >methods, you probably do not have the proper permissions to remove
 >`docker-compose`.  To force the removal, prepend `sudo` to either of the above

+ 3 - 4
docs/pre-process.sh

@@ -13,7 +13,7 @@ content_dir=(`ls -d /docs/content/*`)
 # 5 Change ](word) to ](/project/word)
 # 6 Change ](../../ to ](/project/
 # 7 Change ](../ to ](/project/word)
-# 
+#
 for i in "${content_dir[@]}"
 do
    :
@@ -51,11 +51,10 @@ done
 for i in "${docker_dir[@]}"
 do
    :
-    if [ -d $i ]    
+    if [ -d $i ]
       then
-        mv $i /docs/content/ 
+        mv $i /docs/content/
       fi
 done
 
 rm -rf /docs/content/docker
-

+ 0 - 1
docs/production.md

@@ -93,4 +93,3 @@ guide</a>.
 - [Yaml file reference](yml.md)
 - [Compose environment variables](env.md)
 - [Compose command line completion](completion.md)
-

+ 1 - 1
docs/rails.md

@@ -117,7 +117,7 @@ Finally, you need to create the database. In another terminal, run:
 
     $ docker-compose run web rake db:create
 
-That's it. Your app should now be running on port 3000 on your Docker daemon. If you're using [Docker Machine](https://docs.docker.com/machine), then `docker-machine ip MACHINE_VM` returns the Docker host IP address. 
+That's it. Your app should now be running on port 3000 on your Docker daemon. If you're using [Docker Machine](https://docs.docker.com/machine), then `docker-machine ip MACHINE_VM` returns the Docker host IP address.
 
 
 ## More Compose documentation

+ 1 - 1
docs/reference/build.md

@@ -20,4 +20,4 @@ Options:
 
 Services are built once and then tagged as `project_service`, e.g.,
 `composetest_db`. If you change a service's Dockerfile or the contents of its
-build directory, run `docker-compose build` to rebuild it.
+build directory, run `docker-compose build` to rebuild it.

+ 1 - 1
docs/reference/docker-compose.md

@@ -5,7 +5,7 @@ description = "docker-compose Command Binary"
 keywords = ["fig, composition, compose, docker, orchestration, cli,  docker-compose"]
 [menu.main]
 parent = "smn_compose_cli"
-weight=-2	
+weight=-2
 +++
 <![end-metadata]-->
 

+ 3 - 3
docs/reference/index.md

@@ -5,7 +5,7 @@ description = "Compose CLI reference"
 keywords = ["fig, composition, compose, docker, orchestration, cli,  reference"]
 [menu.main]
 identifier = "smn_compose_cli"
-parent = "smn_compose_ref"	
+parent = "smn_compose_ref"
 +++
 <![end-metadata]-->
 
@@ -15,7 +15,7 @@ The following pages describe the usage information for the [docker-compose](/ref
 
 * [build](/reference/build.md)
 * [help](/reference/help.md)
-* [kill](/reference/kill.md)          
+* [kill](/reference/kill.md)
 * [ps](/reference/ps.md)
 * [restart](/reference/restart.md)
 * [run](/reference/run.md)
@@ -23,7 +23,7 @@ The following pages describe the usage information for the [docker-compose](/ref
 * [up](/reference/up.md)
 * [logs](/reference/logs.md)
 * [port](/reference/port.md)
-* [pull](/reference/pull.md) 
+* [pull](/reference/pull.md)
 * [rm](/reference/rm.md)
 * [scale](/reference/scale.md)
 * [stop](/reference/stop.md)

+ 1 - 1
docs/reference/kill.md

@@ -21,4 +21,4 @@ Options:
 Forces running containers to stop by sending a `SIGKILL` signal. Optionally the
 signal can be passed, for example:
 
-    $ docker-compose kill -s SIGINT
+    $ docker-compose kill -s SIGINT

+ 1 - 1
docs/reference/overview.md

@@ -5,7 +5,7 @@ description = "Introduction to the CLI"
 keywords = ["fig, composition, compose, docker, orchestration, cli,  reference"]
 [menu.main]
 parent = "smn_compose_cli"
-weight=-2	
+weight=-2
 +++
 <![end-metadata]-->
 

+ 1 - 1
docs/reference/port.md

@@ -20,4 +20,4 @@ Options:
                   instances of a service [default: 1]
 ```
 
-Prints the public port for a port binding.
+Prints the public port for a port binding.

+ 1 - 1
docs/reference/pull.md

@@ -15,4 +15,4 @@ parent = "smn_compose_cli"
 Usage: pull [options] [SERVICE...]
 ```
 
-Pulls service images.
+Pulls service images.

+ 1 - 5
docs/reference/run.md

@@ -27,7 +27,7 @@ Options:
 -T                    Disable pseudo-tty allocation. By default `docker-compose run` allocates a TTY.
 ```
 
-Runs a one-time command against a service. For example, the following command starts the `web` service and runs `bash` as its command. 
+Runs a one-time command against a service. For example, the following command starts the `web` service and runs `bash` as its command.
 
     $ docker-compose run web bash
 
@@ -52,7 +52,3 @@ This would open up an interactive PostgreSQL shell for the linked `db` container
 If you do not want the `run` command to start linked containers, specify the `--no-deps` flag:
 
     $ docker-compose run --no-deps web python manage.py shell
-
-
-
-

+ 1 - 1
docs/reference/scale.md

@@ -18,4 +18,4 @@ Sets the number of containers to run for a service.
 
 Numbers are specified as arguments in the form `service=num`. For example:
 
-    $ docker-compose scale web=2 worker=3
+    $ docker-compose scale web=2 worker=3

+ 3 - 3
docs/wordpress.md

@@ -13,7 +13,7 @@ weight=6
 # Quickstart Guide: Compose and Wordpress
 
 You can use Compose to easily run Wordpress in an isolated environment built
-with Docker containers. 
+with Docker containers.
 
 ## Define the project
 
@@ -36,7 +36,7 @@ your Dockerfile should be:
     ADD . /code
 
 This tells Docker how to build an image defining a container that contains PHP
-and Wordpress. 
+and Wordpress.
 
 Next you'll create a `docker-compose.yml` file that will start your web service
 and a separate MySQL instance:
@@ -108,7 +108,7 @@ Second, `router.php` tells PHP's built-in web server how to run Wordpress:
 
 With those four files in place, run `docker-compose up` inside your Wordpress
 directory and it'll pull and build the needed images, and then start the web and
-database containers. If you're using [Docker Machine](https://docs.docker.com/machine), then `docker-machine ip MACHINE_VM` gives you the machine address and you can open `http://MACHINE_VM_IP:8000` in a browser. 
+database containers. If you're using [Docker Machine](https://docs.docker.com/machine), then `docker-machine ip MACHINE_VM` gives you the machine address and you can open `http://MACHINE_VM_IP:8000` in a browser.
 
 ## More Compose documentation
 

+ 2 - 3
docs/yml.md

@@ -19,7 +19,7 @@ As with `docker run`, options specified in the Dockerfile (e.g., `CMD`,
 `EXPOSE`, `VOLUME`, `ENV`) are respected by default - you don't need to
 specify them again in `docker-compose.yml`.
 
-Values for configuration options can contain environment variables, e.g. 
+Values for configuration options can contain environment variables, e.g.
 `image: postgres:${POSTGRES_VERSION}`. For more details, see the section on
 [variable substitution](#variable-substitution).
 
@@ -353,7 +353,7 @@ Custom DNS search domains. Can be a single value or a list.
 
 ### devices
 
-List of device mappings.  Uses the same format as the `--device` docker 
+List of device mappings.  Uses the same format as the `--device` docker
 client create option.
 
     devices:
@@ -433,4 +433,3 @@ dollar sign (`$$`).
 - [Command line reference](/reference)
 - [Compose environment variables](env.md)
 - [Compose command line completion](completion.md)
-

+ 4 - 4
requirements-dev.txt

@@ -1,7 +1,7 @@
+coverage==3.7.1
+flake8==2.3.0
+git+https://github.com/pyinstaller/pyinstaller.git@12e40471c77f588ea5be352f7219c873ddaae056#egg=pyinstaller
 mock >= 1.0.1
 nose==1.3.4
-git+https://github.com/pyinstaller/pyinstaller.git@12e40471c77f588ea5be352f7219c873ddaae056#egg=pyinstaller
-unittest2==0.8.0
-flake8==2.3.0
 pep8==1.6.1
-coverage==3.7.1
+unittest2==0.8.0

+ 1 - 1
requirements.txt

@@ -1,8 +1,8 @@
 PyYAML==3.10
-jsonschema==2.5.1
 docker-py==1.3.1
 dockerpty==0.3.4
 docopt==0.6.1
+jsonschema==2.5.1
 requests==2.6.1
 six==1.7.3
 texttable==0.8.2

+ 1 - 1
script/test-versions

@@ -5,7 +5,7 @@
 set -e
 
 >&2 echo "Running lint checks"
-flake8 compose tests setup.py
+tox -e pre-commit
 
 if [ "$DOCKER_VERSIONS" == "" ]; then
   DOCKER_VERSIONS="default"

+ 5 - 2
setup.py

@@ -1,13 +1,16 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
-from __future__ import unicode_literals
 from __future__ import absolute_import
-from setuptools import setup, find_packages
+from __future__ import unicode_literals
+
 import codecs
 import os
 import re
 import sys
 
+from setuptools import find_packages
+from setuptools import setup
+
 
 def read(*parts):
     path = os.path.join(os.path.dirname(__file__), *parts)

+ 1 - 1
tests/fixtures/extends/nonexistent-path-base.yml

@@ -3,4 +3,4 @@ dnebase:
   command: /bin/true
   environment:
     - FOO=1
-    - BAR=1
+    - BAR=1

+ 1 - 1
tests/fixtures/extends/nonexistent-path-child.yml

@@ -5,4 +5,4 @@ dnechild:
   image: busybox
   command: /bin/true
   environment:
-    - BAR=2
+    - BAR=2

+ 1 - 1
tests/fixtures/longer-filename-composefile/docker-compose.yaml

@@ -1,3 +1,3 @@
 definedinyamlnotyml:
   image: busybox:latest
-  command: top
+  command: top

+ 5 - 4
tests/integration/cli_test.py

@@ -1,15 +1,16 @@
 from __future__ import absolute_import
-from operator import attrgetter
-import sys
+
 import os
 import shlex
+import sys
+from operator import attrgetter
 
-from six import StringIO
 from mock import patch
+from six import StringIO
 
 from .testcases import DockerClientTestCase
-from compose.cli.main import TopLevelCommand
 from compose.cli.errors import UserError
+from compose.cli.main import TopLevelCommand
 from compose.project import NoSuchService
 
 

+ 2 - 2
tests/integration/legacy_test.py

@@ -1,11 +1,11 @@
 import unittest
-from mock import Mock
 
 from docker.errors import APIError
+from mock import Mock
 
+from .testcases import DockerClientTestCase
 from compose import legacy
 from compose.project import Project
-from .testcases import DockerClientTestCase
 
 
 class UtilitiesTestCase(unittest.TestCase):

+ 2 - 2
tests/integration/project_test.py

@@ -1,10 +1,10 @@
 from __future__ import unicode_literals
 
+from .testcases import DockerClientTestCase
 from compose import config
 from compose.const import LABEL_PROJECT
-from compose.project import Project
 from compose.container import Container
-from .testcases import DockerClientTestCase
+from compose.project import Project
 
 
 def build_service_dicts(service_config):

+ 2 - 2
tests/integration/resilience_test.py

@@ -1,10 +1,10 @@
-from __future__ import unicode_literals
 from __future__ import absolute_import
+from __future__ import unicode_literals
 
 import mock
 
-from compose.project import Project
 from .testcases import DockerClientTestCase
+from compose.project import Project
 
 
 class ResilienceTest(DockerClientTestCase):

+ 16 - 18
tests/integration/service_test.py

@@ -1,30 +1,28 @@
-from __future__ import unicode_literals
 from __future__ import absolute_import
+from __future__ import unicode_literals
+
 import os
+import shutil
+import tempfile
 from os import path
 
 from docker.errors import APIError
 from mock import patch
-import tempfile
-import shutil
-from six import StringIO, text_type
+from six import StringIO
+from six import text_type
 
+from .testcases import DockerClientTestCase
 from compose import __version__
-from compose.const import (
-    LABEL_CONTAINER_NUMBER,
-    LABEL_ONE_OFF,
-    LABEL_PROJECT,
-    LABEL_SERVICE,
-    LABEL_VERSION,
-)
-from compose.service import (
-    ConfigError,
-    ConvergencePlan,
-    Service,
-    build_extra_hosts,
-)
+from compose.const import LABEL_CONTAINER_NUMBER
+from compose.const import LABEL_ONE_OFF
+from compose.const import LABEL_PROJECT
+from compose.const import LABEL_SERVICE
+from compose.const import LABEL_VERSION
 from compose.container import Container
-from .testcases import DockerClientTestCase
+from compose.service import build_extra_hosts
+from compose.service import ConfigError
+from compose.service import ConvergencePlan
+from compose.service import Service
 
 
 def create_and_start_container(service, **override_options):

+ 5 - 5
tests/integration/state_test.py

@@ -1,13 +1,13 @@
 from __future__ import unicode_literals
-import tempfile
-import shutil
+
 import os
+import shutil
+import tempfile
 
+from .testcases import DockerClientTestCase
 from compose import config
-from compose.project import Project
 from compose.const import LABEL_CONFIG_HASH
-
-from .testcases import DockerClientTestCase
+from compose.project import Project
 
 
 class ProjectTestCase(DockerClientTestCase):

+ 5 - 4
tests/integration/testcases.py

@@ -1,11 +1,12 @@
-from __future__ import unicode_literals
 from __future__ import absolute_import
-from compose.service import Service
+from __future__ import unicode_literals
+
+from .. import unittest
+from compose.cli.docker_client import docker_client
 from compose.config.config import ServiceLoader
 from compose.const import LABEL_PROJECT
-from compose.cli.docker_client import docker_client
 from compose.progress_stream import stream_output
-from .. import unittest
+from compose.service import Service
 
 
 class DockerClientTestCase(unittest.TestCase):

+ 3 - 2
tests/unit/cli/docker_client_test.py

@@ -1,11 +1,12 @@
-from __future__ import unicode_literals
 from __future__ import absolute_import
+from __future__ import unicode_literals
+
 import os
 
 import mock
-from tests import unittest
 
 from compose.cli import docker_client
+from tests import unittest
 
 
 class DockerClientTestCase(unittest.TestCase):

+ 2 - 2
tests/unit/cli/verbose_proxy_test.py

@@ -1,8 +1,8 @@
-from __future__ import unicode_literals
 from __future__ import absolute_import
-from tests import unittest
+from __future__ import unicode_literals
 
 from compose.cli import verbose_proxy
+from tests import unittest
 
 
 class VerboseProxyTestCase(unittest.TestCase):

+ 3 - 2
tests/unit/cli_test.py

@@ -1,11 +1,12 @@
-from __future__ import unicode_literals
 from __future__ import absolute_import
+from __future__ import unicode_literals
+
 import os
-from .. import unittest
 
 import docker
 import mock
 
+from .. import unittest
 from compose.cli.docopt_command import NoSuchCommand
 from compose.cli.errors import UserError
 from compose.cli.main import TopLevelCommand

+ 3 - 2
tests/unit/config_test.py

@@ -1,9 +1,10 @@
-import mock
 import os
 import shutil
 import tempfile
-from .. import unittest
 
+import mock
+
+from .. import unittest
 from compose.config import config
 from compose.config.errors import ConfigurationError
 

+ 2 - 2
tests/unit/container_test.py

@@ -1,9 +1,9 @@
 from __future__ import unicode_literals
-from .. import unittest
 
-import mock
 import docker
+import mock
 
+from .. import unittest
 from compose.container import Container
 from compose.container import get_container_name
 

+ 2 - 1
tests/unit/interpolation_test.py

@@ -1,7 +1,8 @@
 import unittest
 
-from compose.config.interpolation import interpolate, InvalidInterpolation
 from compose.config.interpolation import BlankDefaultDict as bddict
+from compose.config.interpolation import interpolate
+from compose.config.interpolation import InvalidInterpolation
 
 
 class InterpolationTest(unittest.TestCase):

+ 3 - 2
tests/unit/log_printer_test.py

@@ -1,9 +1,10 @@
-from __future__ import unicode_literals
 from __future__ import absolute_import
+from __future__ import unicode_literals
+
 import os
 
-from compose.cli.log_printer import LogPrinter
 from .. import unittest
+from compose.cli.log_printer import LogPrinter
 
 
 class LogPrinterTest(unittest.TestCase):

+ 2 - 2
tests/unit/progress_stream_test.py

@@ -1,10 +1,10 @@
-from __future__ import unicode_literals
 from __future__ import absolute_import
-from tests import unittest
+from __future__ import unicode_literals
 
 from six import StringIO
 
 from compose import progress_stream
+from tests import unittest
 
 
 class ProgressStreamTestCase(unittest.TestCase):

+ 7 - 6
tests/unit/project_test.py

@@ -1,12 +1,13 @@
 from __future__ import unicode_literals
-from .. import unittest
-from compose.service import Service
-from compose.project import Project
-from compose.container import Container
-from compose.const import LABEL_SERVICE
 
-import mock
 import docker
+import mock
+
+from .. import unittest
+from compose.const import LABEL_SERVICE
+from compose.container import Container
+from compose.project import Project
+from compose.service import Service
 
 
 class ProjectTest(unittest.TestCase):

+ 15 - 16
tests/unit/service_test.py

@@ -1,25 +1,24 @@
-from __future__ import unicode_literals
 from __future__ import absolute_import
-
-from .. import unittest
-import mock
+from __future__ import unicode_literals
 
 import docker
+import mock
 from docker.utils import LogConfig
 
-from compose.service import Service
+from .. import unittest
+from compose.const import LABEL_ONE_OFF
+from compose.const import LABEL_PROJECT
+from compose.const import LABEL_SERVICE
 from compose.container import Container
-from compose.const import LABEL_SERVICE, LABEL_PROJECT, LABEL_ONE_OFF
-from compose.service import (
-    ConfigError,
-    NeedsBuildError,
-    NoSuchImageError,
-    build_volume_binding,
-    get_container_data_volumes,
-    merge_volume_bindings,
-    parse_repository_tag,
-    parse_volume_spec,
-)
+from compose.service import build_volume_binding
+from compose.service import ConfigError
+from compose.service import get_container_data_volumes
+from compose.service import merge_volume_bindings
+from compose.service import NeedsBuildError
+from compose.service import NoSuchImageError
+from compose.service import parse_repository_tag
+from compose.service import parse_volume_spec
+from compose.service import Service
 
 
 class ServiceTest(unittest.TestCase):

+ 2 - 1
tests/unit/sort_service_test.py

@@ -1,5 +1,6 @@
-from compose.project import sort_service_dicts, DependencyError
 from .. import unittest
+from compose.project import DependencyError
+from compose.project import sort_service_dicts
 
 
 class SortServiceTest(unittest.TestCase):

+ 3 - 2
tests/unit/split_buffer_test.py

@@ -1,7 +1,8 @@
-from __future__ import unicode_literals
 from __future__ import absolute_import
-from compose.cli.utils import split_buffer
+from __future__ import unicode_literals
+
 from .. import unittest
+from compose.cli.utils import split_buffer
 
 
 class SplitBufferTest(unittest.TestCase):

+ 11 - 1
tox.ini

@@ -1,8 +1,10 @@
 [tox]
-envlist = py26,py27
+envlist = py27,pre-commit
 
 [testenv]
 usedevelop=True
+passenv =
+    LD_LIBRARY_PATH
 deps =
     -rrequirements.txt
     -rrequirements-dev.txt
@@ -10,6 +12,14 @@ commands =
     nosetests -v {posargs}
     flake8 compose tests setup.py
 
+[testenv:pre-commit]
+skip_install = True
+deps =
+    pre-commit
+commands =
+    pre-commit install
+    pre-commit run --all-files
+
 [flake8]
 # ignore line-length for now
 ignore = E501,E203