From 1df238df9cf7e072e7beb8f7370a120906b8eab9 Mon Sep 17 00:00:00 2001 From: Yuanle Song Date: Fri, 4 May 2018 20:01:47 +0800 Subject: [PATCH] v1.4.0 better support when running in docker env - support reading configs from environment variable. all config key can be configured by env variable. This feature is introduced in wells 1.4.0. - add another configuration file position /etc/{{name}}/{{name}}.conf to allow easier volume mount in kubernetes. - ci-build docker run use go user - add host and port in app default configuration - replace pep8 by pycodestyle --- project.clj | 2 +- src/leiningen/new/python/Makefile | 4 ++-- src/leiningen/new/python/config.py | 5 ++++- src/leiningen/new/python/requirements-dev.txt | 6 +++--- src/leiningen/new/python/requirements.txt | 2 +- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/project.clj b/project.clj index eabe9ac..9867fad 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject python/lein-template "1.3.1" +(defproject python/lein-template "1.4.0" :description "lein template for a python project" :repositories [["snapshots" {:url "http://devserv.game.yy.com/nexus/content/repositories/snapshots" diff --git a/src/leiningen/new/python/Makefile b/src/leiningen/new/python/Makefile index 3bbaf76..fdfac18 100644 --- a/src/leiningen/new/python/Makefile +++ b/src/leiningen/new/python/Makefile @@ -3,7 +3,7 @@ PYTHONPATH := . VENV := .venv PYTEST := env PYTHONPATH=$(PYTHONPATH) PYTEST=1 $(VENV)/bin/py.test PYLINT := env PYTHONPATH=$(PYTHONPATH) $(VENV)/bin/pylint --disable=I0011 --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" -PEP8 := env PYTHONPATH=$(PYTHONPATH) $(VENV)/bin/pep8 --repeat --ignore=E202,E501,E402 +PEP8 := env PYTHONPATH=$(PYTHONPATH) $(VENV)/bin/pycodestyle --repeat --ignore=E202,E501,E402,W504 PYTHON := env PYTHONPATH=$(PYTHONPATH) $(VENV)/bin/python PIP := $(VENV)/bin/pip @@ -83,7 +83,7 @@ just-test: # image and push image on host. ci-build: docker login -u $(DOCKER_USER) -p $(DOCKER_PASSWORD) $(BUILD_DOCKER_IMAGE) - docker run --rm --name {{ name }}-test -v "$(CURDIR)":/app $(BUILD_DOCKER_IMAGE) make test deb -C /app + docker run --rm --name {{ name }}-test -v "$(CURDIR)":/app -u $(shell id -u go):$(shell id -g go) $(BUILD_DOCKER_IMAGE) make test deb -C /app docker build -t $(DOCKER_IMAGE_PREFIX)/{{ name }}:$(VERSION) . docker push $(DOCKER_IMAGE_PREFIX)/{{ name }}:$(VERSION) deploy: diff --git a/src/leiningen/new/python/config.py b/src/leiningen/new/python/config.py index d7e4a22..7fe41b0 100644 --- a/src/leiningen/new/python/config.py +++ b/src/leiningen/new/python/config.py @@ -26,6 +26,8 @@ if TESTING: logging.getLogger('').setLevel(logging.ERROR) DEFAULTS = { + "host": "127.0.0.1", + "port": "8082", "db.host": "localhost", "db.port": "5432", "db.name": "{{name}}", @@ -43,7 +45,8 @@ REQUIRED_KEYS = [ CONF = ConfigurationManger(defaults=DEFAULTS, configfiles=["/opt/{{name}}/conf/{{name}}.conf", - "/etc/{{name}}.conf"], + "/etc/{{name}}.conf", + "/etc/{{name}}/{{name}}.conf"], required_keys=REQUIRED_KEYS, optional_keys=OPTIONAL_KEYS) diff --git a/src/leiningen/new/python/requirements-dev.txt b/src/leiningen/new/python/requirements-dev.txt index 6193d77..72ec85d 100644 --- a/src/leiningen/new/python/requirements-dev.txt +++ b/src/leiningen/new/python/requirements-dev.txt @@ -1,3 +1,3 @@ -pytest==3.0.7 -pylint==1.6.5 -pep8==1.7.0 +pytest==3.5.1 +pylint==1.8.4 +pycodestyle==2.4.0 diff --git a/src/leiningen/new/python/requirements.txt b/src/leiningen/new/python/requirements.txt index bb3e23c..28bbb2f 100644 --- a/src/leiningen/new/python/requirements.txt +++ b/src/leiningen/new/python/requirements.txt @@ -1,3 +1,3 @@ -wells==1.1.0 +wells==1.4.0 # six==1.10.0 # raven==6.0.0 -- GitLab