From f69358a6243f05238ca74f629b317deb83d94442 Mon Sep 17 00:00:00 2001 From: Erik Reid <erik.reid@geant.org> Date: Thu, 16 Apr 2020 14:05:08 +0200 Subject: [PATCH] refactored config schema for readability --- inventory_provider/config.py | 42 ++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/inventory_provider/config.py b/inventory_provider/config.py index 4311d91c..59953f2e 100644 --- a/inventory_provider/config.py +++ b/inventory_provider/config.py @@ -6,7 +6,7 @@ CONFIG_SCHEMA = { "$schema": "http://json-schema.org/draft-07/schema#", "definitions": { - "database_credentials": { + "database-credentials": { "type": "object", "properties": { "hostname": {"type": "string"}, @@ -17,17 +17,7 @@ CONFIG_SCHEMA = { "required": ["hostname", "dbname", "username", "password"], "additionalProperties": False }, - "timeout": { - "type": "number", - "maximum": 10, # sanity - "exclusiveMinimum": 0 - } - }, - - "type": "object", - "properties": { - "ops-db": {"$ref": "#/definitions/database_credentials"}, - "ssh": { + "ssh-credentials": { "type": "object", "properties": { "username": {"type": "string"}, @@ -37,7 +27,7 @@ CONFIG_SCHEMA = { "required": ["private-key", "known-hosts"], "additionalProperties": False }, - "redis": { + "redis-credentials": { "type": "object", "properties": { "hostname": {"type": "string"}, @@ -47,7 +37,7 @@ CONFIG_SCHEMA = { "required": ["hostname", "port"], "additionalProperties": False }, - "sentinel": { + "redis-sentinel-config": { "type": "object", "properties": { "hostname": {"type": "string"}, @@ -59,16 +49,30 @@ CONFIG_SCHEMA = { "required": ["hostname", "port", "name"], "additionalProperties": False }, + "junosspace-credentials": { + "api": {"type": "string"}, + "username": {"type": "string"}, + "password": {"type": "string"} + }, + "timeout": { + "type": "number", + "maximum": 10, # sanity + "exclusiveMinimum": 0 + } + }, + + "type": "object", + "properties": { + "ops-db": {"$ref": "#/definitions/database-credentials"}, + "ssh": {"$ref": "#/definitions/ssh-credentials"}, + "redis": {"$ref": "#/definitions/redis-credentials"}, + "sentinel": {"$ref": "#/definitions/redis-sentinel-config"}, "redis-databases": { "type": "array", "minItems": 1, "items": {"type": "integer"} }, - "junosspace": { - "api": {"type": "string"}, - "username": {"type": "string"}, - "password": {"type": "string"} - } + "junosspace": {"$ref": "#/definitions/junosspace-credentials"}, }, "oneOf": [ { -- GitLab