@@ -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
125125def 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
151151def 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 :
0 commit comments