Skip to content

Commit 044545d

Browse files
committed
fix: update comments from Russian to English for better clarity
1 parent 6d21903 commit 044545d

File tree

7 files changed

+55
-55
lines changed

7 files changed

+55
-55
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pip install .
2828

2929
The `generate` command creates an application manifest based on a [configuration file](./example/jaeger/qubership-jaeger-am-build.yaml) and, if needed, [additional component files](./example/jaeger/).
3030

31-
### Синтаксис
31+
### Syntax
3232

3333
```bash
3434
python -m venv venv

src/app_manifest_cli/commands/generate.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,18 @@ def generate_command(
2828
if out == None:
2929
out = name + '-' + version + '.json'
3030
body = create_command(name=name, version=version, out=open(out, "w"))
31-
# Получаю компоненты из конфига -- именно они определяют состав манифеста
31+
# Get components from config -- they define the manifest composition
3232
config_components = get_components_from_data(configuration_data)
33-
# Получаю депенденси из конфига
33+
# Get dependencies from config
3434
config_dependencies = load_dependencies(config_components)
35-
# Читаю все json файлы с компонентами
35+
# Read all JSON files with components
3636
json_components = []
3737
if components_files:
3838
for json_path in components_files:
3939
with open(json_path.resolve(), "r", encoding="utf-8") as f:
4040
json_comp = json.load(f)
4141
json_components.append(json_comp)
42-
# Перебираю компоненты из конфига, если в json_components есть такой же, то обновляю его
42+
# Iterate through components from config, if the same exists in json_components, then update it
4343
components = []
4444
for conf_comp in config_components:
4545
conf_comp['mime-type'] = conf_comp["mimeType"]
@@ -52,24 +52,24 @@ def generate_command(
5252
conf_comp["bom-ref"] = get_bom_ref(conf_comp["name"])
5353
components.append(conf_comp)
5454

55-
# Генерирую дополнительные метаданные для helm chart
56-
# добавляю properies с именем qubership:helm.values.artifactMappings
57-
# и значением в виде dict, где ключ - bom-ref зависимости, а значение - dict с ключом valuesPathPrefix и значением из конфигурации
55+
# Generate additional metadata for helm chart
56+
# add properties named qubership:helm.values.artifactMappings
57+
# with value as a dict, where key is bom-ref of dependency, and value is a dict with valuesPathPrefix key and value from configuration
5858

5959
components = generate_helm_values_artifact_mappings(components)
60-
# Если включено discovery, то запускаю его
61-
# дополняя компоненты зависимостями и свойствами
60+
# If discovery is enabled, run it
61+
# enriching components with dependencies and properties
6262
# if discovery:
6363
components = helm_discovery(components)
64-
# Добавляю все компоненты в манифест
64+
# Add all components to the manifest
6565
for comp in components:
6666
if comp.get("mime-type") == "application/vnd.qubership.standalone-runnable":
6767
if comp.get("version", "") == "":
6868
comp["version"] = version
6969
typer.echo(f"Adding component: {comp['name']} with mime-type: {comp['mime-type']}")
7070
#typer.echo(f"comp details: {json.dumps(comp, indent=2)}")
7171
_add_component(manifest_path=out, payload_text=json.dumps(obj=comp,sort_keys=True), out_file=None)
72-
# Формирую простой список компонент для удобства поиска
72+
# Form a simple list of components for easy search
7373
components_list = [ comp["mime-type"] + ":" + comp["name"] for comp in components]
7474
for dep in config_dependencies:
7575
dep_record = {}
@@ -117,11 +117,11 @@ def load_configuration(configuration: str) -> dict:
117117
# raise ValueError("Configuration file must contain 'dependencies' section")
118118
return configuration_data
119119

120-
# Здесь я предполагаю, что в конфиге dependencies описываются внутри каждого компонента
121-
# в виде списка dependsOn, где каждый элемент содержит name и mime-type
122-
# Преобразую это в список словарей с ключами name, ref и dependsOn
123-
# ref - это mime-type:name
124-
# dependsOn - это список ref зависимостей
120+
# Here I assume that in the config dependencies are described inside each component
121+
# in the form of dependsOn list, where each element contains name and mime-type
122+
# Transform this into a list of dictionaries with keys name, ref and dependsOn
123+
# ref is mime-type:name
124+
# dependsOn is a list of dependency refs
125125
def load_dependencies(config_data: dict) -> List:
126126
deps = []
127127
for comp in config_data:
@@ -139,15 +139,15 @@ def load_dependencies(config_data: dict) -> List:
139139
deps.append({"name": deps_elem_name, "ref": deps_elem_ref, "dependsOn": deps_elem_depends_on})
140140
return deps
141141

142-
# Функция, которая получает на вход список компонент из манифеста (чтобы найти bom-ref по имени)
143-
# Что она делает:
144-
# 1. если mime-type компоненты == application/vnd.qubership.helm.chart
145-
# 2. если у компонента есть dependsOn, то перебирает все зависимости и проверяет есть ли у каждой зависимости параметр valuesPathPrefix
146-
# 3. если есть, то создаёт dict с ключами:
147-
# "name": "qubership:helm.values.artifactMappings" и
148-
# "value": {"bom-ref зависимости": {"valuesPathPrefix": "значение из зависимости"}, ...}
149-
# 4. добавляет этот dict в properties компонента
150-
# 5. возвращает обновлённый список компонентов
142+
# Function that receives a list of components from the manifest (to find bom-ref by name)
143+
# What it does:
144+
# 1. if component mime-type == application/vnd.qubership.helm.chart
145+
# 2. if the component has dependsOn, iterate through all dependencies and check if each dependency has valuesPathPrefix parameter
146+
# 3. if yes, create a dict with keys:
147+
# "name": "qubership:helm.values.artifactMappings" and
148+
# "value": {"dependency bom-ref": {"valuesPathPrefix": "value from dependency"}, ...}
149+
# 4. add this dict to component properties
150+
# 5. return the updated list of components
151151
def generate_helm_values_artifact_mappings(manifest_components: List[dict]) -> dict | None:
152152
components = []
153153
for component in manifest_components:
@@ -162,7 +162,7 @@ def generate_helm_values_artifact_mappings(manifest_components: List[dict]) -> d
162162
if "valuesPathPrefix" in dep:
163163
dep_name = dep.get("name")
164164
dep_mime = dep.get("mimeType", dep.get("mime-type"))
165-
# Ищу в manifest_components компонент с таким же name и mime-type, чтобы взять его bom-ref
165+
# Search in manifest_components for a component with the same name and mime-type to get its bom-ref
166166
matching_comp = next((comp for comp in manifest_components if comp["name"] == dep_name and comp["mime-type"] == dep_mime), None)
167167
print(f" Processing dependency: {dep_name}, found matching component: {matching_comp is not None}")
168168
if matching_comp and "bom-ref" in matching_comp:

src/app_manifest_cli/handlers/docker_handler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
def handle(obj: dict) -> dict:
55

6-
# DAO Тут можно добавить логику обработки входящего json Docker Image
6+
# DAO Here you can add logic for processing incoming json Docker Image
77
DOCKER_REQUIRED_FIELDS = ["type",
88
"mime-type",
99
"bom-ref",
@@ -33,7 +33,7 @@ def handle(obj: dict) -> dict:
3333
if field not in obj:
3434
raise ValueError(f"Missing required field '{field}' in docker image component")
3535
#print("Running docker_image handler")
36-
# удаляю лишние поля из obj
36+
# Remove extra fields from obj
3737
for field in list(obj.keys()):
3838
if field not in DOCKER_FIELDS:
3939
print(f" Warning: Unknown field '{field}' in docker image component")

src/app_manifest_cli/handlers/helm_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
def handle(obj: dict) -> dict:
55

6-
# DAO Тут можно добавить логику обработки входящего json Helm Chart
6+
# DAO Here you can add logic for processing incoming json Helm Chart
77
CHART_REQUIRED_FIELDS = [
88
"type",
99
"mime-type",

src/app_manifest_cli/handlers/standalone_runnable_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
def handle(obj: dict) -> dict:
44

5-
# DAO Тут можно добавить логику обработки входящего json standalone-runnable
5+
# DAO Here you can add logic for processing incoming json standalone-runnable
66
STANDALONE_RUNNABLE_REQUIRED_FIELDS = [
77
"type",
88
"mime-type",

src/app_manifest_cli/services/helm_discovery.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77
from typing import List
88
from ..commands.create import get_bom_ref
99
from ..services.purl_url import url_2_purl
10-
# Здесь должны быть методы для работы с helm chart
11-
# для генерации дополнительных метаданных
12-
# На входе получаем url чарта
13-
# командами helm скачиваем чарт
14-
# распаковываем его
15-
# 1. Читаем Chart.yaml, чтобы:
16-
# - узнать его type, если type: library, то добавляем в манифест property isLibrary=true
17-
# - узнать, есть ли у него dependencies, если есть, то для каждой зависимости добавляем вложенную component в компоненту этого чарта в манифесте
18-
# 2. Проверяем,есть ли в чарте файл с именем values.schema.json
19-
# если есть, то шифруем файл в base64 и добавляем в component чарта вложенный объект
10+
# Here should be methods for working with helm charts
11+
# for generating additional metadata
12+
# Input: chart url
13+
# Download chart using helm commands
14+
# Unpack it
15+
# 1. Read Chart.yaml to:
16+
# - determine its type, if type: library, then add property isLibrary=true to manifest
17+
# - determine if it has dependencies, if yes, for each dependency add a nested component to this chart's component in manifest
18+
# 2. Check if the chart has a file named values.schema.json
19+
# if yes, encode the file in base64 and add a nested object to the chart component
2020
# "components": [
2121
# {
2222
# "bom-ref": "qubership-jaeger-values-schema:7f17a6dc-b973-438f-abb7-e0c57a32afc5",
@@ -65,14 +65,14 @@
6565
# def helm_discovery(components: List) -> List:
6666
# if components is None:
6767
# return {}
68-
# # Проверяю, что helm установлен
68+
# # Check that helm is installed
6969
# try:
7070
# subprocess.run("helm version", shell=True, text=True, check=True, capture_output=True)
7171
# except subprocess.CalledProcessError as e:
7272
# print("Helm is not installed or not found in PATH. Please install Helm to use helm discovery.", file=sys.stderr)
7373
# return components
7474
# print("Helm is installed, proceeding with helm discovery.")
75-
# # Иду по всем компонентам, у которых mime-type application/vnd.qubership.helm.chart
75+
# # Iterate through all components with mime-type application/vnd.qubership.helm.chart
7676
# for comp in [f for f in components if f['mime-type'] == 'application/vnd.qubership.helm.chart']:
7777
# chart = single_chart_discovery(comp)
7878
# comp.update(chart)
@@ -91,7 +91,7 @@ def helm_discovery(components: List) -> List:
9191
charts = [f for f in components if f['mime-type'] == 'application/vnd.qubership.helm.chart']
9292
with concurrent.futures.ThreadPoolExecutor() as executor:
9393
results = list(executor.map(single_chart_discovery, charts))
94-
# Обновляем компоненты результатами
94+
# Update components with results
9595
chart_names = {c['name'] for c in charts}
9696
for i, comp in enumerate(components):
9797
if comp['name'] in chart_names:
@@ -100,15 +100,15 @@ def helm_discovery(components: List) -> List:
100100

101101
def single_chart_discovery(chart: dict) -> dict:
102102
try:
103-
# делаю директорию для скачивания чарта с рандомным именем
103+
# Create directory for downloading chart with random name
104104
chart_dir = f"chart-{os.urandom(4).hex()}"
105105
os.makedirs(chart_dir, exist_ok=True)
106106
if chart.get("mime-type") != "application/vnd.qubership.helm.chart":
107107
print(f"Component {chart['name']} isn't a chart.")
108108
return chart
109109
if not chart['reference']:
110110
raise ValueError("Helm chart component must have reference")
111-
# Тут должна быть логика скачивания чарта по purl, распаковки и чтения файлов
111+
# Here should be the logic for downloading chart by purl, unpacking and reading files
112112
chart_url = chart["reference"]
113113
print(f"Discovering helm chart: {chart['name']} with reference: {chart['reference']}")
114114
try:
@@ -126,7 +126,7 @@ def single_chart_discovery(chart: dict) -> dict:
126126
chart["properties"] = []
127127
chart["properties"].append({"name": "isLibrary", "value": chart_info.get("type") == "library"})
128128

129-
# Проверяю наличие dependencies
129+
# Check for dependencies
130130
if "dependencies" not in chart_info:
131131
print(f"No dependencies found in chart {chart['name']}")
132132
# continue
@@ -146,7 +146,7 @@ def single_chart_discovery(chart: dict) -> dict:
146146
"properties": [],
147147
"components": []
148148
})
149-
# Проверяю наличие values.schema.json
149+
# Check for values.schema.json
150150
if os.path.isfile(os.path.join(chart_dir, chart['name'], "values.schema.json")):
151151
with open(os.path.join(chart_dir, chart['name'], "values.schema.json"), 'rb') as f:
152152
encoded_content = base64.b64encode(f.read()).decode('utf-8')
@@ -169,7 +169,7 @@ def single_chart_discovery(chart: dict) -> dict:
169169
}
170170
}]
171171
})
172-
# Проверяю наличие resource-profiles directory
172+
# Check for resource-profiles directory
173173
resource_profiles_path = os.path.join(chart_dir, chart['name'], "resource-profiles")
174174
if os.path.isdir(resource_profiles_path):
175175
profile_files = [f for f in os.listdir(resource_profiles_path) if os.path.isfile(os.path.join(resource_profiles_path, f)) and f.endswith(('.yaml', '.yml', '.json'))]
@@ -203,7 +203,7 @@ def single_chart_discovery(chart: dict) -> dict:
203203
except Exception as e:
204204
print(f"Error processing helm chart component {chart.get('name', 'unknown')}: {e}", file=sys.stderr)
205205
finally:
206-
# Удаляю директорию чарта
206+
# Delete chart directory
207207
if os.path.isdir(chart_dir):
208208
subprocess.run(f"rm -rf {chart_dir}", shell=True)
209209
return chart

src/app_manifest_cli/services/standalone_runnable.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Здесь происходит наполнение данных о компоненте с mime-type application/vnd.qubership.standalone-runnable
2-
# Входные данные:
3-
# - путь к каталогу с файлами конфигурации (.yaml или .yml или .json)
4-
# - dict компоненты, в которую нужно добавить вложенные объекты с конфигурациями
5-
# Выходные данные: dict вида
1+
# Here the data is populated for a component with mime-type application/vnd.qubership.standalone-runnable
2+
# Input data:
3+
# - path to directory with configuration files (.yaml or .yml or .json)
4+
# - component dict to which nested objects with configurations need to be added
5+
# Output data: dict of the form
66
# {
77
# "bom-ref": "qubership-jaeger:61439aff-c00d-43f5-9bae-fe6db05db2d5",
88
# "type": "application",

0 commit comments

Comments
 (0)