From 50a9e710f9cff8be9d85d7161bb454a46c3f5734 Mon Sep 17 00:00:00 2001 From: Hussein Ait-Lahcen Date: Mon, 19 Nov 2018 15:50:51 +0100 Subject: add dhall interface --- dhall/Config.dhall | 26 ++++++++++++++++++++++ dhall/Vault.dhall | 1 + dhall/addon/Addon.dhall | 1 + dhall/addon/Postgresql.dhall | 3 +++ dhall/addon/functions.dhall | 1 + dhall/environment/Environment.dhall | 1 + dhall/functions.dhall | 1 + dhall/mkConfig.dhall | 43 +++++++++++++++++++++++++++++++++++++ dhall/types.dhall | 9 ++++++++ scripts/dhall_check.sh | 25 +++++++++++++++++++++ 10 files changed, 111 insertions(+) create mode 100644 dhall/Config.dhall create mode 100644 dhall/Vault.dhall create mode 100644 dhall/addon/Addon.dhall create mode 100644 dhall/addon/Postgresql.dhall create mode 100644 dhall/addon/functions.dhall create mode 100644 dhall/environment/Environment.dhall create mode 100644 dhall/functions.dhall create mode 100644 dhall/mkConfig.dhall create mode 100644 dhall/types.dhall create mode 100755 scripts/dhall_check.sh diff --git a/dhall/Config.dhall b/dhall/Config.dhall new file mode 100644 index 0000000..01329a8 --- /dev/null +++ b/dhall/Config.dhall @@ -0,0 +1,26 @@ + let Addon = ./addon/Addon.dhall + +in λ(Environment : Type) + → { clever_app : + Text + , clever_orga : + Text + , clever_secret : + Text + , clever_token : + Text + , clever_syslog_server : + Text + , clever_domain : + Text + , clever_app_tasks_file : + Text + , clever_entry_point : + Text + , clever_metrics : + Bool + , clever_addons : + List Addon + , clever_env : + Environment + } diff --git a/dhall/Vault.dhall b/dhall/Vault.dhall new file mode 100644 index 0000000..ba1a309 --- /dev/null +++ b/dhall/Vault.dhall @@ -0,0 +1 @@ +{ organization : Text, secret : Text, token : Text } diff --git a/dhall/addon/Addon.dhall b/dhall/addon/Addon.dhall new file mode 100644 index 0000000..2eb781c --- /dev/null +++ b/dhall/addon/Addon.dhall @@ -0,0 +1 @@ +< Postgresql : { name : Text, env_prefix : Text } > diff --git a/dhall/addon/Postgresql.dhall b/dhall/addon/Postgresql.dhall new file mode 100644 index 0000000..9dd9744 --- /dev/null +++ b/dhall/addon/Postgresql.dhall @@ -0,0 +1,3 @@ + let addon = constructors ./Addon.dhall + +in addon.Postgresql { name = "pg", env_prefix = "POSTGRESQL_ADDON" } diff --git a/dhall/addon/functions.dhall b/dhall/addon/functions.dhall new file mode 100644 index 0000000..65979ac --- /dev/null +++ b/dhall/addon/functions.dhall @@ -0,0 +1 @@ +{ Postgresql = ./Postgresql.dhall } diff --git a/dhall/environment/Environment.dhall b/dhall/environment/Environment.dhall new file mode 100644 index 0000000..68514c9 --- /dev/null +++ b/dhall/environment/Environment.dhall @@ -0,0 +1 @@ +{ FORCE_HTTPS : Bool } diff --git a/dhall/functions.dhall b/dhall/functions.dhall new file mode 100644 index 0000000..f047c19 --- /dev/null +++ b/dhall/functions.dhall @@ -0,0 +1 @@ +{ Addon = ./addon/functions.dhall, mkConfig = ./mkConfig.dhall } diff --git a/dhall/mkConfig.dhall b/dhall/mkConfig.dhall new file mode 100644 index 0000000..a904332 --- /dev/null +++ b/dhall/mkConfig.dhall @@ -0,0 +1,43 @@ + let Config = ./Config.dhall + +in let Vault = ./Vault.dhall + +in let Addon = ./addon/Addon.dhall + +in let Environment = ./environment/Environment.dhall + +in let nonifyEmpty = + λ(opt : Optional Text) + → Optional/fold Text opt Text (λ(x : Text) → x) "None" + +in λ(vault : Vault) + → λ(app : Text) + → λ(entryPoint : Text) + → λ(syslogServer : Optional Text) + → λ(domain : Optional Text) + → λ(tasksFile : Optional Text) + → λ(addons : List Addon) + → { clever_app = + app + , clever_orga = + vault.organization + , clever_secret = + vault.secret + , clever_token = + vault.token + , clever_syslog_server = + nonifyEmpty syslogServer + , clever_domain = + nonifyEmpty domain + , clever_app_tasks_file = + nonifyEmpty tasksFile + , clever_entry_point = + entryPoint + , clever_metrics = + True + , clever_addons = + addons + , clever_env = + { FORCE_HTTPS = True } + } + : Config Environment diff --git a/dhall/types.dhall b/dhall/types.dhall new file mode 100644 index 0000000..5e6a81c --- /dev/null +++ b/dhall/types.dhall @@ -0,0 +1,9 @@ +{ Vault = + ./Vault.dhall +, Addon = + ./addon/Addon.dhall +, Environment = + ./environment/Environment.dhall +, Config = + ./Config.dhall +} diff --git a/scripts/dhall_check.sh b/scripts/dhall_check.sh new file mode 100755 index 0000000..009d570 --- /dev/null +++ b/scripts/dhall_check.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +pushd () { + command pushd "$@" > /dev/null +} + +popd () { + command popd "$@" > /dev/null +} + +go() { + local ERROR=0; + for file in $(find -type f -name "*.dhall"); do + pushd $(dirname $file); + cat $(basename $file) | dhall --explain resolve > /dev/null; + if [ "$?" -ne "0" ]; then + echo "Failed to resolve $file" + ERROR=1; + fi; + popd; + done; + exit $ERROR; +} + +go -- cgit v1.2.3