From e335b1463d32d84450b6f3808816a081d3238b14 Mon Sep 17 00:00:00 2001 From: Jiangge Zhang Date: Mon, 2 Feb 2015 01:08:05 +0800 Subject: [PATCH 01/14] fix up the wrong description for DOCKER_TLS_CERT. --- docs/index.rst | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index 9fe9396..6592eb8 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -76,8 +76,8 @@ to the Docker server. certificate. Because the client certificate have two files (a public and a private), this configuration value - should be a tuple of their path. (e.g. - ``('/path/to/cert.pem', '/path/to/key.pem')``) + should be a colon-separated tuple of their path. + (e.g. ``"/path/to/cert.pem:/path/to/key.pem"``) This defaults to ``None``. `DOCKER_TLS_CA_CERT` The file path to the CA certificate. It is usually be used with a self-signed @@ -86,9 +86,8 @@ to the Docker server. `DOCKER_TLS_CERT_PATH` This defaults to ``None``. Once it be specified, The default value of `DOCKER_TLS_CLIENT_CERT` and `DOCKER_TLS_CA_CERT` will be filled to - ``("{DOCKER_TLS_CERT_PATH}/cert.pem", - "{DOCKER_TLS_CERT_PATH}/key.pem")`` and - ``"{DOCKER_TLS_CERT_PATH}/ca.pem"`` instead of + ``"{0}/cert.pem:{0}/key.pem"`` and + ``"{0}/ca.pem"`` instead of ``None``. It is usually be used with boot2docker_. ============================ ================================================== From 923b74a888a1ae6a8a29e4be5ea14ab834a7eaba Mon Sep 17 00:00:00 2001 From: Jiangge Zhang Date: Mon, 2 Feb 2015 11:13:10 +0800 Subject: [PATCH 02/14] fix up documents. --- README.rst | 4 ++-- docs/index.rst | 3 +-- setup.py | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index 4b0142b..056beb7 100644 --- a/README.rst +++ b/README.rst @@ -3,8 +3,8 @@ Flask-Docker ============ -Flask-Docker is an extension for Flask_ that integrates a Docker_ client into -your application. It is based on the official docker-py_. +Flask-Docker is an extension for Flask_ that integrates Docker_ client into +your application. It is based on the official client docker-py_. .. _Flask: http://flask.pocoo.org .. _Docker: https://www.docker.com diff --git a/docs/index.rst b/docs/index.rst index 6592eb8..e9fde9e 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -19,7 +19,7 @@ Installation Configuration ------------- -You can configure it like mostly extensions of Flask. +You can configure it like most extensions of Flask. For single file applications: @@ -52,7 +52,6 @@ For large applications which following the application factory pattern: The Flask-Docker has some configuration values that describes how to connect to the Docker server. - ============================ ================================================== `DOCKER_URL` The URL of Docker server. **REQUIRED** `DOCKER_VERSION` The API version of Docker server. diff --git a/setup.py b/setup.py index 5ed1f4f..814b2cb 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ setup( name='Flask-Docker', - description='Uses Docker client in your Flask application.', + description='Using Docker client in your Flask application.', long_description=long_description, version='0.1.0', author='Jiangge Zhang', From 176bff34a91df16576535b5901fc98d869331a46 Mon Sep 17 00:00:00 2001 From: Jiangge Zhang Date: Mon, 8 Jun 2015 04:13:31 +0800 Subject: [PATCH 03/14] use shields.io instead of pypip.in --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 056beb7..fa1631f 100644 --- a/README.rst +++ b/README.rst @@ -40,7 +40,7 @@ You can send a pull reueqst on .. |Coverage Status| image:: https://img.shields.io/coveralls/tonyseek/flask-docker.svg?style=flat :target: https://coveralls.io/r/tonyseek/flask-docker :alt: Coverage Status -.. |Wheel Status| image:: https://pypip.in/wheel/Flask-Docker/badge.svg?style=flat +.. |Wheel Status| image:: https://img.shields.io/pypi/wheel/Flask-Docker.svg?style=flat :target: https://warehouse.python.org/project/Flask-Docker :alt: Wheel Status .. |PyPI Version| image:: https://img.shields.io/pypi/v/Flask-Docker.svg?style=flat From e17e534349cf2ae62c60803b39605db515fb15bb Mon Sep 17 00:00:00 2001 From: Jiangge Zhang Date: Mon, 8 Jun 2015 04:27:43 +0800 Subject: [PATCH 04/14] add pypi classifiers for python implementation support. --- setup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.py b/setup.py index 814b2cb..631783f 100644 --- a/setup.py +++ b/setup.py @@ -29,6 +29,8 @@ 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: Implementation :: CPython', + 'Programming Language :: Python :: Implementation :: PyPy', 'Topic :: Software Development :: Libraries', 'Topic :: Utilities', ], From d86eca94ef1b250e7250856fddc581e816ba98b7 Mon Sep 17 00:00:00 2001 From: Jiangge Zhang Date: Mon, 8 Jun 2015 04:31:42 +0800 Subject: [PATCH 05/14] add more badges. --- README.rst | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index fa1631f..6acf63e 100644 --- a/README.rst +++ b/README.rst @@ -1,4 +1,4 @@ -|Build Status| |Coverage Status| |PyPI Version| |Wheel Status| +|Build Status| |Coverage Status| |PyPI Version| |PyPI Status| |Wheel Status| |Python Versions| |Python Implementations| Flask-Docker ============ @@ -46,3 +46,8 @@ You can send a pull reueqst on .. |PyPI Version| image:: https://img.shields.io/pypi/v/Flask-Docker.svg?style=flat :target: https://pypi.python.org/pypi/Flask-Docker :alt: PyPI Version +.. |PyPI Status| image:: https://img.shields.io/pypi/status/Flask-Docker.svg?style=flat + :target: https://pypi.python.org/pypi/Flask-Docker + :alt: PyPI Version +.. |Python Versions| image:: https://img.shields.io/pypi/pyversions/Flask-Docker.svg?style=flat +.. |Python Implementations| image:: https://img.shields.io/pypi/implementation/Flask-Docker.svg?style=flat From cb440a02366353c70ae95d632217f7eff332f45d Mon Sep 17 00:00:00 2001 From: Jiangge Zhang Date: Mon, 8 Jun 2015 04:33:06 +0800 Subject: [PATCH 06/14] break lines for badges. --- README.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 6acf63e..0347480 100644 --- a/README.rst +++ b/README.rst @@ -1,4 +1,6 @@ -|Build Status| |Coverage Status| |PyPI Version| |PyPI Status| |Wheel Status| |Python Versions| |Python Implementations| +|Build Status| |Coverage Status| |PyPI Version| |PyPI Status| |Wheel Status| + +|Python Versions| |Python Implementations| Flask-Docker ============ From 82062391ce817746df88111e3bdf33769e9ef032 Mon Sep 17 00:00:00 2001 From: Jiangge Zhang Date: Mon, 8 Jun 2015 11:58:21 +0800 Subject: [PATCH 07/14] reduce badges (finished the testing for shields.io) --- README.rst | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/README.rst b/README.rst index 0347480..fa1631f 100644 --- a/README.rst +++ b/README.rst @@ -1,6 +1,4 @@ -|Build Status| |Coverage Status| |PyPI Version| |PyPI Status| |Wheel Status| - -|Python Versions| |Python Implementations| +|Build Status| |Coverage Status| |PyPI Version| |Wheel Status| Flask-Docker ============ @@ -48,8 +46,3 @@ You can send a pull reueqst on .. |PyPI Version| image:: https://img.shields.io/pypi/v/Flask-Docker.svg?style=flat :target: https://pypi.python.org/pypi/Flask-Docker :alt: PyPI Version -.. |PyPI Status| image:: https://img.shields.io/pypi/status/Flask-Docker.svg?style=flat - :target: https://pypi.python.org/pypi/Flask-Docker - :alt: PyPI Version -.. |Python Versions| image:: https://img.shields.io/pypi/pyversions/Flask-Docker.svg?style=flat -.. |Python Implementations| image:: https://img.shields.io/pypi/implementation/Flask-Docker.svg?style=flat From 755491a53fcafc07d1a737733a358b1843baadab Mon Sep 17 00:00:00 2001 From: Jiangge Zhang Date: Mon, 8 Jun 2015 12:00:36 +0800 Subject: [PATCH 08/14] add docs link to README. --- README.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.rst b/README.rst index fa1631f..2ddc1bf 100644 --- a/README.rst +++ b/README.rst @@ -6,9 +6,12 @@ Flask-Docker Flask-Docker is an extension for Flask_ that integrates Docker_ client into your application. It is based on the official client docker-py_. +The document is in ReadTheDocs_. + .. _Flask: http://flask.pocoo.org .. _Docker: https://www.docker.com .. _docker-py: https://github.com/docker/docker-py#readme +.. _ReadTheDocs: https://flask-docker.readthedocs.org Installation From 17a4a6503039f9ae580e8297553ebe8c5bdaaf94 Mon Sep 17 00:00:00 2001 From: Jiangge Zhang Date: Mon, 8 Jun 2015 12:05:39 +0800 Subject: [PATCH 09/14] add zip_safe=False flag to setup.py --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 631783f..3a356b5 100644 --- a/setup.py +++ b/setup.py @@ -34,6 +34,7 @@ 'Topic :: Software Development :: Libraries', 'Topic :: Utilities', ], + zip_safe=False, py_modules=['flask_docker'], install_requires=['flask', 'docker-py'], platforms=['Any']) From 6e5c0691b05544c12fd091e19e6921f870e296c7 Mon Sep 17 00:00:00 2001 From: Jiangge Zhang Date: Mon, 8 Jun 2015 12:09:51 +0800 Subject: [PATCH 10/14] self.app always exists. (point to current_app in app-factory usage) --- flask_docker.py | 22 +++++++++++----------- tests/test_factory.py | 29 ++++++++++++++++++----------- tests/test_simple.py | 3 ++- 3 files changed, 31 insertions(+), 23 deletions(-) diff --git a/flask_docker.py b/flask_docker.py index b62753a..58ae326 100644 --- a/flask_docker.py +++ b/flask_docker.py @@ -17,7 +17,9 @@ class Docker(object): """ def __init__(self, app=None): - if app: + if app is None: + self.app = current_app + else: self.app = app self.init_app(app) @@ -49,18 +51,16 @@ def client(self): docker.create_container('ubuntu') docker.client.create_container('ubuntu') # equivalent """ - app = getattr(self, 'app', current_app) - - if not app.config['DOCKER_URL']: + if not self.app.config['DOCKER_URL']: raise RuntimeError('"DOCKER_URL" must be specified') - if not app.extensions['docker.client']: - app.extensions['docker.client'] = Client( - base_url=app.config['DOCKER_URL'], - version=app.config['DOCKER_VERSION'], - timeout=app.config['DOCKER_TIMEOUT'], - tls=make_tls_config(app.config)) - return app.extensions['docker.client'] + if not self.app.extensions['docker.client']: + self.app.extensions['docker.client'] = Client( + base_url=self.app.config['DOCKER_URL'], + version=self.app.config['DOCKER_VERSION'], + timeout=self.app.config['DOCKER_TIMEOUT'], + tls=make_tls_config(self.app.config)) + return self.app.extensions['docker.client'] def __getattr__(self, name): if name != 'app' and hasattr(self.client, name): diff --git a/tests/test_factory.py b/tests/test_factory.py index b59f0da..30f22f2 100644 --- a/tests/test_factory.py +++ b/tests/test_factory.py @@ -1,4 +1,4 @@ -from flask import Flask +from flask import Flask, current_app from flask_docker import Docker from pytest import fixture, raises import responses @@ -14,7 +14,7 @@ def create_app(): @fixture -def current_app(request): +def app(request): app = create_app() ctx = app.app_context() ctx.push() @@ -23,42 +23,49 @@ def current_app(request): def test_factory(): - assert not hasattr(docker, 'app') + assert docker.app is current_app def test_out_of_context(): + docker.app # nothing raises + + # but if we... + with raises(RuntimeError) as error: + docker.app.name + assert error.value.args[0] == 'working outside of application context' + with raises(RuntimeError) as error: docker.client assert error.value.args[0] == 'working outside of application context' -def test_url_missing(current_app): +def test_url_missing(app): with raises(RuntimeError) as error: docker.client assert error.value.args[0] == '"DOCKER_URL" must be specified' @responses.activate -def test_versioned(current_app): +def test_versioned(app): responses.add( responses.GET, 'http://docker-testing:2375/v1.11/info', body='{"message": "Yo! Gotcha."}', status=200, content_type='application/json') - current_app.config['DOCKER_URL'] = 'http://docker-testing:2375' - current_app.config['DOCKER_VERSION'] = '1.11' + app.config['DOCKER_URL'] = 'http://docker-testing:2375' + app.config['DOCKER_VERSION'] = '1.11' assert docker.client.info() == {'message': 'Yo! Gotcha.'} -def test_lazy_creation(current_app): - current_app.config['DOCKER_URL'] = 'http://docker-testing:2375' +def test_lazy_creation(app): + app.config['DOCKER_URL'] = 'http://docker-testing:2375' - assert current_app.extensions['docker.client'] is None + assert app.extensions['docker.client'] is None client1 = docker.client client2 = docker.client - assert current_app.extensions['docker.client'] is client1 is client2 + assert app.extensions['docker.client'] is client1 is client2 def test_isolation(): diff --git a/tests/test_simple.py b/tests/test_simple.py index 042bdb1..4215276 100644 --- a/tests/test_simple.py +++ b/tests/test_simple.py @@ -1,4 +1,4 @@ -from flask import Flask +from flask import Flask, current_app from flask_docker import Docker from pytest import fixture, raises import responses @@ -13,6 +13,7 @@ def docker(): def test_singleton(docker): assert docker.app + assert docker.app is not current_app def test_url_missing(docker): From de27563b302d13503f6f2ffb6b04c1142c679ee5 Mon Sep 17 00:00:00 2001 From: Jiangge Zhang Date: Mon, 8 Jun 2015 14:33:53 +0800 Subject: [PATCH 11/14] add changelog to docs. --- CHANGELOG.rst | 14 ++++++++++++++ README.rst | 5 +++-- docs/index.rst | 2 ++ 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 CHANGELOG.rst diff --git a/CHANGELOG.rst b/CHANGELOG.rst new file mode 100644 index 0000000..b97b4b4 --- /dev/null +++ b/CHANGELOG.rst @@ -0,0 +1,14 @@ +Changelog +--------- + +0.2.0 - Unreleased +~~~~~~~~~~~~~~~~~~ + +* Make ``app`` attribute always be accessible in :class:`flask_docker.Docker`. +* Add ``zip_safe=False`` flag to ``setup.py``. +* Fix some description in the document. + +0.1.0 - 2015-02-01 +~~~~~~~~~~~~~~~~~~ + +* Initial release. diff --git a/README.rst b/README.rst index 2ddc1bf..42a7891 100644 --- a/README.rst +++ b/README.rst @@ -6,11 +6,12 @@ Flask-Docker Flask-Docker is an extension for Flask_ that integrates Docker_ client into your application. It is based on the official client docker-py_. -The document is in ReadTheDocs_. - .. _Flask: http://flask.pocoo.org .. _Docker: https://www.docker.com .. _docker-py: https://github.com/docker/docker-py#readme + +The document is in ReadTheDocs_. + .. _ReadTheDocs: https://flask-docker.readthedocs.org diff --git a/docs/index.rst b/docs/index.rst index e9fde9e..c60cc5b 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -144,3 +144,5 @@ API Reference .. autoclass:: flask_docker.Docker :members: + +.. include:: ../CHANGELOG.rst From d09b544620798a3927ef92a257d314799557651a Mon Sep 17 00:00:00 2001 From: Jiangge Zhang Date: Mon, 8 Jun 2015 14:34:15 +0800 Subject: [PATCH 12/14] add docs to tox. --- tox.ini | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 8d0ab53..44b8b48 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,py33,py34,pypy +envlist = py27,py33,py34,pypy,docs [testenv] deps = setuptools>=12.0 @@ -10,3 +10,11 @@ deps = responses commands = py.test +[testenv:docs] +changedir = docs +deps = + --requirement=docs/requirements.txt +whitelist_externals = + make +commands = + make html From 5647deaee3baaf72ec1445e9ac36020fa5c17749 Mon Sep 17 00:00:00 2001 From: Jiangge Zhang Date: Mon, 8 Jun 2015 13:59:33 +0800 Subject: [PATCH 13/14] =?UTF-8?q?Bump=20version:=200.1.0=20=E2=86=92=200.2?= =?UTF-8?q?.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .bumpversion.cfg | 2 +- docs/conf.py | 4 ++-- flask_docker.py | 2 +- setup.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index df3d3b6..fc03de0 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.1.0 +current_version = 0.2.0 files = setup.py flask_docker.py docs/conf.py commit = True tag = False diff --git a/docs/conf.py b/docs/conf.py index 821a154..5ce7ccd 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -55,9 +55,9 @@ # built documents. # # The short X.Y version. -version = '0.1.0' +version = '0.2.0' # The full version, including alpha/beta/rc tags. -release = '0.1.0' +release = '0.2.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/flask_docker.py b/flask_docker.py index 58ae326..ca2506c 100644 --- a/flask_docker.py +++ b/flask_docker.py @@ -6,7 +6,7 @@ __all__ = ['Docker'] -__version__ = '0.1.0' +__version__ = '0.2.0' class Docker(object): diff --git a/setup.py b/setup.py index 3a356b5..32dd76e 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ name='Flask-Docker', description='Using Docker client in your Flask application.', long_description=long_description, - version='0.1.0', + version='0.2.0', author='Jiangge Zhang', author_email='tonyseek@gmail.com', url='https://github.com/tonyseek/flask-docker', From e028a3cba9edd201df117e960f870149372cd479 Mon Sep 17 00:00:00 2001 From: Jiangge Zhang Date: Mon, 8 Jun 2015 14:35:07 +0800 Subject: [PATCH 14/14] pin the release date of 0.2.0 in CHANGELOG. --- CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index b97b4b4..b0db0ac 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,7 +1,7 @@ Changelog --------- -0.2.0 - Unreleased +0.2.0 - 2015-06-08 ~~~~~~~~~~~~~~~~~~ * Make ``app`` attribute always be accessible in :class:`flask_docker.Docker`.