Skip to content

Commit

Permalink
some more changes
Browse files Browse the repository at this point in the history
  • Loading branch information
pieterb committed Dec 11, 2017
1 parent df79ac6 commit e63ea70
Show file tree
Hide file tree
Showing 7 changed files with 359 additions and 119 deletions.
87 changes: 87 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
.PHONY: build run test jenkinstest cov testclean distclean clean

RM = rm -rf

# `pytest` and `python -m pytest` are equivalent, except that the latter will
# add the current working directory to sys.path. We don't want that; we want
# to test against the _installed_ package(s), not against any python sources
# that are (accidentally) in our CWD.
PYTEST = pytest

# The ?= operator below assigns only if the variable isn't defined yet. This
# allows the caller to override them::
#
# TESTS=other_tests make test
#
#PYTEST_OPTS ?= --loop uvloop -p no:cacheprovider --verbose --exitfirst --capture=no --cov=src --cov-report=term --no-cov-on-fail
PYTEST_OPTS ?= --loop uvloop -p no:cacheprovider --verbose --exitfirst
PYTEST_COV_OPTS ?= --loop uvloop -p no:cacheprovider --verbose --cov=src --cov-report=term --no-cov-on-fail
TESTS ?= tests

YAML2JSON = python -c 'import json, sys, yaml; json.dump(yaml.load(sys.stdin), sys.stdout, indent=" ")'
JSON2YAML = python -c 'import json, sys, yaml; yaml.dump(json.load(sys.stdin), sys.stdout, default_flow_style=False)'
CONFIG = 'config'
SCHEMA = 'web/datacatalog/config_schema'

json:
$(YAML2JSON) <$(CONFIG).yml >$(CONFIG).json
$(YAML2JSON) <$(SCHEMA).yml >$(SCHEMA).json

yaml:
$(JSON2YAML) <$(CONFIG).json >$(CONFIG).yml
$(JSON2YAML) <$(SCHEMA).json >$(SCHEMA).yml

run:
cp -af $(OPENAPI_PATH) \
swagger-ui/dist/openapi.yml && \
authz_admin


schema schema_jenkins schema_acc:
$(MAKE) -C alembic $@


test: schema
$(PYTEST) $(PYTEST_OPTS) $(TESTS)


jenkinstest: schema_jenkins
$(PYTEST) $(PYTEST_OPTS) $(TESTS)


cov: schema
$(PYTEST) $(PYTEST_COV_OPTS) $(TESTS)


testclean:
@$(RM) .cache .coverage


# @evert waar komt dit eigenlijk vandaan? [--PvB]
distclean:
@$(RM) \
dist/ \
bin/ \
develop-eggs/ \
eggs/ \
parts/ \
MANIFEST \
htmlcov/ \
.installed.cfg

clean: testclean distclean
@$(RM) build *.egg-info .eggs dist
@find . -not -path "./.venv/*" -and \( \
-name "*.pyc" -or \
-name "__pycache__" -or \
-name "*.pyo" -or \
-name "*.so" -or \
-name "*.o" -or \
-name "*~" -or \
-name "._*" -or \
-name "*.swp" -or \
-name "Desktop.ini" -or \
-name "Thumbs.db" -or \
-name "__MACOSX__" -or \
-name ".DS_Store" \
\) -delete
49 changes: 26 additions & 23 deletions config.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,47 @@
datacatalog: {}

postgres:
host: ${DB_HOST:-localhost}
port: ${DB_PORT:-5432}
user: ${DB_USER:-datacatalog}
password: ${DB_PASS:-datacatalog}
dbname: ${DB_DATABASE:-datacatalog}

logging:
version: 1
formatters:
default:
format: '%(asctime)s authz_admin %(levelname)-8s %(module)s:%(lineno)d: %(message)s'
handlers:
aiohttp.access:
class: logging.StreamHandler
console:
class: logging.StreamHandler
formatter: default
aiohttp.access:
class: logging.StreamHandler
loggers:
datacatalog:
level: ${LOGLEVEL:-DEBUG}
handlers: [console]
propagate: false
aiohttp:
propagate: true
aiohttp.*:
propagate: true
aiohttp.access:
handlers:
- aiohttp.access
level: ${LOGLEVEL:-DEBUG}
handlers: [aiohttp.access]
propagate: false
aiohttp:
propagate: true
# aiohttp.*:
# propagate: true
aiohttp_extras:
handlers:
- console
level: ${LOGLEVEL:-DEBUG}
handlers: [console]
propagate: false
config_loader:
handlers:
- console
level: ${LOGLEVEL:-DEBUG}
propagate: false
datacatalog:
handlers:
- console
level: ${LOGLEVEL:-DEBUG}
handlers: [console]
propagate: false
root:
handlers:
- console
level: ${LOGLEVEL:-WARNING}
handlers: [console]
version: 1
postgres:
dbname: ${DB_DATABASE:-datacatalog}
host: ${DB_HOST:-localhost}
password: ${DB_PASS:-datacatalog}
port: ${DB_PORT:-5432}
user: ${DB_USER:-datacatalog}
168 changes: 168 additions & 0 deletions json-schema-draft-07.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "http://json-schema.org/draft-07/schema#",
"title": "Core schema meta-schema",
"definitions": {
"schemaArray": {
"type": "array",
"minItems": 1,
"items": { "$ref": "#" }
},
"nonNegativeInteger": {
"type": "integer",
"minimum": 0
},
"nonNegativeIntegerDefault0": {
"allOf": [
{ "$ref": "#/definitions/nonNegativeInteger" },
{ "default": 0 }
]
},
"simpleTypes": {
"enum": [
"array",
"boolean",
"integer",
"null",
"number",
"object",
"string"
]
},
"stringArray": {
"type": "array",
"items": { "type": "string" },
"uniqueItems": true,
"default": []
}
},
"type": ["object", "boolean"],
"properties": {
"$id": {
"type": "string",
"format": "uri-reference"
},
"$schema": {
"type": "string",
"format": "uri"
},
"$ref": {
"type": "string",
"format": "uri-reference"
},
"$comment": {
"type": "string"
},
"title": {
"type": "string"
},
"description": {
"type": "string"
},
"default": true,
"readOnly": {
"type": "boolean",
"default": false
},
"examples": {
"type": "array",
"items": true
},
"multipleOf": {
"type": "number",
"exclusiveMinimum": 0
},
"maximum": {
"type": "number"
},
"exclusiveMaximum": {
"type": "number"
},
"minimum": {
"type": "number"
},
"exclusiveMinimum": {
"type": "number"
},
"maxLength": { "$ref": "#/definitions/nonNegativeInteger" },
"minLength": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
"pattern": {
"type": "string",
"format": "regex"
},
"additionalItems": { "$ref": "#" },
"items": {
"anyOf": [
{ "$ref": "#" },
{ "$ref": "#/definitions/schemaArray" }
],
"default": true
},
"maxItems": { "$ref": "#/definitions/nonNegativeInteger" },
"minItems": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
"uniqueItems": {
"type": "boolean",
"default": false
},
"contains": { "$ref": "#" },
"maxProperties": { "$ref": "#/definitions/nonNegativeInteger" },
"minProperties": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
"required": { "$ref": "#/definitions/stringArray" },
"additionalProperties": { "$ref": "#" },
"definitions": {
"type": "object",
"additionalProperties": { "$ref": "#" },
"default": {}
},
"properties": {
"type": "object",
"additionalProperties": { "$ref": "#" },
"default": {}
},
"patternProperties": {
"type": "object",
"additionalProperties": { "$ref": "#" },
"propertyNames": { "format": "regex" },
"default": {}
},
"dependencies": {
"type": "object",
"additionalProperties": {
"anyOf": [
{ "$ref": "#" },
{ "$ref": "#/definitions/stringArray" }
]
}
},
"propertyNames": { "$ref": "#" },
"const": true,
"enum": {
"type": "array",
"items": true,
"minItems": 1,
"uniqueItems": true
},
"type": {
"anyOf": [
{ "$ref": "#/definitions/simpleTypes" },
{
"type": "array",
"items": { "$ref": "#/definitions/simpleTypes" },
"minItems": 1,
"uniqueItems": true
}
]
},
"format": { "type": "string" },
"contentMediaType": { "type": "string" },
"contentEncoding": { "type": "string" },
"if": {"$ref": "#"},
"then": {"$ref": "#"},
"else": {"$ref": "#"},
"allOf": { "$ref": "#/definitions/schemaArray" },
"anyOf": { "$ref": "#/definitions/schemaArray" },
"oneOf": { "$ref": "#/definitions/schemaArray" },
"not": { "$ref": "#" }
},
"default": true
}
9 changes: 4 additions & 5 deletions web/datacatalog/config.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# language=rst
"""
Module that loads the configuration settings for all our services.
.. envvar:: CONFIG_PATH
.. envvar:: CONFIG_PATH
If set, the configuration is loaded from this path.
See also :mod:`config_loader`.
**Example usage**::
Example usage::
from authz_admin import config
os.chdir(config.get()['working_directory'])
Expand Down Expand Up @@ -38,8 +39,6 @@
# extra imports:
import config_loader

from .frozen import frozen

_logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -99,5 +98,5 @@ def load() -> types.MappingProxyType:

# Procedure logging.config.dictConfig() (called above) requires a
# MutableMapping as its input, so we only freeze config *after* that call:
config = frozen(config)
config = config_loader.freeze(config)
return config
Loading

0 comments on commit e63ea70

Please sign in to comment.