aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.travis.yml2
-rw-r--r--README.md2
-rw-r--r--defaults/main.yml2
-rw-r--r--dhall-1.18.nix16
-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.dhall44
-rw-r--r--dhall/types.dhall9
-rwxr-xr-xscripts/dhall_check.sh26
14 files changed, 133 insertions, 2 deletions
diff --git a/.travis.yml b/.travis.yml
index 82ddcec..ef53f71 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,6 +6,7 @@ sudo: false
6install: 6install:
7 - nix-env -i python2.7-ansible 7 - nix-env -i python2.7-ansible
8 - nix-env -i python2.7-ansible-lint 8 - nix-env -i python2.7-ansible-lint
9 - nix-env -if ./dhall-1.18.nix
9 10
10 # Check ansible version 11 # Check ansible version
11 - ansible --version 12 - ansible --version
@@ -20,6 +21,7 @@ script:
20 # Basic role syntax check 21 # Basic role syntax check
21 - ansible-playbook tests/test.yml -i tests/inventory --syntax-check 22 - ansible-playbook tests/test.yml -i tests/inventory --syntax-check
22 - ansible-lint . 23 - ansible-lint .
24 - scripts/dhall_check.sh
23 25
24notifications: 26notifications:
25 slack: fretlink:pTIylIN7zkwRFuL3aHERmsbB 27 slack: fretlink:pTIylIN7zkwRFuL3aHERmsbB
diff --git a/README.md b/README.md
index 86153af..b932c7f 100644
--- a/README.md
+++ b/README.md
@@ -30,7 +30,7 @@ Variables for the application
30- _Obsolete_: `domain`: Same as above but was replaced by `clever_domain` since v1.4 of this role. 30- _Obsolete_: `domain`: Same as above but was replaced by `clever_domain` since v1.4 of this role.
31- `clever_syslog_server`: UDP Syslog server to be used as UDPSyslog drain for the application, optional. Example: `udp://198.51.100.51:12345`. 31- `clever_syslog_server`: UDP Syslog server to be used as UDPSyslog drain for the application, optional. Example: `udp://198.51.100.51:12345`.
32- _Obsolete_: `syslog_server`: Same as above but was replaced by `clever_syslog_server` since v1.5 of this role. 32- _Obsolete_: `syslog_server`: Same as above but was replaced by `clever_syslog_server` since v1.5 of this role.
33- `clever_metrics`: a boolean to enable or disable metrics support. Optional, default to `false`. 33- `clever_metrics`: a boolean to enable or disable metrics support. Optional, default to `true`.
34 34
35Variables specific to deployment, default should be fine: 35Variables specific to deployment, default should be fine:
36- `clever_cli_version`: Version of clever cli tools, default to `0.9.3`. 36- `clever_cli_version`: Version of clever cli tools, default to `0.9.3`.
diff --git a/defaults/main.yml b/defaults/main.yml
index 1fbea48..fb0e30f 100644
--- a/defaults/main.yml
+++ b/defaults/main.yml
@@ -9,7 +9,7 @@ clever_login_file: "{{ clever_app_confdir }}/login"
9clever_entry_point: "" 9clever_entry_point: ""
10clever_env: {} 10clever_env: {}
11 11
12clever_metrics: false 12clever_metrics: true
13 13
14clever_addons: [] 14clever_addons: []
15# example 15# example
diff --git a/dhall-1.18.nix b/dhall-1.18.nix
new file mode 100644
index 0000000..d6522bd
--- /dev/null
+++ b/dhall-1.18.nix
@@ -0,0 +1,16 @@
1{ pkgs ? import <nixpkgs> {} }: with pkgs;
2
3stdenv.mkDerivation rec {
4 name = "dhall-${version}";
5 version = "1.18.0";
6 phases = [ "installPhase "];
7 src = fetchurl {
8 url = "https://github.com/dhall-lang/dhall-haskell/releases/download/${version}/dhall-${version}-x86_64-linux.tar.bz2";
9 sha256 = "0jvw6ss96xifb21mzpvfjzvaffcnpj0jhpc4rd36cl2r22800qgx";
10 };
11 installPhase = ''
12 mkdir -p $out/bin
13 tar -xjf $src
14 mv bin/dhall $out/bin/
15 '';
16}
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..5040f1c
--- /dev/null
+++ b/dhall/mkConfig.dhall
@@ -0,0 +1,44 @@
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 → λ(metrics : Bool)
17 → λ(syslogServer : Optional Text)
18 → λ(domain : Optional Text)
19 → λ(tasksFile : Optional Text)
20 → λ(addons : List Addon)
21 → { clever_app =
22 app
23 , clever_orga =
24 vault.organization
25 , clever_secret =
26 vault.secret
27 , clever_token =
28 vault.token
29 , clever_syslog_server =
30 nonifyEmpty syslogServer
31 , clever_domain =
32 nonifyEmpty domain
33 , clever_app_tasks_file =
34 nonifyEmpty tasksFile
35 , clever_entry_point =
36 entryPoint
37 , clever_metrics =
38 metrics
39 , clever_addons =
40 addons
41 , clever_env =
42 { FORCE_HTTPS = True }
43 }
44 : 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..a3413ec
--- /dev/null
+++ b/scripts/dhall_check.sh
@@ -0,0 +1,26 @@
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 echo "Typechecking ${file}"
17 if [ "$?" -ne "0" ]; then
18 echo "Failed to resolve $file"
19 ERROR=1;
20 fi;
21 popd;
22 done;
23 exit $ERROR;
24}
25
26go