You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A python module which allows you to merge hierarchical config files using YAML syntax. It offers deep merge, variable interpolation and secrets retrieval from secrets managers.
9
+
10
+
It is ideal if you want to structure your hierarchy in such a way that you avoid duplication. You can define a structure for your configuration using a hierarchy such environment/project/cluster/app. It is up to you what layers you want to use in this hierarchy. The tool will read all yaml files starting from the root (where default values would be) all the way to the leaf (where most specific values would be, which will take precedence).
11
+
12
+
Idea came from puppet's hiera.
13
+
14
+
## Table of Contents
15
+
16
+
1.[Installation](#installation)
17
+
2.[Examples](#examples)
18
+
3.[Features](#features)
19
+
*[Interpolation](#feature-interpolation)
20
+
*[Deep merge](#feature-deep-merge)
21
+
*[Secrets retrieval](#feature-secrets-retrieval)
22
+
*[Merge with Terraform remote state](#feature-terraform-remote-state)
23
+
24
+
<aname="installation"/>
6
25
7
26
## Installation
8
27
@@ -20,10 +39,80 @@ cd himl
20
39
sudo python setup.py install
21
40
```
22
41
23
-
## Example
42
+
<aname="examples"/>
43
+
44
+
## Examples
45
+
46
+
### Using the python module
47
+
48
+
This will merge simple/default.yaml with simple/production/env.yaml
49
+
```py
50
+
from himl import ConfigProcessor
51
+
52
+
config_processor = ConfigProcessor()
53
+
path ="examples/simple/production"
54
+
filters = () # can choose to output only specific keys
55
+
exclude_keys = () # can choose to remove specific keys
The above example will merge `simple/default.yaml` with `simple/production/env.yaml`:
65
+
```
66
+
$ tree examples/simple
67
+
examples/simple
68
+
├── default.yaml
69
+
└── production
70
+
└── env.yaml
71
+
```
72
+
73
+
<aname="deep-merge-example"/>
74
+
75
+
The example also showcases deep merging of lists and maps.
76
+
77
+
`examples/simple/default.yaml`
78
+
```yaml
79
+
---
80
+
env: default
81
+
deep:
82
+
key1: v1
83
+
key2: v2
84
+
deep_list:
85
+
- item1
86
+
- item2
87
+
```
88
+
89
+
`examples/simple/production/env.yaml`
90
+
```yaml
91
+
---
92
+
env: prod
93
+
deep:
94
+
key3: v3
95
+
deep_list:
96
+
- item3
97
+
```
98
+
99
+
Result:
100
+
```yaml
101
+
env: prod
102
+
deep:
103
+
key1: v1
104
+
key2: v2
105
+
key3: v3
106
+
deep_list:
107
+
- item1
108
+
- item2
109
+
- item3
110
+
```
24
111
25
112
### Using the cli
26
113
114
+
A cli tool called `himl` is automatically installed via `pip`. You can use it to parse a tree of yamls and it will either output the combined configuration at standard output or write it to a file.
0 commit comments