aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorHussein Ait-Lahcen <hussein.ait-lahcen@fretlink.com>2018-11-19 15:50:51 +0100
committerHussein Ait-Lahcen <hussein.ait-lahcen@fretlink.com>2018-11-19 18:58:43 +0100
commit50a9e710f9cff8be9d85d7161bb454a46c3f5734 (patch)
tree8b566d127eb719a0c3f458f8f80b91a6d75040bc
parentb570ba036adb74095c712705d686f630d41f4ed0 (diff)
downloadansible-clever-50a9e710f9cff8be9d85d7161bb454a46c3f5734.tar.gz
ansible-clever-50a9e710f9cff8be9d85d7161bb454a46c3f5734.tar.zst
ansible-clever-50a9e710f9cff8be9d85d7161bb454a46c3f5734.zip
add dhall interface
-rw-r--r--dhall/Config.dhall26
-rw-r--r--dhall/Vault.dhall1
-rw-r--r--dhall/addon/Addon.dhall1
-rw-r--r--dhall/addon/Postgresql.dhall3
-rw-r--r--dhall/addon/functions.dhall1
-rw-r--r--dhall/environment/Environment.dhall1
-rw-r--r--dhall/functions.dhall1
-rw-r--r--dhall/mkConfig.dhall43
-rw-r--r--dhall/types.dhall9
-rwxr-xr-xscripts/dhall_check.sh25
10 files changed, 111 insertions, 0 deletions
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 @@
1 let Addon = ./addon/Addon.dhall
2
3in λ(Environment : Type)
4 → { clever_app :
5 Text
6 , clever_orga :
7 Text
8 , clever_secret :
9 Text
10 , clever_token :
11 Text
12 , clever_syslog_server :
13 Text
14 , clever_domain :
15 Text
16 , clever_app_tasks_file :
17 Text
18 , clever_entry_point :
19 Text
20 , clever_metrics :
21 Bool
22 , clever_addons :
23 List Addon
24 , clever_env :
25 Environment
26 }
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 @@
1 let addon = constructors ./Addon.dhall
2
3in 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 @@
1 let Config = ./Config.dhall
2
3in let Vault = ./Vault.dhall
4
5in let Addon = ./addon/Addon.dhall
6
7in let Environment = ./environment/Environment.dhall
8
9in let nonifyEmpty =
10 λ(opt : Optional Text)
11 → Optional/fold Text opt Text (λ(x : Text) → x) "None"
12
13in λ(vault : Vault)
14 → λ(app : Text)
15 → λ(entryPoint : Text)
16 → λ(syslogServer : Optional Text)
17 → λ(domain : Optional Text)
18 → λ(tasksFile : Optional Text)
19 → λ(addons : List Addon)
20 → { clever_app =
21 app
22 , clever_orga =
23 vault.organization
24 , clever_secret =
25 vault.secret
26 , clever_token =
27 vault.token
28 , clever_syslog_server =
29 nonifyEmpty syslogServer
30 , clever_domain =
31 nonifyEmpty domain
32 , clever_app_tasks_file =
33 nonifyEmpty tasksFile
34 , clever_entry_point =
35 entryPoint
36 , clever_metrics =
37 True
38 , clever_addons =
39 addons
40 , clever_env =
41 { FORCE_HTTPS = True }
42 }
43 : 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 @@
1{ Vault =
2 ./Vault.dhall
3, Addon =
4 ./addon/Addon.dhall
5, Environment =
6 ./environment/Environment.dhall
7, Config =
8 ./Config.dhall
9}
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 @@
1#!/usr/bin/env bash
2
3pushd () {
4 command pushd "$@" > /dev/null
5}
6
7popd () {
8 command popd "$@" > /dev/null
9}
10
11go() {
12 local ERROR=0;
13 for file in $(find -type f -name "*.dhall"); do
14 pushd $(dirname $file);
15 cat $(basename $file) | dhall --explain resolve > /dev/null;
16 if [ "$?" -ne "0" ]; then
17 echo "Failed to resolve $file"
18 ERROR=1;
19 fi;
20 popd;
21 done;
22 exit $ERROR;
23}
24
25go