Skip to content

Commit 8f1793d

Browse files
committed
Merge pull request #186 from orchardup/update-docker-py-7f55a101f813f3e96413d1b577e98d9467b0bffc
WIP: Docker >=0.9 support, docker-py 0.3.1
2 parents 2495920 + fd85be2 commit 8f1793d

29 files changed

Lines changed: 588 additions & 418 deletions

.travis.yml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,22 @@ python:
33
- '2.6'
44
- '2.7'
55
env:
6-
- DOCKER_VERSION=0.8.0
7-
- DOCKER_VERSION=0.8.1
8-
matrix:
9-
allow_failures:
10-
- python: '3.2'
11-
- python: '3.3'
12-
install: script/travis-install
6+
global:
7+
- secure: exbot0LTV/0Wic6ElKCrOZmh2ZrieuGwEqfYKf5rVuwu1sLngYRihh+lBL/hTwc79NSu829pbwiWfsQZrXbk/yvaS7avGR0CLDoipyPxlYa2/rfs/o4OdTZqXv0LcFmmd54j5QBMpWU1S+CYOwNkwas57trrvIpPbzWjMtfYzOU=
8+
install:
9+
- pip install .
10+
- pip install -r requirements.txt
11+
- pip install -r requirements-dev.txt
12+
- sudo curl -L -o /usr/local/bin/orchard https://github.com/orchardup/go-orchard/releases/download/2.0.5/linux
13+
- sudo chmod +x /usr/local/bin/orchard
14+
before_script:
15+
- '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && orchard hosts rm -f $TRAVIS_JOB_ID'
16+
- '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && orchard hosts create $TRAVIS_JOB_ID || false'
1317
script:
14-
- pwd
15-
- env
16-
- sekexe/run "`pwd`/script/travis $TRAVIS_PYTHON_VERSION"
18+
- nosetests tests/unit
19+
- '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && script/travis-integration || false'
20+
after_script:
21+
- '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && orchard hosts rm -f $TRAVIS_JOB_ID || false'
1722
deploy:
1823
provider: pypi
1924
user: orchard

docs/install.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ title: Installing Fig
66
Installing Fig
77
==============
88

9-
First, install Docker (version 0.8 or higher). If you're on OS X, you can use [docker-osx](https://github.com/noplay/docker-osx):
9+
First, install Docker version 0.10.0. If you're on OS X, you can use [docker-osx](https://github.com/noplay/docker-osx):
1010

11-
$ curl https://raw.github.com/noplay/docker-osx/0.8.0/docker-osx > /usr/local/bin/docker-osx
11+
$ curl https://raw.github.com/noplay/docker-osx/0.10.0/docker-osx > /usr/local/bin/docker-osx
1212
$ chmod +x /usr/local/bin/docker-osx
1313
$ docker-osx shell
1414

fig/cli/main.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from .log_printer import LogPrinter
1616
from .utils import yesno
1717

18-
from ..packages.docker.client import APIError
18+
from ..packages.docker.errors import APIError
1919
from .errors import UserError
2020
from .docopt_command import NoSuchCommand
2121
from .socketclient import SocketClient
@@ -301,10 +301,9 @@ def up(self, options):
301301
"""
302302
detached = options['-d']
303303

304-
new = self.project.up(service_names=options['SERVICE'])
304+
to_attach = self.project.up(service_names=options['SERVICE'])
305305

306306
if not detached:
307-
to_attach = [c for (s, c) in new]
308307
print("Attaching to", list_containers(to_attach))
309308
log_printer = LogPrinter(to_attach, attach_params={"logs": True})
310309

fig/packages/docker/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from .client import Client, APIError # flake8: noqa
15+
__title__ = 'docker-py'
16+
__version__ = '0.3.0'
17+
18+
from .client import Client # flake8: noqa

fig/packages/docker/auth/auth.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from fig.packages import six
2121

2222
from ..utils import utils
23+
from .. import errors
2324

2425
INDEX_URL = 'https://index.docker.io/v1/'
2526
DOCKER_CONFIG_FILENAME = '.dockercfg'
@@ -45,18 +46,19 @@ def expand_registry_url(hostname):
4546

4647
def resolve_repository_name(repo_name):
4748
if '://' in repo_name:
48-
raise ValueError('Repository name cannot contain a '
49-
'scheme ({0})'.format(repo_name))
49+
raise errors.InvalidRepository(
50+
'Repository name cannot contain a scheme ({0})'.format(repo_name))
5051
parts = repo_name.split('/', 1)
51-
if not '.' in parts[0] and not ':' in parts[0] and parts[0] != 'localhost':
52+
if '.' not in parts[0] and ':' not in parts[0] and parts[0] != 'localhost':
5253
# This is a docker index repo (ex: foo/bar or ubuntu)
5354
return INDEX_URL, repo_name
5455
if len(parts) < 2:
55-
raise ValueError('Invalid repository name ({0})'.format(repo_name))
56+
raise errors.InvalidRepository(
57+
'Invalid repository name ({0})'.format(repo_name))
5658

5759
if 'index.docker.io' in parts[0]:
58-
raise ValueError('Invalid repository name,'
59-
'try "{0}" instead'.format(parts[1]))
60+
raise errors.InvalidRepository(
61+
'Invalid repository name, try "{0}" instead'.format(parts[1]))
6062

6163
return expand_registry_url(parts[0]), parts[1]
6264

@@ -87,6 +89,11 @@ def resolve_authconfig(authconfig, registry=None):
8789
return authconfig.get(swap_protocol(registry), None)
8890

8991

92+
def encode_auth(auth_info):
93+
return base64.b64encode(auth_info.get('username', '') + b':' +
94+
auth_info.get('password', ''))
95+
96+
9097
def decode_auth(auth):
9198
if isinstance(auth, six.string_types):
9299
auth = auth.encode('ascii')
@@ -100,6 +107,12 @@ def encode_header(auth):
100107
return base64.b64encode(auth_json)
101108

102109

110+
def encode_full_header(auth):
111+
""" Returns the given auth block encoded for the X-Registry-Config header.
112+
"""
113+
return encode_header({'configs': auth})
114+
115+
103116
def load_config(root=None):
104117
"""Loads authentication data from a Docker configuration file in the given
105118
root directory."""
@@ -136,7 +149,8 @@ def load_config(root=None):
136149
data.append(line.strip().split(' = ')[1])
137150
if len(data) < 2:
138151
# Not enough data
139-
raise Exception('Invalid or empty configuration file!')
152+
raise errors.InvalidConfigFile(
153+
'Invalid or empty configuration file!')
140154

141155
username, password = decode_auth(data[0])
142156
conf[INDEX_URL] = {

0 commit comments

Comments
 (0)