qontract-reconcile 0.10.1rc1018__py3-none-any.whl → 0.10.1rc1020__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: qontract-reconcile
3
- Version: 0.10.1rc1018
3
+ Version: 0.10.1rc1020
4
4
  Summary: Collection of tools to reconcile services with their desired state as defined in the app-interface DB.
5
5
  Home-page: https://github.com/app-sre/qontract-reconcile
6
6
  Author: Red Hat App-SRE Team
@@ -644,7 +644,7 @@ reconcile/unleash_feature_toggles/integration.py,sha256=nx7BhtzCsTfPbOp60vI5MkNw
644
644
  reconcile/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
645
645
  reconcile/utils/aggregated_list.py,sha256=km0xadW0jO4G_CqZPsXmoBURQ8c90FaTu5x4X1K1cZs,3357
646
646
  reconcile/utils/amtool.py,sha256=ngtBuVPETH6oAy5RnKzvreVbjwQCaATS_PYYwBprzjQ,2288
647
- reconcile/utils/aws_api.py,sha256=FHE7tVN91ZAVDARN9EYr7kY3kB6UWtvZSlsvHcDyzx8,66830
647
+ reconcile/utils/aws_api.py,sha256=0Sh83kX8tk-XGwsWbNI19miuits71c3btKxGVhyApuY,66860
648
648
  reconcile/utils/aws_helper.py,sha256=MDbv5jrNdqqJ5pfBxniGdJXBBO_EYc2_Uf2w9ZzeMNs,2854
649
649
  reconcile/utils/batches.py,sha256=TtEm64a8lWhFuNbUVpFEmXVdU2Q0sTBrP_I0Cjbgh7g,320
650
650
  reconcile/utils/binary.py,sha256=7MaAFBpzuBUTJ_aA6G6-eult_BPMVyiXbBLD0Y6F-DM,2301
@@ -775,7 +775,7 @@ reconcile/utils/mr/labels.py,sha256=9QRTRjZAtq45zELd9SwavaraczMjwjn5no3RK1YxFTg,
775
775
  reconcile/utils/mr/notificator.py,sha256=cp80wFzu_ZzrJPye7L1pI0H6JRGb7hOGuNxJYUq4Yr8,2967
776
776
  reconcile/utils/mr/ocm_update_recommended_version.py,sha256=p_aVP0TGrlKk9WBwgQnYWqUDsED_Hg6G5Bqj0UvtRwA,1536
777
777
  reconcile/utils/mr/ocm_upgrade_scheduler_org_updates.py,sha256=ojnIjw-8vRnmCCxOGBOEgPZLH4nC1hcuef74LWw2Rpk,3004
778
- reconcile/utils/mr/promote_qontract.py,sha256=6WWCSOU9B7P1VY8z7PCFWCnHA0LM0RuOwkZPWsFR700,6095
778
+ reconcile/utils/mr/promote_qontract.py,sha256=4rUMZJGor2AE84BMqnekSbmFyu3ZOUfkxwel8Hnc3-M,5948
779
779
  reconcile/utils/mr/user_maintenance.py,sha256=cHPBn8zrReWLHalyk-EFdkFJe9zjVjRoZhT4t2zZfGE,3956
780
780
  reconcile/utils/ocm/__init__.py,sha256=xv7CJp7K9LCQfa4gL_W0MMCOD1P4qOy8t5aZj1xXNUE,808
781
781
  reconcile/utils/ocm/addons.py,sha256=_LDdJ-gapM3s5exKlIUt-MlXZTAUoHezbYBU0QmvfWQ,7335
@@ -859,8 +859,8 @@ tools/test/test_qontract_cli.py,sha256=_D61RFGAN5x44CY1tYbouhlGXXABwYfxKSWSQx3Jr
859
859
  tools/test/test_saas_promotion_state.py,sha256=dy4kkSSAQ7bC0Xp2CociETGN-2aABEfL6FU5D9Jl00Y,6056
860
860
  tools/test/test_sd_app_sre_alert_report.py,sha256=v363r9zM7__0kR5K6mvJoGFcM9BvE33fWAayrqkpojA,2116
861
861
  tools/test/test_sre_checkpoints.py,sha256=SKqPPTl9ua0RFdSSofnoQX-JZE6dFLO3LRhfQzqtfh8,2607
862
- qontract_reconcile-0.10.1rc1018.dist-info/METADATA,sha256=3OZq-m7eRqQY8igAdMP63_3OWuW5raq16rrwa8kfB14,2263
863
- qontract_reconcile-0.10.1rc1018.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
864
- qontract_reconcile-0.10.1rc1018.dist-info/entry_points.txt,sha256=GKQqCl2j2X1BJQ69een6rHcR26PmnxnONLNOQB-nRjY,491
865
- qontract_reconcile-0.10.1rc1018.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
866
- qontract_reconcile-0.10.1rc1018.dist-info/RECORD,,
862
+ qontract_reconcile-0.10.1rc1020.dist-info/METADATA,sha256=nlUFKwjsUyVZVDAbzvIF_4FhV-g1XlrJk91Z7lLRsjI,2263
863
+ qontract_reconcile-0.10.1rc1020.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
864
+ qontract_reconcile-0.10.1rc1020.dist-info/entry_points.txt,sha256=GKQqCl2j2X1BJQ69een6rHcR26PmnxnONLNOQB-nRjY,491
865
+ qontract_reconcile-0.10.1rc1020.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
866
+ qontract_reconcile-0.10.1rc1020.dist-info/RECORD,,
@@ -1384,7 +1384,7 @@ class AWSApi: # pylint: disable=too-many-public-methods
1384
1384
  if not zones:
1385
1385
  return []
1386
1386
  zone_id = self._get_hosted_zone_id(zones[0])
1387
- return route53.list_resource_record_sets(HostedZoneId=zone_id)[
1387
+ return route53.list_resource_record_sets(HostedZoneId=zone_id)[ # type: ignore[return-value]
1388
1388
  "ResourceRecordSets"
1389
1389
  ]
1390
1390
 
@@ -1,3 +1,4 @@
1
+ from jsonpath_ng.ext import parser
1
2
  from ruamel.yaml.compat import StringIO
2
3
 
3
4
  from reconcile.utils.gitlab_api import GitLabApi
@@ -63,82 +64,61 @@ class PromoteQontractReconcileCommercial(MergeRequestBase):
63
64
  def description(self) -> str:
64
65
  return f"promote qontract-reconcile to version {self.version}"
65
66
 
66
- def process(self, gitlab_cli: GitLabApi) -> None:
67
- yml = create_ruamel_instance()
68
-
69
- # .env
70
- path = ".env"
71
- raw_file = gitlab_cli.project.files.get(
72
- file_path=path, ref=gitlab_cli.main_branch
73
- ).decode()
67
+ def _process_by_line_search(
68
+ self, raw_file: bytes, search_text: str, replace_text: str
69
+ ) -> str:
74
70
  content = raw_file.decode("utf-8")
75
71
  lines = content.splitlines()
76
72
  for index, text in enumerate(lines):
77
- if text.startswith("export RECONCILE_IMAGE_TAG="):
78
- lines[index] = f"export RECONCILE_IMAGE_TAG={self.version}"
73
+ if text.startswith(search_text):
74
+ lines[index] = replace_text
79
75
  new_content = "\n".join(lines) + "\n"
80
- gitlab_cli.update_file(
81
- branch_name=self.branch,
82
- file_path=path,
83
- commit_message=self.description,
84
- content=new_content,
85
- )
86
76
 
87
- # resources/jenkins/global/defaults.yaml
88
- path = "resources/jenkins/global/defaults.yaml"
89
- raw_file = gitlab_cli.project.files.get(
90
- file_path=path, ref=gitlab_cli.main_branch
91
- ).decode()
92
- content = raw_file.decode("utf-8")
93
- lines = content.splitlines()
94
- for index, text in enumerate(lines):
95
- if text.startswith(" qontract_reconcile_image_tag: "):
96
- lines[index] = f" qontract_reconcile_image_tag: '{self.version}'"
97
- new_content = "\n".join(lines) + "\n"
98
- gitlab_cli.update_file(
99
- branch_name=self.branch,
100
- file_path=path,
101
- commit_message=self.description,
102
- content=new_content,
103
- )
77
+ return new_content
104
78
 
105
- # data/services/app-interface/cicd/ci-ext/saas-qontract-dashboards.yaml
106
- path = "data/services/app-interface/cicd/ci-ext/saas-qontract-dashboards.yaml"
107
- raw_file = gitlab_cli.project.files.get(
108
- file_path=path, ref=gitlab_cli.main_branch
109
- ).decode()
79
+ def _process_by_json_path(
80
+ self, raw_file: bytes, search_text: str, replace_text: str
81
+ ) -> str:
82
+ yml = create_ruamel_instance()
110
83
  content = yml.load(raw_file)
111
- for rt in content["resourceTemplates"]:
112
- if rt["url"] == "https://github.com/app-sre/qontract-reconcile":
113
- for t in rt["targets"]:
114
- if t["name"] == "app-sre-observability-production":
115
- t["ref"] = self.commit_sha
84
+ for match in parser.parse(search_text).find(content):
85
+ parent = match.context.value
86
+ key = match.path.fields[0]
87
+ parent[key] = replace_text
116
88
  new_content = "---\n"
117
89
  with StringIO() as stream:
118
90
  yml.dump(content, stream)
119
91
  new_content += stream.getvalue() or ""
120
- gitlab_cli.update_file(
121
- branch_name=self.branch,
122
- file_path=path,
123
- commit_message=self.description,
124
- content=new_content,
125
- )
126
92
 
127
- # data/services/app-interface/cicd/ci-int/saas-qontract-manager-int.yaml
128
- path = "data/services/app-interface/cicd/ci-int/saas-qontract-manager-int.yaml"
93
+ return new_content
94
+
95
+ def _process_by(
96
+ self,
97
+ method: str,
98
+ gitlab_cli: GitLabApi,
99
+ path: str,
100
+ search_text: str,
101
+ replace_text: str,
102
+ ) -> None:
129
103
  raw_file = gitlab_cli.project.files.get(
130
104
  file_path=path, ref=gitlab_cli.main_branch
131
105
  ).decode()
132
- content = yml.load(raw_file)
133
- for rt in content["resourceTemplates"]:
134
- if rt["url"] == "https://github.com/app-sre/qontract-reconcile":
135
- for t in rt["targets"]:
136
- if t["name"] == "app-interface-production":
137
- t["ref"] = self.commit_sha
138
- new_content = "---\n"
139
- with StringIO() as stream:
140
- yml.dump(content, stream)
141
- new_content += stream.getvalue() or ""
106
+ match method:
107
+ case "line_search":
108
+ new_content = self._process_by_line_search(
109
+ raw_file=raw_file,
110
+ search_text=search_text,
111
+ replace_text=replace_text,
112
+ )
113
+ case "json_path":
114
+ new_content = self._process_by_json_path(
115
+ raw_file=raw_file,
116
+ search_text=search_text,
117
+ replace_text=replace_text,
118
+ )
119
+ case _:
120
+ raise NotImplementedError(method)
121
+
142
122
  gitlab_cli.update_file(
143
123
  branch_name=self.branch,
144
124
  file_path=path,
@@ -146,22 +126,48 @@ class PromoteQontractReconcileCommercial(MergeRequestBase):
146
126
  content=new_content,
147
127
  )
148
128
 
129
+ def process(self, gitlab_cli: GitLabApi) -> None:
130
+ # .env
131
+ self._process_by(
132
+ "line_search",
133
+ gitlab_cli=gitlab_cli,
134
+ path=".env",
135
+ search_text="export RECONCILE_IMAGE_TAG=",
136
+ replace_text=f"export RECONCILE_IMAGE_TAG={self.version}",
137
+ )
138
+
139
+ # resources/jenkins/global/defaults.yaml
140
+ self._process_by(
141
+ "line_search",
142
+ gitlab_cli=gitlab_cli,
143
+ path="resources/jenkins/global/defaults.yaml",
144
+ search_text=" qontract_reconcile_image_tag: ",
145
+ replace_text=f" qontract_reconcile_image_tag: '{self.version}'",
146
+ )
147
+
148
+ # data/services/app-interface/cicd/ci-ext/saas-qontract-dashboards.yaml
149
+ self._process_by(
150
+ "json_path",
151
+ gitlab_cli=gitlab_cli,
152
+ path="data/services/app-interface/cicd/ci-ext/saas-qontract-dashboards.yaml",
153
+ search_text="$.resourceTemplates[?(@.url == 'https://github.com/app-sre/qontract-reconcile')].targets[?(@.name == 'app-sre-observability-production')].ref",
154
+ replace_text=self.commit_sha,
155
+ )
156
+
157
+ # data/services/app-interface/cicd/ci-int/saas-qontract-manager-int.yaml
158
+ self._process_by(
159
+ "json_path",
160
+ gitlab_cli=gitlab_cli,
161
+ path="data/services/app-interface/cicd/ci-int/saas-qontract-manager-int.yaml",
162
+ search_text="$.resourceTemplates[?(@.url == 'https://github.com/app-sre/qontract-reconcile')].targets[?(@.name == 'app-interface-production')].ref",
163
+ replace_text=self.commit_sha,
164
+ )
165
+
149
166
  # data/pipelines/tekton-provider-global-defaults.yaml
150
- path = "data/pipelines/tekton-provider-global-defaults.yaml"
151
- raw_file = gitlab_cli.project.files.get(
152
- file_path=path, ref=gitlab_cli.main_branch
153
- ).decode()
154
- content = yml.load(raw_file)
155
- for tt in content["taskTemplates"]:
156
- if tt["name"] == "openshift-saas-deploy":
157
- tt["variables"]["qontract_reconcile_image_tag"] = self.version
158
- new_content = "---\n"
159
- with StringIO() as stream:
160
- yml.dump(content, stream)
161
- new_content += stream.getvalue() or ""
162
- gitlab_cli.update_file(
163
- branch_name=self.branch,
164
- file_path=path,
165
- commit_message=self.description,
166
- content=new_content,
167
+ self._process_by(
168
+ "json_path",
169
+ gitlab_cli=gitlab_cli,
170
+ path="data/pipelines/tekton-provider-global-defaults.yaml",
171
+ search_text="$.taskTemplates[?(@.name == 'openshift-saas-deploy')].variables.qontract_reconcile_image_tag",
172
+ replace_text=self.commit_sha,
167
173
  )