qontract-reconcile 0.10.1rc763__py3-none-any.whl → 0.10.1rc765__py3-none-any.whl

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 (41) hide show
  1. {qontract_reconcile-0.10.1rc763.dist-info → qontract_reconcile-0.10.1rc765.dist-info}/METADATA +1 -1
  2. {qontract_reconcile-0.10.1rc763.dist-info → qontract_reconcile-0.10.1rc765.dist-info}/RECORD +27 -31
  3. reconcile/external_resources/aws.py +85 -0
  4. reconcile/external_resources/factories.py +133 -0
  5. reconcile/external_resources/integration.py +95 -0
  6. reconcile/external_resources/manager.py +350 -0
  7. reconcile/external_resources/meta.py +4 -0
  8. reconcile/external_resources/metrics.py +20 -0
  9. reconcile/external_resources/model.py +244 -0
  10. reconcile/external_resources/reconciler.py +249 -0
  11. reconcile/external_resources/secrets_sync.py +229 -0
  12. reconcile/external_resources/state.py +246 -0
  13. reconcile/saas_auto_promotions_manager/meta.py +1 -1
  14. reconcile/saas_auto_promotions_manager/subscriber.py +52 -2
  15. reconcile/saas_auto_promotions_manager/utils/saas_files_inventory.py +4 -0
  16. reconcile/test/saas_auto_promotions_manager/conftest.py +63 -0
  17. reconcile/test/saas_auto_promotions_manager/merge_request_manager/merge_request_manager/conftest.py +0 -37
  18. reconcile/test/saas_auto_promotions_manager/merge_request_manager/merge_request_manager/test_desired_state.py +20 -14
  19. reconcile/test/saas_auto_promotions_manager/merge_request_manager/renderer/conftest.py +0 -43
  20. reconcile/test/saas_auto_promotions_manager/merge_request_manager/renderer/test_content_multiple_namespaces.py +4 -11
  21. reconcile/test/saas_auto_promotions_manager/merge_request_manager/renderer/test_content_single_namespace.py +12 -19
  22. reconcile/test/saas_auto_promotions_manager/merge_request_manager/renderer/test_content_single_target.py +6 -12
  23. reconcile/test/saas_auto_promotions_manager/merge_request_manager/renderer/test_json_path_selector.py +8 -15
  24. reconcile/test/saas_auto_promotions_manager/merge_request_manager/renderer/data_keys.py +0 -4
  25. reconcile/test/saas_auto_promotions_manager/subscriber/conftest.py +0 -89
  26. reconcile/test/saas_auto_promotions_manager/subscriber/data_keys.py +0 -11
  27. reconcile/test/saas_auto_promotions_manager/subscriber/test_content_hash.py +0 -130
  28. reconcile/test/saas_auto_promotions_manager/subscriber/test_diff.py +0 -161
  29. reconcile/test/saas_auto_promotions_manager/subscriber/test_multiple_channels_config_hash.py +0 -218
  30. reconcile/test/saas_auto_promotions_manager/subscriber/test_multiple_channels_moving_ref.py +0 -216
  31. reconcile/test/saas_auto_promotions_manager/subscriber/test_multiple_publishers_moving_ref.py +0 -129
  32. reconcile/test/saas_auto_promotions_manager/subscriber/test_single_channel_with_single_publisher.py +0 -330
  33. reconcile/test/saas_auto_promotions_manager/utils/saas_files_inventory/__init__.py +0 -0
  34. reconcile/test/saas_auto_promotions_manager/utils/saas_files_inventory/test_multiple_publishers_for_single_channel.py +0 -68
  35. reconcile/test/saas_auto_promotions_manager/utils/saas_files_inventory/test_saas_files_use_target_config_hash.py +0 -62
  36. reconcile/test/saas_auto_promotions_manager/utils/saas_files_inventory/test_saas_files_with_auto_promote.py +0 -73
  37. reconcile/test/saas_auto_promotions_manager/utils/saas_files_inventory/test_saas_files_without_auto_promote.py +0 -64
  38. {qontract_reconcile-0.10.1rc763.dist-info → qontract_reconcile-0.10.1rc765.dist-info}/WHEEL +0 -0
  39. {qontract_reconcile-0.10.1rc763.dist-info → qontract_reconcile-0.10.1rc765.dist-info}/entry_points.txt +0 -0
  40. {qontract_reconcile-0.10.1rc763.dist-info → qontract_reconcile-0.10.1rc765.dist-info}/top_level.txt +0 -0
  41. /reconcile/{test/saas_auto_promotions_manager/subscriber → external_resources}/__init__.py +0 -0
@@ -1,330 +0,0 @@
1
- from collections.abc import (
2
- Callable,
3
- Mapping,
4
- )
5
- from typing import Any
6
-
7
- from reconcile.saas_auto_promotions_manager.subscriber import (
8
- ConfigHash,
9
- Subscriber,
10
- )
11
-
12
- from .data_keys import (
13
- CHANNELS,
14
- CONFIG_HASH,
15
- CUR_CONFIG_HASHES,
16
- CUR_SUBSCRIBER_REF,
17
- REAL_WORLD_SHA,
18
- SUCCESSFUL_DEPLOYMENT,
19
- USE_TARGET_CONFIG_HASH,
20
- )
21
-
22
-
23
- def test_no_change(
24
- subscriber_builder: Callable[[Mapping[str, Any]], Subscriber],
25
- ):
26
- subscriber = subscriber_builder({
27
- CUR_SUBSCRIBER_REF: "current_sha",
28
- CUR_CONFIG_HASHES: [
29
- ConfigHash(
30
- channel="channel-a",
31
- parent_saas="publisher_a",
32
- target_config_hash="current_hash",
33
- ),
34
- ],
35
- CHANNELS: {
36
- "channel-a": {
37
- "publisher_a": {
38
- REAL_WORLD_SHA: "current_sha",
39
- CONFIG_HASH: "current_hash",
40
- }
41
- },
42
- },
43
- })
44
- subscriber.compute_desired_state()
45
- expected_config_hashes = [
46
- ConfigHash(
47
- channel="channel-a",
48
- parent_saas="publisher_a",
49
- target_config_hash="current_hash",
50
- )
51
- ]
52
- assert subscriber.desired_ref == "current_sha"
53
- assert subscriber.desired_hashes == expected_config_hashes
54
-
55
-
56
- def test_moving_ref(
57
- subscriber_builder: Callable[[Mapping[str, Any]], Subscriber],
58
- ):
59
- subscriber = subscriber_builder({
60
- CUR_SUBSCRIBER_REF: "current_sha",
61
- CUR_CONFIG_HASHES: [
62
- ConfigHash(
63
- channel="channel-a",
64
- parent_saas="publisher_a",
65
- target_config_hash="current_hash",
66
- ),
67
- ],
68
- CHANNELS: {
69
- "channel-a": {
70
- "publisher_a": {
71
- REAL_WORLD_SHA: "new_sha",
72
- CONFIG_HASH: "current_hash",
73
- }
74
- },
75
- },
76
- })
77
- subscriber.compute_desired_state()
78
- expected_config_hashes = [
79
- ConfigHash(
80
- channel="channel-a",
81
- parent_saas="publisher_a",
82
- target_config_hash="current_hash",
83
- )
84
- ]
85
- assert subscriber.desired_ref == "new_sha"
86
- assert subscriber.desired_hashes == expected_config_hashes
87
-
88
-
89
- def test_moving_ref_bad_deployment(
90
- subscriber_builder: Callable[[Mapping[str, Any]], Subscriber],
91
- ):
92
- subscriber = subscriber_builder({
93
- CUR_SUBSCRIBER_REF: "current_sha",
94
- CUR_CONFIG_HASHES: [
95
- ConfigHash(
96
- channel="channel-a",
97
- parent_saas="publisher_a",
98
- target_config_hash="current_hash",
99
- ),
100
- ],
101
- CHANNELS: {
102
- "channel-a": {
103
- "publisher_a": {
104
- REAL_WORLD_SHA: "new_sha",
105
- CONFIG_HASH: "current_hash",
106
- SUCCESSFUL_DEPLOYMENT: False,
107
- }
108
- },
109
- },
110
- })
111
- subscriber.compute_desired_state()
112
- expected_config_hashes = [
113
- ConfigHash(
114
- channel="channel-a",
115
- parent_saas="publisher_a",
116
- target_config_hash="current_hash",
117
- )
118
- ]
119
- assert subscriber.desired_ref == "current_sha"
120
- assert subscriber.desired_hashes == expected_config_hashes
121
-
122
-
123
- def test_new_config_hash(
124
- subscriber_builder: Callable[[Mapping[str, Any]], Subscriber],
125
- ):
126
- subscriber = subscriber_builder({
127
- CUR_SUBSCRIBER_REF: "current_sha",
128
- CUR_CONFIG_HASHES: [
129
- ConfigHash(
130
- channel="channel-a",
131
- parent_saas="publisher_a",
132
- target_config_hash="current_hash",
133
- ),
134
- ],
135
- CHANNELS: {
136
- "channel-a": {
137
- "publisher_a": {
138
- REAL_WORLD_SHA: "current_sha",
139
- CONFIG_HASH: "new_hash",
140
- }
141
- },
142
- },
143
- })
144
- subscriber.compute_desired_state()
145
- expected_config_hashes = [
146
- ConfigHash(
147
- channel="channel-a",
148
- parent_saas="publisher_a",
149
- target_config_hash="new_hash",
150
- )
151
- ]
152
- assert subscriber.desired_ref == "current_sha"
153
- assert subscriber.desired_hashes == expected_config_hashes
154
-
155
-
156
- def test_new_config_hash_bad_deployment(
157
- subscriber_builder: Callable[[Mapping[str, Any]], Subscriber],
158
- ):
159
- subscriber = subscriber_builder({
160
- CUR_SUBSCRIBER_REF: "current_sha",
161
- CUR_CONFIG_HASHES: [
162
- ConfigHash(
163
- channel="channel-a",
164
- parent_saas="publisher_a",
165
- target_config_hash="current_hash",
166
- ),
167
- ],
168
- CHANNELS: {
169
- "channel-a": {
170
- "publisher_a": {
171
- REAL_WORLD_SHA: "current_sha",
172
- CONFIG_HASH: "new_hash",
173
- SUCCESSFUL_DEPLOYMENT: False,
174
- }
175
- },
176
- },
177
- })
178
- subscriber.compute_desired_state()
179
- expected_config_hashes = [
180
- ConfigHash(
181
- channel="channel-a",
182
- parent_saas="publisher_a",
183
- target_config_hash="current_hash",
184
- )
185
- ]
186
- assert subscriber.desired_ref == "current_sha"
187
- assert subscriber.desired_hashes == expected_config_hashes
188
-
189
-
190
- def test_new_config_hash_and_moving_ref(
191
- subscriber_builder: Callable[[Mapping[str, Any]], Subscriber],
192
- ):
193
- subscriber = subscriber_builder({
194
- CUR_SUBSCRIBER_REF: "current_sha",
195
- CUR_CONFIG_HASHES: [
196
- ConfigHash(
197
- channel="channel-a",
198
- parent_saas="publisher_a",
199
- target_config_hash="current_hash",
200
- ),
201
- ],
202
- CHANNELS: {
203
- "channel-a": {
204
- "publisher_a": {
205
- REAL_WORLD_SHA: "new_sha",
206
- CONFIG_HASH: "new_hash",
207
- }
208
- },
209
- },
210
- })
211
- subscriber.compute_desired_state()
212
- expected_config_hashes = [
213
- ConfigHash(
214
- channel="channel-a",
215
- parent_saas="publisher_a",
216
- target_config_hash="new_hash",
217
- )
218
- ]
219
- assert subscriber.desired_ref == "new_sha"
220
- assert subscriber.desired_hashes == expected_config_hashes
221
-
222
-
223
- def test_new_config_hash_and_moving_ref_and_bad_deployment(
224
- subscriber_builder: Callable[[Mapping[str, Any]], Subscriber],
225
- ):
226
- subscriber = subscriber_builder({
227
- CUR_SUBSCRIBER_REF: "current_sha",
228
- CUR_CONFIG_HASHES: [
229
- ConfigHash(
230
- channel="channel-a",
231
- parent_saas="publisher_a",
232
- target_config_hash="current_hash",
233
- ),
234
- ],
235
- CHANNELS: {
236
- "channel-a": {
237
- "publisher_a": {
238
- REAL_WORLD_SHA: "new_sha",
239
- CONFIG_HASH: "new_hash",
240
- SUCCESSFUL_DEPLOYMENT: False,
241
- }
242
- },
243
- },
244
- })
245
- subscriber.compute_desired_state()
246
- expected_config_hashes = [
247
- ConfigHash(
248
- channel="channel-a",
249
- parent_saas="publisher_a",
250
- target_config_hash="current_hash",
251
- )
252
- ]
253
- assert subscriber.desired_ref == "current_sha"
254
- assert subscriber.desired_hashes == expected_config_hashes
255
-
256
-
257
- def test_cur_config_hash_did_not_exist(
258
- subscriber_builder: Callable[[Mapping[str, Any]], Subscriber],
259
- ):
260
- subscriber = subscriber_builder({
261
- CUR_SUBSCRIBER_REF: "current_sha",
262
- CUR_CONFIG_HASHES: [],
263
- CHANNELS: {
264
- "channel-a": {
265
- "publisher_a": {
266
- REAL_WORLD_SHA: "current_sha",
267
- CONFIG_HASH: "new_hash",
268
- }
269
- },
270
- },
271
- })
272
- subscriber.compute_desired_state()
273
- expected_config_hashes = [
274
- ConfigHash(
275
- channel="channel-a",
276
- parent_saas="publisher_a",
277
- target_config_hash="new_hash",
278
- )
279
- ]
280
- assert subscriber.desired_ref == "current_sha"
281
- assert subscriber.desired_hashes == expected_config_hashes
282
-
283
-
284
- def test_cur_config_hash_did_not_exist_and_neglect(
285
- subscriber_builder: Callable[[Mapping[str, Any]], Subscriber],
286
- ):
287
- subscriber = subscriber_builder({
288
- USE_TARGET_CONFIG_HASH: False,
289
- CUR_SUBSCRIBER_REF: "current_sha",
290
- CUR_CONFIG_HASHES: [],
291
- CHANNELS: {
292
- "channel-a": {
293
- "publisher_a": {
294
- REAL_WORLD_SHA: "current_sha",
295
- CONFIG_HASH: "new_hash",
296
- }
297
- },
298
- },
299
- })
300
- subscriber.compute_desired_state()
301
- assert subscriber.desired_ref == "current_sha"
302
- assert subscriber.desired_hashes == []
303
-
304
-
305
- def test_neglect_config_hashes(
306
- subscriber_builder: Callable[[Mapping[str, Any]], Subscriber],
307
- ):
308
- subscriber = subscriber_builder({
309
- USE_TARGET_CONFIG_HASH: False,
310
- CUR_SUBSCRIBER_REF: "current_sha",
311
- CUR_CONFIG_HASHES: [
312
- ConfigHash(
313
- channel="channel-a",
314
- parent_saas="publisher_a",
315
- target_config_hash="old_hash",
316
- ),
317
- ],
318
- CHANNELS: {
319
- "channel-a": {
320
- "publisher_a": {
321
- REAL_WORLD_SHA: "current_sha",
322
- CONFIG_HASH: "new_hash",
323
- }
324
- },
325
- },
326
- })
327
- subscriber.compute_desired_state()
328
-
329
- assert subscriber.desired_ref == "current_sha"
330
- assert subscriber.desired_hashes == []
@@ -1,68 +0,0 @@
1
- from collections.abc import (
2
- Callable,
3
- Iterable,
4
- Mapping,
5
- )
6
-
7
- from reconcile.saas_auto_promotions_manager.utils.saas_files_inventory import (
8
- SaasFilesInventory,
9
- )
10
- from reconcile.typed_queries.saas_files import SaasFile
11
-
12
-
13
- def test_multiple_publishers_for_single_channel(
14
- saas_files_builder: Callable[[Iterable[Mapping]], list[SaasFile]],
15
- ):
16
- saas_files = saas_files_builder([
17
- {
18
- "path": "/saas1.yml",
19
- "name": "saas_1",
20
- "resourceTemplates": [
21
- {
22
- "name": "template_1",
23
- "url": "repo1/url",
24
- "targets": [
25
- {
26
- "ref": "main",
27
- "namespace": {"path": "/namespace1.yml"},
28
- "promotion": {
29
- "publish": ["channel-a"],
30
- },
31
- },
32
- {
33
- "ref": "main",
34
- "namespace": {"path": "/namespace2.yml"},
35
- "promotion": {
36
- "publish": ["channel-a"],
37
- },
38
- },
39
- ],
40
- }
41
- ],
42
- },
43
- {
44
- "path": "/saas2.yml",
45
- "name": "saas_2",
46
- "resourceTemplates": [
47
- {
48
- "name": "template_2",
49
- "url": "repo2/url",
50
- "targets": [
51
- {
52
- "ref": "main",
53
- "namespace": {"path": "/namespace3.yml"},
54
- "promotion": {
55
- "subscribe": ["channel-a"],
56
- "auto": True,
57
- },
58
- }
59
- ],
60
- }
61
- ],
62
- },
63
- ])
64
- inventory = SaasFilesInventory(saas_files=saas_files)
65
-
66
- assert len(inventory.publishers) == 3
67
- assert len(inventory.publishers_with_subscribers) == 2
68
- assert len(inventory.subscribers) == 1
@@ -1,62 +0,0 @@
1
- from collections.abc import (
2
- Callable,
3
- Iterable,
4
- Mapping,
5
- )
6
-
7
- from reconcile.saas_auto_promotions_manager.utils.saas_files_inventory import (
8
- SaasFilesInventory,
9
- )
10
- from reconcile.typed_queries.saas_files import SaasFile
11
-
12
-
13
- def test_use_target_config_hash(
14
- saas_files_builder: Callable[[Iterable[Mapping]], list[SaasFile]],
15
- ):
16
- saas_files = saas_files_builder([
17
- {
18
- "path": "/saas1.yml",
19
- "name": "saas_1",
20
- "resourceTemplates": [
21
- {
22
- "name": "template_1",
23
- "url": "repo1/url",
24
- "targets": [
25
- {
26
- "ref": "main",
27
- "namespace": {"path": "/namespace1.yml"},
28
- "promotion": {
29
- "publish": ["channel-a"],
30
- },
31
- }
32
- ],
33
- }
34
- ],
35
- },
36
- {
37
- "path": "/saas2.yml",
38
- "name": "saas_2",
39
- "publishJobLogs": True,
40
- "resourceTemplates": [
41
- {
42
- "name": "template_2",
43
- "url": "repo2/url",
44
- "targets": [
45
- {
46
- "ref": "main",
47
- "namespace": {"path": "/namespace2.yml"},
48
- "promotion": {
49
- "subscribe": ["channel-a"],
50
- "auto": True,
51
- },
52
- }
53
- ],
54
- }
55
- ],
56
- },
57
- ])
58
- inventory = SaasFilesInventory(saas_files=saas_files)
59
- assert len(inventory.publishers) == 2
60
- assert len(inventory.publishers_with_subscribers) == 1
61
- assert len(inventory.subscribers) == 1
62
- assert inventory.subscribers[0]._use_target_config_hash
@@ -1,73 +0,0 @@
1
- from collections.abc import (
2
- Callable,
3
- Iterable,
4
- Mapping,
5
- )
6
-
7
- from reconcile.saas_auto_promotions_manager.utils.saas_files_inventory import (
8
- SaasFilesInventory,
9
- )
10
- from reconcile.typed_queries.saas_files import SaasFile
11
-
12
-
13
- def test_single_channel(
14
- saas_files_builder: Callable[[Iterable[Mapping]], list[SaasFile]],
15
- ):
16
- saas_files = saas_files_builder([
17
- {
18
- "path": "/saas1.yml",
19
- "name": "saas_1",
20
- "resourceTemplates": [
21
- {
22
- "name": "template_1",
23
- "url": "repo1/url",
24
- "targets": [
25
- {
26
- "ref": "main",
27
- "namespace": {"path": "/namespace1.yml"},
28
- "promotion": {
29
- "publish": ["channel-a"],
30
- },
31
- }
32
- ],
33
- }
34
- ],
35
- },
36
- {
37
- "path": "/saas2.yml",
38
- "name": "saas_2",
39
- "resourceTemplates": [
40
- {
41
- "name": "template_2",
42
- "url": "repo2/url",
43
- "targets": [
44
- {
45
- "ref": "main",
46
- "namespace": {"path": "/namespace2.yml"},
47
- "promotion": {
48
- "subscribe": ["channel-a"],
49
- "auto": True,
50
- "promotion_data": [
51
- {
52
- "channel": "channel-a",
53
- "data": [
54
- {
55
- "target_config_hash": "channel-a-hash",
56
- "parent_saas": "saas_1",
57
- "type": "type",
58
- }
59
- ],
60
- }
61
- ],
62
- },
63
- }
64
- ],
65
- }
66
- ],
67
- },
68
- ])
69
- inventory = SaasFilesInventory(saas_files=saas_files)
70
- assert len(inventory.publishers) == 2
71
- assert len(inventory.publishers_with_subscribers) == 1
72
- assert len(inventory.subscribers) == 1
73
- assert not inventory.subscribers[0]._use_target_config_hash
@@ -1,64 +0,0 @@
1
- from collections.abc import (
2
- Callable,
3
- Iterable,
4
- Mapping,
5
- )
6
-
7
- from reconcile.saas_auto_promotions_manager.utils.saas_files_inventory import (
8
- SaasFilesInventory,
9
- )
10
- from reconcile.typed_queries.saas_files import SaasFile
11
-
12
-
13
- def test_saas_files_without_auto_promote(
14
- saas_files_builder: Callable[[Iterable[Mapping]], list[SaasFile]],
15
- ):
16
- saas_files = saas_files_builder([
17
- {
18
- "path": "/saas1.yml",
19
- "name": "saas_1",
20
- "resourceTemplates": [
21
- {
22
- "name": "template_1",
23
- "url": "repo1/url",
24
- "targets": [
25
- {
26
- "ref": "main",
27
- "namespace": {"path": "/namespace1.yml"},
28
- "promotion": {
29
- "publish": ["channel-a"],
30
- },
31
- }
32
- ],
33
- }
34
- ],
35
- },
36
- {
37
- "path": "/saas2.yml",
38
- "name": "saas_2",
39
- "resourceTemplates": [
40
- {
41
- "name": "template_2",
42
- "url": "repo2/url",
43
- "targets": [
44
- {
45
- "ref": "main",
46
- "namespace": {"path": "/namespace2.yml"},
47
- "promotion": {
48
- "publish": ["channel-b"],
49
- "subscribe": ["channel-a"],
50
- },
51
- },
52
- {
53
- "ref": "main",
54
- "namespace": {"path": "/namespace3.yml"},
55
- },
56
- ],
57
- }
58
- ],
59
- },
60
- ])
61
- inventory = SaasFilesInventory(saas_files=saas_files)
62
- assert len(inventory.publishers) == 2
63
- assert len(inventory.publishers_with_subscribers) == 0
64
- assert len(inventory.subscribers) == 0