toml-combine 1.0.2__tar.gz → 1.0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. toml_combine-1.0.3/.github/release.yml +6 -0
  2. {toml_combine-1.0.2 → toml_combine-1.0.3}/CONTRIBUTING.md +23 -4
  3. {toml_combine-1.0.2 → toml_combine-1.0.3}/PKG-INFO +90 -30
  4. {toml_combine-1.0.2 → toml_combine-1.0.3}/README.md +89 -29
  5. {toml_combine-1.0.2 → toml_combine-1.0.3}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
  6. {toml_combine-1.0.2 → toml_combine-1.0.3}/.github/renovate.json5 +0 -0
  7. {toml_combine-1.0.2 → toml_combine-1.0.3}/.github/workflows/ci.yml +0 -0
  8. {toml_combine-1.0.2 → toml_combine-1.0.3}/.pre-commit-config.yaml +0 -0
  9. {toml_combine-1.0.2 → toml_combine-1.0.3}/LICENSE +0 -0
  10. {toml_combine-1.0.2 → toml_combine-1.0.3}/pyproject.toml +0 -0
  11. {toml_combine-1.0.2 → toml_combine-1.0.3}/tests/result.json +0 -0
  12. {toml_combine-1.0.2 → toml_combine-1.0.3}/tests/test.toml +0 -0
  13. {toml_combine-1.0.2 → toml_combine-1.0.3}/tests/test_cli.py +0 -0
  14. {toml_combine-1.0.2 → toml_combine-1.0.3}/tests/test_combiner.py +0 -0
  15. {toml_combine-1.0.2 → toml_combine-1.0.3}/tests/test_lib.py +0 -0
  16. {toml_combine-1.0.2 → toml_combine-1.0.3}/toml_combine/__init__.py +0 -0
  17. {toml_combine-1.0.2 → toml_combine-1.0.3}/toml_combine/__main__.py +0 -0
  18. {toml_combine-1.0.2 → toml_combine-1.0.3}/toml_combine/cli.py +0 -0
  19. {toml_combine-1.0.2 → toml_combine-1.0.3}/toml_combine/combiner.py +0 -0
  20. {toml_combine-1.0.2 → toml_combine-1.0.3}/toml_combine/exceptions.py +0 -0
  21. {toml_combine-1.0.2 → toml_combine-1.0.3}/toml_combine/lib.py +0 -0
  22. {toml_combine-1.0.2 → toml_combine-1.0.3}/toml_combine/toml.py +0 -0
  23. {toml_combine-1.0.2 → toml_combine-1.0.3}/uv.lock +0 -0
@@ -0,0 +1,6 @@
1
+ changelog:
2
+ exclude:
3
+ authors:
4
+ - pre-commit-ci
5
+ - renovate
6
+ - dependabot
@@ -14,21 +14,40 @@ or using a package manager, such as [brew](https://brew.sh/):
14
14
  $ brew install uv
15
15
  ```
16
16
 
17
- Then you can directly launch the tests with:
17
+ ### Work with UV (will handle the venv for you)
18
+
19
+ **Run tests**
18
20
 
19
21
  ```console
20
22
  $ uv run pytest
21
23
  ```
22
24
 
23
- or create a virtual environment to work on the package and activate it:
25
+ **Run the command**
26
+
27
+ ```console
28
+ $ uv run toml-combine --help
29
+ ```
30
+
31
+ ### Work with a classic virtual environment
32
+
33
+ **Create and activate a virtual environment**
24
34
 
25
35
  ```console
26
36
  $ uv sync
27
37
  $ source .venv/bin/activate
28
38
  ```
29
39
 
30
- or launch the command itself with uv (no need to activate the venv):
40
+ **Run tests**
31
41
 
32
42
  ```console
33
- $ uv run toml-combine --help
43
+ $ pytest
44
+ ```
45
+
46
+ **Run the command**
47
+
48
+ ```console
49
+ $ toml-combine --help
34
50
  ```
51
+
52
+ > [!NOTE]
53
+ > In this venv, if you need `pip` you can use `uv pip` instead, it works the same.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: toml-combine
3
- Version: 1.0.2
3
+ Version: 1.0.3
4
4
  Summary: A tool for combining complex configurations in TOML format.
5
5
  Author-email: Joachim Jablon <ewjoachim@gmail.com>
6
6
  License-Expression: MIT
@@ -47,7 +47,10 @@ name = "my-service"
47
47
  registry = "gcr.io/my-project/"
48
48
  container.image_name = "my-image"
49
49
  container.port = 8080
50
- service_account = "my-service-account"
50
+
51
+ [[override]]
52
+ when.environment = "production"
53
+ service_account = "my-production-service-account"
51
54
 
52
55
  [[override]]
53
56
  when.environment = "staging"
@@ -73,50 +76,107 @@ Each override defines a set of condition where it applies (`when.<dimension> =
73
76
 
74
77
  ```toml
75
78
  [[override]]
76
- # Conditions
79
+ # Keys starting with `when.` are "conditions"
77
80
  when.environment = "staging"
78
81
  when.region = "us"
79
82
 
80
- # Overridden keys / values
83
+ # Other keys in an override are "overridden keys" / "overridden values"
81
84
  service_account = "my-us-staging-service-account"
82
85
  ```
83
86
 
84
- If two overrides are both applicable in the same run of `toml-combine`, they will be
85
- checked for _compatibility_ with one another, and an error if they're not compatible.
87
+ If you run `toml-combine` with a given mapping that selects multiple overrides, they
88
+ will be checked for _compatibility_ with one another, and an error will be raised if
89
+ they're _not compatible_.
86
90
 
87
91
  Compatibility rules:
88
92
 
89
- - If the two overrides don't share any overridden key, then they're always compatible.
90
- - If the conditions of an override are a subset of the condition of the other one,
91
- they're compatible. Also, in that case, the overridden values of the more specific one
92
- **will have precedence**.
93
+ - If the two overrides don't share any _overridden key_, then they're always compatible.
94
+
95
+ <details>
96
+ <summary>Example (click to expand)</summary>
97
+
98
+ ```toml
99
+ [dimensions]
100
+ environment = ["staging"]
101
+ region = ["eu"]
102
+
103
+ [[override]]
104
+ when.environment = "staging"
105
+ service_account = "my-staging-service-account"
106
+
107
+ [[override]]
108
+ when.region = "eu"
109
+ env.CURRENCY = "EUR"
110
+ ```
111
+
112
+ </details>
113
+
114
+ - If an override defines a set of conditions (say `env=prod`) and the other one defines
115
+ strictly more conditions (say `env=prod, region=eu`, in other words, it defines all
116
+ the conditions of the first override and then some more), then they're compatible.
117
+ Also, in that case, **the override with more conditions will have precedence**.
118
+
119
+ <details>
120
+ <summary>Example</summary>
121
+
122
+ ```toml
123
+ [dimensions]
124
+ environment = ["staging"]
125
+ region = ["eu"]
126
+
127
+ [[override]]
128
+ when.environment = "staging"
129
+ service_account = "my-staging-service-account"
130
+
131
+ [[override]]
132
+ when.environment = "staging"
133
+ when.region = "eu"
134
+ service_account = "my-staging-eu-service-account"
135
+ ```
136
+
137
+ </details>
138
+
93
139
  - If they both define a dimension that the other one doesn't, they're incompatible.
94
140
 
95
- Example of incompatible overrides: neither is a subset of the other one and they both
96
- define a value for `foo`:
141
+ <details>
142
+ <summary>Example (click to expand)</summary>
97
143
 
98
- ```toml
99
- [dimensions]
100
- environment = ["staging"]
101
- region = ["eu"]
144
+ Incompatible overrides: neither is a subset of the other one and they both
145
+ define a value for `service_account`:
102
146
 
103
- [[override]]
104
- when.environment = "staging"
105
- foo = "bar"
147
+ ```toml
148
+ [dimensions]
149
+ environment = ["staging"]
150
+ region = ["eu"]
106
151
 
107
- [[override]]
108
- when.region = "eu"
109
- foo = "baz"
110
- ```
152
+ [default]
153
+ service_account = "my-service-account"
111
154
 
112
- ```console
113
- $ toml-combine config.toml --environment=staging --region=eu
114
- Error: Incompatible overrides `{'region': ['eu']}` and `{'environment': ['staging']}`:
115
- When they're both applicable, overrides defining a common overridden key (foo) must be
116
- a subset of one another
117
- ```
155
+ [[override]]
156
+ when.environment = "staging"
157
+ service_account = "my-staging-service-account"
158
+
159
+ [[override]]
160
+ when.region = "eu"
161
+ service_account = "my-eu-service-account"
162
+ ```
163
+
164
+ ```console
165
+ $ toml-combine config.toml --environment=staging --region=eu
166
+ Error: Incompatible overrides `{'region': ['eu']}` and `{'environment': ['staging']}`:
167
+ When they're both applicable, overrides defining a common overridden key (foo) must be
168
+ a subset of one another
169
+ ```
170
+
171
+ > [!NOTE]
172
+ > It's ok to have incompatible overrides in your config as long as you don't
173
+ > run `toml-combine` with a mapping that would select both of them. In the example
174
+ > above, if you run `toml-combine --environment=staging --region=eu`, the error
175
+ > will be triggered, but you can run `toml-combine --environment=staging`.
176
+
177
+ </details>
118
178
 
119
- > [!Note]
179
+ > [!NOTE]
120
180
  > Instead of defining a single value for the override dimensions, you can define a list.
121
181
  > This is a shortcut to duplicating the override with each individual value:
122
182
  >
@@ -27,7 +27,10 @@ name = "my-service"
27
27
  registry = "gcr.io/my-project/"
28
28
  container.image_name = "my-image"
29
29
  container.port = 8080
30
- service_account = "my-service-account"
30
+
31
+ [[override]]
32
+ when.environment = "production"
33
+ service_account = "my-production-service-account"
31
34
 
32
35
  [[override]]
33
36
  when.environment = "staging"
@@ -53,50 +56,107 @@ Each override defines a set of condition where it applies (`when.<dimension> =
53
56
 
54
57
  ```toml
55
58
  [[override]]
56
- # Conditions
59
+ # Keys starting with `when.` are "conditions"
57
60
  when.environment = "staging"
58
61
  when.region = "us"
59
62
 
60
- # Overridden keys / values
63
+ # Other keys in an override are "overridden keys" / "overridden values"
61
64
  service_account = "my-us-staging-service-account"
62
65
  ```
63
66
 
64
- If two overrides are both applicable in the same run of `toml-combine`, they will be
65
- checked for _compatibility_ with one another, and an error if they're not compatible.
67
+ If you run `toml-combine` with a given mapping that selects multiple overrides, they
68
+ will be checked for _compatibility_ with one another, and an error will be raised if
69
+ they're _not compatible_.
66
70
 
67
71
  Compatibility rules:
68
72
 
69
- - If the two overrides don't share any overridden key, then they're always compatible.
70
- - If the conditions of an override are a subset of the condition of the other one,
71
- they're compatible. Also, in that case, the overridden values of the more specific one
72
- **will have precedence**.
73
+ - If the two overrides don't share any _overridden key_, then they're always compatible.
74
+
75
+ <details>
76
+ <summary>Example (click to expand)</summary>
77
+
78
+ ```toml
79
+ [dimensions]
80
+ environment = ["staging"]
81
+ region = ["eu"]
82
+
83
+ [[override]]
84
+ when.environment = "staging"
85
+ service_account = "my-staging-service-account"
86
+
87
+ [[override]]
88
+ when.region = "eu"
89
+ env.CURRENCY = "EUR"
90
+ ```
91
+
92
+ </details>
93
+
94
+ - If an override defines a set of conditions (say `env=prod`) and the other one defines
95
+ strictly more conditions (say `env=prod, region=eu`, in other words, it defines all
96
+ the conditions of the first override and then some more), then they're compatible.
97
+ Also, in that case, **the override with more conditions will have precedence**.
98
+
99
+ <details>
100
+ <summary>Example</summary>
101
+
102
+ ```toml
103
+ [dimensions]
104
+ environment = ["staging"]
105
+ region = ["eu"]
106
+
107
+ [[override]]
108
+ when.environment = "staging"
109
+ service_account = "my-staging-service-account"
110
+
111
+ [[override]]
112
+ when.environment = "staging"
113
+ when.region = "eu"
114
+ service_account = "my-staging-eu-service-account"
115
+ ```
116
+
117
+ </details>
118
+
73
119
  - If they both define a dimension that the other one doesn't, they're incompatible.
74
120
 
75
- Example of incompatible overrides: neither is a subset of the other one and they both
76
- define a value for `foo`:
121
+ <details>
122
+ <summary>Example (click to expand)</summary>
77
123
 
78
- ```toml
79
- [dimensions]
80
- environment = ["staging"]
81
- region = ["eu"]
124
+ Incompatible overrides: neither is a subset of the other one and they both
125
+ define a value for `service_account`:
82
126
 
83
- [[override]]
84
- when.environment = "staging"
85
- foo = "bar"
127
+ ```toml
128
+ [dimensions]
129
+ environment = ["staging"]
130
+ region = ["eu"]
86
131
 
87
- [[override]]
88
- when.region = "eu"
89
- foo = "baz"
90
- ```
132
+ [default]
133
+ service_account = "my-service-account"
91
134
 
92
- ```console
93
- $ toml-combine config.toml --environment=staging --region=eu
94
- Error: Incompatible overrides `{'region': ['eu']}` and `{'environment': ['staging']}`:
95
- When they're both applicable, overrides defining a common overridden key (foo) must be
96
- a subset of one another
97
- ```
135
+ [[override]]
136
+ when.environment = "staging"
137
+ service_account = "my-staging-service-account"
138
+
139
+ [[override]]
140
+ when.region = "eu"
141
+ service_account = "my-eu-service-account"
142
+ ```
143
+
144
+ ```console
145
+ $ toml-combine config.toml --environment=staging --region=eu
146
+ Error: Incompatible overrides `{'region': ['eu']}` and `{'environment': ['staging']}`:
147
+ When they're both applicable, overrides defining a common overridden key (foo) must be
148
+ a subset of one another
149
+ ```
150
+
151
+ > [!NOTE]
152
+ > It's ok to have incompatible overrides in your config as long as you don't
153
+ > run `toml-combine` with a mapping that would select both of them. In the example
154
+ > above, if you run `toml-combine --environment=staging --region=eu`, the error
155
+ > will be triggered, but you can run `toml-combine --environment=staging`.
156
+
157
+ </details>
98
158
 
99
- > [!Note]
159
+ > [!NOTE]
100
160
  > Instead of defining a single value for the override dimensions, you can define a list.
101
161
  > This is a shortcut to duplicating the override with each individual value:
102
162
  >
File without changes
File without changes