-
Notifications
You must be signed in to change notification settings - Fork 4
/
c0046.yml
81 lines (70 loc) · 1.89 KB
/
c0046.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
doc_meta: |
folder: env-vars
title: environment vars
head: |
This showcases:
* How to use env variables and provide a default value if it is empty
* An minimal entry task could be just a name
* The empty value is mapped to None value internnally
sections:
- title: Demo
log: yes
notes:
goal:
- showcase the bare minimal entry point is just a named task only
- showcase how to gracefully manage the env vars
storys:
- a cli script requires 2 input from env vars
- |
it also requires 2 config vars in a profile
based config for different execution context/env,
eg dev/st/prod
- it should take the env var from current bash/shell environment
- the env vars:
student_name: |
if it can not find it, it fails fast and execution stops
ref to f0045 for the failed case
student_age: if it can not find it, defaul it to 18
scopes:
- name: global
dvars:
- name: student_name
value: '{{ env "STUDENT_NAME" |default "Tom Hanks" }}'
- name: student_age
value: '{{ env "STUDENT_AGE" |default 28 }}'
dvars:
- name: cli
value: |
echo """
student details:
name: {{.student_name}}
age: {{.student_age}}
"""
tasks:
-
name: task
task:
-
func: shell
desc: this show an example of the empty value is mapped to None
vars:
person: ""
dvars:
- name: someone
value: '{{ .person }}'
- name: i_am_empty
value: '{{ "" }}'
- name: empty_env_var
value: '{{ env "EMPTY_VAR" }}'
do: |
echo "{{.someone}}"
echo "{{.i_am_empty}}"
echo "{{.empty_env_var}}"
-
func: cmd
do:
-
name: inspect
cmd:
- exec_vars
- exec_base_vars