diff options
author | Paul Bonaud <paul.bonaud@fretlink.com> | 2020-03-24 10:18:14 +0100 |
---|---|---|
committer | Paul Bonaud <paul.bonaud@fretlink.com> | 2020-03-24 16:09:45 +0100 |
commit | c99eb17850e51327449e6fac5572c6cfc436d21c (patch) | |
tree | 0773be49aed217cebe9e600c4acb0b7cc49921df | |
parent | 13602abcc2f50d0ad5b3eff47e5719bfa8b77ecd (diff) | |
download | ansible-clever-c99eb17850e51327449e6fac5572c6cfc436d21c.tar.gz ansible-clever-c99eb17850e51327449e6fac5572c6cfc436d21c.tar.zst ansible-clever-c99eb17850e51327449e6fac5572c6cfc436d21c.zip |
vars: fix `clever_base_env` by removing a variable if not necessary
The `CC_RUN_COMMAND` variable was defined in case we use haskell
binary as entrypoints. However if the `clever_haskell_entry_point`
variable is not defined we shouldn't define the `CC_RUN_COMMAND` env variable.
-rw-r--r-- | .travis.yml | 6 | ||||
-rw-r--r-- | defaults/main.yml | 4 | ||||
-rw-r--r-- | templates/env.j2 | 8 | ||||
-rwxr-xr-x | tests/fake.sh | 14 | ||||
-rw-r--r-- | tests/inventory | 2 | ||||
-rw-r--r-- | tests/test.yml | 6 | ||||
-rw-r--r-- | vars/main.yml | 3 |
7 files changed, 35 insertions, 8 deletions
diff --git a/.travis.yml b/.travis.yml index 22e80b3..0fcb053 100644 --- a/.travis.yml +++ b/.travis.yml | |||
@@ -24,6 +24,12 @@ script: | |||
24 | - ansible-lint . | 24 | - ansible-lint . |
25 | - shellcheck **/*.sh | 25 | - shellcheck **/*.sh |
26 | - scripts/dhall_check.sh | 26 | - scripts/dhall_check.sh |
27 | # Run integration test | ||
28 | - mkdir -p ~/.local/bin | ||
29 | - cp tests/fake.sh ~/.local/bin/clever | ||
30 | - cp tests/fake.sh ~/.local/bin/git | ||
31 | - ansible-playbook tests/test.yml -i tests/inventory | ||
27 | 32 | ||
28 | notifications: | 33 | notifications: |
29 | slack: fretlink:pTIylIN7zkwRFuL3aHERmsbB | 34 | slack: fretlink:pTIylIN7zkwRFuL3aHERmsbB |
35 | webhooks: https://galaxy.ansible.com/api/v1/notifications/ | ||
diff --git a/defaults/main.yml b/defaults/main.yml index d4aa86d..0e4bada 100644 --- a/defaults/main.yml +++ b/defaults/main.yml | |||
@@ -1,12 +1,12 @@ | |||
1 | --- | 1 | --- |
2 | # defaults file for clever | 2 | # defaults file for clever |
3 | clever_cli_version: 1.4.2 | 3 | clever_cli_version: 1.6.3 |
4 | clever_user_path: .local/bin | 4 | clever_user_path: .local/bin |
5 | clever_app_root: "{{ app_root | default(playbook_dir + '/..') }}" | 5 | clever_app_root: "{{ app_root | default(playbook_dir + '/..') }}" |
6 | clever_app_confdir: "{{ clever_app_root }}/.clever_cloud" | 6 | clever_app_confdir: "{{ clever_app_root }}/.clever_cloud" |
7 | clever_login_file: "{{ clever_app_confdir }}/login" | 7 | clever_login_file: "{{ clever_app_confdir }}/login" |
8 | 8 | ||
9 | clever_haskell_entry_point: "{{ clever_entry_point | default('') }}" | 9 | clever_haskell_entry_point: "{{ clever_entry_point | default(None) }}" |
10 | clever_env: {} | 10 | clever_env: {} |
11 | 11 | ||
12 | clever_disable_metrics: false | 12 | clever_disable_metrics: false |
diff --git a/templates/env.j2 b/templates/env.j2 index d2bf446..66e5508 100644 --- a/templates/env.j2 +++ b/templates/env.j2 | |||
@@ -1,3 +1,9 @@ | |||
1 | {% for key, value in (clever_base_env | combine(clever_env)).items() %} | 1 | {% for key, value in (clever_base_env | combine(clever_env)).items() %} |
2 | {{ key }}="{{ value | tojson }}" | 2 | {{ key }}="{{ value | to_json }}" |
3 | {% endfor %} | 3 | {% endfor %} |
4 | |||
5 | {%- if clever_haskell_entry_point %} | ||
6 | {# Haskell only #} | ||
7 | {# https://www.clever-cloud.com/doc/get-help/reference-environment-variables/#haskell #} | ||
8 | CC_RUN_COMMAND="{{'~/.local/bin/' + clever_haskell_entry_point | to_json }}" | ||
9 | {% endif %} | ||
diff --git a/tests/fake.sh b/tests/fake.sh new file mode 100755 index 0000000..2835e85 --- /dev/null +++ b/tests/fake.sh | |||
@@ -0,0 +1,14 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | |||
3 | binary="${0/*\/}" | ||
4 | fakeCommit="aaa000aaa000aaa000aaa000aaa000aaa000aaa0" | ||
5 | |||
6 | if [ "${binary}" = "clever" ] && [ "${1}" = "--version" ]; then | ||
7 | echo "1.6.3" | ||
8 | elif [ "${binary}" = "clever" ] && [ "${1}" = "activity" ]; then | ||
9 | echo "2020-02-02T20:20:02+02:00 OK DEPLOY ${fakeCommit} Git" | ||
10 | elif [ "${binary}" = "git" ]; then | ||
11 | echo "${fakeCommit}" | ||
12 | else | ||
13 | echo "${binary} called with arguments: ${*}" | ||
14 | fi | ||
diff --git a/tests/inventory b/tests/inventory index 878877b..49d4fe2 100644 --- a/tests/inventory +++ b/tests/inventory | |||
@@ -1,2 +1,2 @@ | |||
1 | localhost | 1 | localhost ansible_connection=local |
2 | 2 | ||
diff --git a/tests/test.yml b/tests/test.yml index 3e3c57f..663bc6b 100644 --- a/tests/test.yml +++ b/tests/test.yml | |||
@@ -2,4 +2,8 @@ | |||
2 | - hosts: localhost | 2 | - hosts: localhost |
3 | remote_user: root | 3 | remote_user: root |
4 | roles: | 4 | roles: |
5 | - clever \ No newline at end of file | 5 | - role: clever |
6 | vars: | ||
7 | clever_token: 123abc | ||
8 | clever_secret: cba321 | ||
9 | clever_app: app_00000000-0000-0000-0000-000000000000 | ||
diff --git a/vars/main.yml b/vars/main.yml index 94ee792..a9625f0 100644 --- a/vars/main.yml +++ b/vars/main.yml | |||
@@ -2,9 +2,6 @@ | |||
2 | # vars file for clever | 2 | # vars file for clever |
3 | clever_base_env: | 3 | clever_base_env: |
4 | CACHE_DEPENDENCIES: "true" | 4 | CACHE_DEPENDENCIES: "true" |
5 | # Haskell only | ||
6 | # https://www.clever-cloud.com/doc/get-help/reference-environment-variables/#haskell | ||
7 | CC_RUN_COMMAND: "~/.local/bin/{{ clever_haskell_entry_point }}" | ||
8 | CC_DISABLE_METRICS: "{{ clever_disable_metrics | lower }}" | 5 | CC_DISABLE_METRICS: "{{ clever_disable_metrics | lower }}" |
9 | PORT: "8080" | 6 | PORT: "8080" |
10 | 7 | ||