Skip to content

Commit

Permalink
Use environment variables for configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
dstufft committed Jul 9, 2015
1 parent 1cd9565 commit 2b1ca8f
Show file tree
Hide file tree
Showing 12 changed files with 240 additions and 150 deletions.
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ include .coveragerc tox.ini docs/requirements.txt

recursive-include docs conf.py Makefile *.rst
recursive-include tests *.py
recursive-include warehouse/etc *.yml
recursive-include warehouse/migrations *.mako
recursive-include warehouse/migrations/versions *.py
recursive-include warehouse/static *.css *.json *.scss *.png
Expand Down
48 changes: 0 additions & 48 deletions dev/config.yml

This file was deleted.

12 changes: 11 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ camo:

web:
build: .
command: python -m warehouse --config dev/config.yml serve -b 0.0.0.0 -w 1 --reload
command: python -m warehouse serve -b 0.0.0.0 -w 1 --reload
ports:
- "80:8000"
volumes:
Expand All @@ -25,3 +25,13 @@ web:
- redis
environment:
PYTHONUNBUFFERED: 1
WAREHOUSE_ENV: development
DATABASE_URL: postgresql://postgres@db/warehouse
REDIS_URL: redis://redis:6379/0
STATS_REDIS_URL: redis://redis:6379/1
SESSION_SECRET: "an insecure development secret"
CAMO_URL: "{request.scheme}://{request.domain}:9000/"
CAMO_KEY: "insecure camo key"
DOCS_URL: "https://pythonhosted.org/{project}/"
DOCS_DIR: /app/data/documentation/
FILES_BACKEND: "warehouse.packaging.services.LocalFileStorage path=/app/data/packages/"
4 changes: 2 additions & 2 deletions docs/development/database-migrations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Database Migrations
Modifying database schema will need database migrations (except for removing
and adding tables). To autogenerate migrations::

$ docker-compose run web warehouse -c dev/config.yml db revision -m
$ docker-compose run web warehouse db revision -m

Then migrate and test your migration::

$ docker-compose run web warehouse -c dev/config.yml db upgrade head
$ docker-compose run web warehouse db upgrade head
4 changes: 2 additions & 2 deletions docs/development/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Quickstart for Developers with Docker experience
$ xz -d -k dev/example.sql.xz
$ docker-compose run web psql -h db -d warehouse -U postgres -v ON_ERROR_STOP=1 -1 -f dev/example.sql
$ rm dev/example.sql
$ docker-compose run web warehouse -c dev/config.yml db upgrade head
$ docker-compose run web warehouse db upgrade head
View Warehouse in the browser at ``http://localhost:80/`` (Linux) or
``http://boot2docker_ip_address:80/`` (for Mac OS X and Windows).
Expand Down Expand Up @@ -149,7 +149,7 @@ Run:
$ xz -d -k dev/example.sql.xz
$ docker-compose run web psql -h db -d warehouse -U postgres -v ON_ERROR_STOP=1 -1 -f dev/example.sql
$ rm dev/example.sql
$ docker-compose run web warehouse -c dev/config.yml db upgrade head
$ docker-compose run web warehouse db upgrade head
If running the second command raises an error, you may need to install the `xz
library`. This is highly likely on Mac OS X and Windows.
Expand Down
5 changes: 1 addition & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,13 @@ pastedeploy==1.5.2 # via pyramid
psycopg2==2.6.1
pycparser==2.14 # via cffi
pygments==2.0.2 # via readme
pymlconf==0.3.17 # via tzf.pyramid-yml
pyramid-jinja2==2.5
pyramid-multiauth==0.5.0
pyramid-services==0.2
pyramid-tm==0.12
pyramid==1.6a2 # via pyramid-jinja2, pyramid-multiauth, pyramid-services, pyramid-tm, tzf.pyramid-yml
pyramid==1.6a2 # via pyramid-jinja2, pyramid-multiauth, pyramid-services, pyramid-tm
python-dateutil==2.4.2 # via botocore
pytz==2015.4 # via babel
pyyaml==3.11 # via pymlconf
readme==0.5.1
redis==2.10.3
repoze.lru==0.6 # via pyramid
Expand All @@ -51,7 +49,6 @@ sqlalchemy==1.0.6 # via alembic, sqlalchemy-citext, zope.sqlalchemy
structlog==15.2.0
transaction==1.4.4 # via pyramid-tm, zope.sqlalchemy
translationstring==1.3 # via pyramid
tzf.pyramid-yml==1.0.1
venusian==1.0 # via pyramid
webob==1.5.dev0 # via pyramid
wtforms==2.0.2
Expand Down
2 changes: 0 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@
"sqlalchemy-citext",
"structlog",
"transaction",
"pymlconf!=0.3.12,!=0.3.13,!=0.3.14", # Needed by tzf.pyramid_yml
"tzf.pyramid_yml",
"WTForms>=2.0.0",
"zope.sqlalchemy",
],
Expand Down
27 changes: 2 additions & 25 deletions tests/unit/cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os.path

import click
import pretend

Expand All @@ -35,7 +33,7 @@ def test_lazy_config_delays(monkeypatch):

def test_cli_no_settings(monkeypatch, cli):
config = pretend.stub()
configure = pretend.call_recorder(lambda settings: config)
configure = pretend.call_recorder(lambda: config)
monkeypatch.setattr(warehouse.cli, "LazyConfig", configure)

@warehouse.cli.warehouse.command()
Expand All @@ -46,25 +44,4 @@ def cli_test_command(obj):
result = cli.invoke(warehouse.cli.warehouse, ["cli_test_command"])

assert result.exit_code == 0
assert configure.calls == [pretend.call(settings={})]


def test_cli_with_settings(monkeypatch, cli):
config = pretend.stub()
configure = pretend.call_recorder(lambda settings: config)
monkeypatch.setattr(warehouse.cli, "LazyConfig", configure)

@warehouse.cli.warehouse.command()
@click.pass_obj
def cli_test_command(obj):
assert obj is config

result = cli.invoke(
warehouse.cli.warehouse,
["--config", ".", "cli_test_command"],
)

assert result.exit_code == 0
assert configure.calls == [
pretend.call(settings={"yml.location": (os.path.abspath("."),)}),
]
assert configure.calls == [pretend.call()]
Loading

0 comments on commit 2b1ca8f

Please sign in to comment.