forked from JeepGuy/Docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Yaml
219 lines (163 loc) · 4.19 KB
/
Yaml
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
YAML
====
- text files or configuration files that are returned
in a particular format called YAML.
- All docker compose files and All ansible playbooks are configuration files
written in particular format Yaml.
Similar to XML or JSON
A yaml file is used to represent data, in this case configuration data.
Key value pairs - seperated by a colon.
----------------------------------------
Fruit: Apple
Vegetable: Carrot
etc.
YOU MUST Have a space following the colon differentiatiing the key and the value.
ARRAY/LISTS
-----------
Fruits:
- Orange (The dash indicates it is an element of an array.)
- Apple
- Banana
Vegetable:
- Carrot
- Cauliglower
- Tomato
Dictionaries/Map
=============
- a dictionary is a set of properties group together under an item.
Banana:
Calories: 105
Fat: 0.4 g
Carbs: 27 g
You must have an equal number of spaces in front of the properties of a single item.
- they are all aligned together - all aligned together.
SPACES in YAML
==============
You must have an equal number of spaces in front of the properties of a single item.
- they are all aligned together.
> if you have an extra space,
the value becomes a property of the preceeding item, not the parent dictionary item.
i.e.
Banana:
Calories: 105
Fat: 0.4 g
Carbs: 27 g
Fat becomes a property of Calories...
If you make a spacing error / mistake, you will receive an syntax error message that states:
Mapping values are not allowed here.
Key Value/Dictionary/Lists
==========================
- You can have lists containing dictionaries containing lists
Fruits:
- Banana (Element of the list - array)
Calories: 105 (dictionaries of nutrition info for each element of the list)
Fat: 0.4 g
Carbs: 27 g
- Grape
Calories: 62
Fat: 0.3 g
Carbs: 16 g
DICTIONARY vs LIST vs LIST of DICTIONARIES
==========================================
ALL XML , json, or yaml is used to represent data.
All objects have properties: Color, price, model, engine, etc.
To store data (different information or properties) about an object (car) we use a dictionary.
- Defined in a key value format.
DICTIONARY
===========
You can further break down individual properties into dictionaries (sub dictionaries almost)
e.g.
Color: Blue
Model: Corvette
Engine: v8
Price: $20k
- e.g. Can add a dictionary to one property in this case model.
Color: Blue
Model:
Name: Corvette
Year: 1955
Engine: v8
Price: $20k
LIST of strings (array)
====
- a list of the same types of objects
i.e. store six different corvettes names based on color of car.
- Blue corvette
- Grey corvette
- Red corvette
- Green corvette
- Blue corvette
- Black corvette
LIST of dictionaries
====================
Expand each item in the array and replace each name with the dictionary we built earlier.
simple:
- Color: Blue
Model: Corvette
Engine: v8
Price: $20k
- Color: Grey
Model: Corvette
Engine: v8
Price: $22k
More complex List of dictionaries with sub dictionary items:
- Color: Blue
Model:
Name: Corvette
Year: 1955
Engine: v8
Price: $20k
- Color: Grey
Model:
Name: Corvette
Year: 1985
Engine: v8
Price: $22k
- Color: Red
Model:
Name: Corvette
Year: 1965
Engine: v8
Price: $21k
- Color: Green
Model:
Name: Corvette
Year: 1975
Engine: v8
Price: $24k
- Color: Blue
Model:
Name: Corvette
Year: 1959
Engine: v8
Price: $25k
NOTES: Ordered verses Unordered items
------------------------------------------
Dictionary is an unordered group of information
- the properties appear in any order
List is an ordered group of information
DICTIONARY
Banana:
Calories: 105
Fat: 0.4 g
Carbs: 27 g
- is the same as-
Banana:
Calories: 105
Carbs: 27 g (notice Carbs and Fats are in different order )
Fat: 0.4 g
LIST
-----
- ordered so the items must be in the sames order
Vegetable:
- Carrot
- Tomato
- Cauliglower
-is NOT the same as
Vegetable:
- Carrot
- Cauliglower (inverted order of items in the array.)
- Tomato
# COMMENT
Any line beggining with a hash or octothorpe is ignored andß considered a comment.
...