Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*~
*.pyc
.venv/
.venv3/
Expand Down
35 changes: 12 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
APT_PREREQS=python-dev python3-dev python-virtualenv
APT_PREREQS=python3-dev python-virtualenv
PROJECT=pgsql
TESTS=tests/

Expand All @@ -12,33 +12,28 @@ all:
.PHONY: clean
clean:
find . -name '*.pyc' -delete
rm -rf .venv
find . -name '__pycache__' -delete
find . -name '*~' -delete
rm -rf .venv3
rm -rf docs/_build
rm -rf docs/build

.PHONY: docclean
docclean:
-rm -rf docs/_build

.venv:
@echo Processing apt package prereqs
@for i in $(APT_PREREQS); do dpkg -l | grep -w $$i >/dev/null || sudo apt-get install -y $$i; done
virtualenv .venv
.venv/bin/pip install -IUr test_requirements.txt

.venv3:
@echo Processing apt package prereqs
@for i in $(APT_PREREQS); do dpkg -l | grep -w $$i >/dev/null || sudo apt-get install -y $$i; done
virtualenv .venv3 --python=python3
.venv3/bin/pip install -IUr test_requirements.txt

.PHONY: lint
lint: .venv .venv3
@echo Checking for Python syntax...
.venv/bin/flake8 --max-line-length=120 $(PROJECT) $(TESTS) \
&& echo Py2 OK
.venv3/bin/flake8 --max-line-length=120 $(PROJECT) $(TESTS) \
&& echo Py3 OK
# lint: .venv3
# @echo Checking for Python syntax...
# .venv3/bin/flake8 $(PROJECT) $(TESTS) \
# && echo Py3 OK
lint:
flake8 requires.py

# Note we don't even attempt to run tests if lint isn't passing.
.PHONY: test
Expand All @@ -55,11 +50,5 @@ test3: .venv3
.venv3/bin/nosetests -s --nologcapture tests/

.PHONY: docs
docs: .venv
- [ -z "`.venv/bin/pip list | grep -i 'sphinx '`" ] && .venv/bin/pip install sphinx
- [ -z "`.venv/bin/pip list | grep -i sphinx-pypi-upload`" ] && .venv/bin/pip install sphinx-pypi-upload
# If sphinx is installed on the system, pip installing into the venv does not
# put the binaries into .venv/bin. Test for and use the .venv binary if it's
# there; otherwise, we probably have a system sphinx in /usr/bin, so use that.
SPHINX=$$(test -x .venv/bin/sphinx-build && echo \"../.venv/bin/sphinx-build\" || echo \"../.venv/bin/python /usr/bin/sphinx-build\"); \
cd docs && make html SPHINXBUILD=$$SPHINX && cd -
docs: .venv3
make -C docs html SPHINXBUILD=../.venv3/bin/sphinx-build
Empty file removed common/__init__.py
Empty file.
22 changes: 11 additions & 11 deletions copyright
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
Format: http://dep.debian.net/deps/dep5/

Files: *
Copyright: Copyright 2015, Canonical Ltd., All Rights Reserved.
License: Apache License 2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Copyright: Copyright 2015-2016, Canonical Ltd.
License: GPL-3
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 3, as
published by the Free Software Foundation.
.
http://www.apache.org/licenses/LICENSE-2.0
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranties of
MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
1 change: 0 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Contents:
:maxdepth: 2

requires
provides


Indices and tables
Expand Down
65 changes: 0 additions & 65 deletions docs/source/provides.rst

This file was deleted.

20 changes: 13 additions & 7 deletions docs/source/requires.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,22 @@ This is what a charm using this relation would look like:
from charmhelpers.core.reactive import set_state
from charmhelpers.core.reactive import remove_state

@hook('db-relation-joined')
@when('db.connected')
def request_db(pgsql):
pgsql.change_database_name('mydb')
pgsql.request_roles('myrole', 'otherrole')
pgsql.set_database('mydb')

@hook('config-changed')
@when('config.changed')
def check_admin_pass():
admin_pass = hookenv.config('admin-pass')
admin_pass = hookenv.config()['admin-pass']
if admin_pass:
set_state('admin-pass')
else:
remove_state('admin-pass')

@when('db.database.available', 'admin-pass')
@when('db.master.available', 'admin-pass')
def render_config(pgsql):
render_template('app-config.j2', '/etc/app.conf', {
'db_conn': pgsql.connection_string(),
'db_conn': pgsql.master,
'admin_pass': hookenv.config('admin-pass'),
})

Expand All @@ -42,6 +41,13 @@ This is what a charm using this relation would look like:

Reference
---------
.. autoclass::
requires.ConnectionString
:members:

.. autoclass::
requires.ConnectionStrings
:members:

.. autoclass::
requires.PostgreSQLClient
Expand Down
2 changes: 1 addition & 1 deletion interface.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name: pgsql
summary: Interface for relating to PostgreSQL
summary: PostgreSQL client interface
maintainer: '"Cory Johns" <cory.johns@canonical.com>'
Empty file removed peer.py
Empty file.
163 changes: 0 additions & 163 deletions provides.py

This file was deleted.

Loading