aIbrahiim commented on code in PR #38815:
URL: https://github.com/apache/beam/pull/38815#discussion_r3357845795
##########
scripts/tools/bomupgrader.py:
##########
@@ -254,18 +255,54 @@ def write_back(self):
for line in self.target_lines:
fout.write(line)
+ def _get_opentelemetry_version(self):
+ for line in self.target_lines:
+ match = self.VERSION_STRING.match(line)
+ if match and match.group(1) == 'opentelemetry':
+ return match.group(2)
+ logging.warning('opentelemetry_version not found in BeamModulePlugin')
+ return None
+
+ @staticmethod
+ def _opentelemetry_license_yaml_block(version):
+ license_url = (
+ 'https://raw.githubusercontent.com/open-telemetry/'
+ 'opentelemetry-java/v{}/LICENSE'.format(version))
+ return (
+ 'opentelemetry-bom:\n'
+ " '{version}':\n"
+ ' license: "{license_url}"\n'
+ ' type: "Apache License 2.0"\n'
+ 'opentelemetry-bom-alpha:\n'
+ " '{version}-alpha':\n"
+ ' license: "{license_url}"\n'
+ ' type: "Apache License 2.0"\n'.format(
+ version=version, license_url=license_url))
+
def write_license_script(self):
logging.info("-----Update dep_urls_java.yaml-----")
- with open(os.path.join(self.project_root, self.LICENSE_SC_PATH),
- 'r') as fin:
- lines = fin.readlines()
- with open(os.path.join(self.project_root, self.LICENSE_SC_PATH),
- 'w') as fout:
- for idx, line in enumerate(lines):
- if line.strip() == 'libraries-bom:':
- lines[idx + 1] = re.sub(
- r'[\'"]\d[\.\d]+[\'"]', f"'{self.bom_version}'", lines[idx + 1])
- fout.write(line)
+ license_path = os.path.join(self.project_root, self.LICENSE_SC_PATH)
+ with open(license_path, 'r') as fin:
+ content = fin.read()
+
+ content = re.sub(
+ r"(libraries-bom:\n)(\s*['\"])\d[\d\.]+(['\"])",
+ r"\1\2{}\3".format(self.bom_version),
+ content,
+ count=1)
+
+ otel_version = self._get_opentelemetry_version()
+ if otel_version:
+ content = re.sub(
+ r'opentelemetry-bom:.*?(?=\nzstd-jni:)',
+ self._opentelemetry_license_yaml_block(otel_version),
+ content,
+ flags=re.DOTALL)
Review Comment:
I think it is fine with keeping it for now since OTel blocks sit directly
above zstd-jni in dep_urls_java.yaml
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]