
This feature introduces support for creating local custom manifest files without losing visibility of new updates. It ensures flexibility for local customization while maintaining alignment with official changes Test Plan: - PASS: Build package with specific custom manifest directory (/custom-manifests) - PASS: Execute build-helm-charts.sh - PASS: Compare diffs between official and merged manifests Change-Id: Ifbdb14e30e8ecccba6b6f7a93ce0914247c7c71d Signed-off-by: jbarboza <joaopedro.barbozalioneza@windriver.com>
49 lines
1.5 KiB
Python
49 lines
1.5 KiB
Python
#!/usr/bin/python
|
|
#
|
|
# Copyright (c) 2024 Wind River Systems, Inc.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
|
|
import os
|
|
import sys
|
|
import ruamel.yaml as yaml
|
|
|
|
def merge_dicts(main: dict, custom: dict) -> None:
|
|
for key, value in custom.items():
|
|
if key in main and isinstance(main[key], dict) and isinstance(value, dict):
|
|
merge_dicts(main[key], value)
|
|
else:
|
|
main[key] = value
|
|
|
|
def handle_manifests_merge(main_manifests_path: str, custom_manifests_path: str):
|
|
with open(main_manifests_path, 'r') as main_file, open(custom_manifests_path, 'r') as custom_file:
|
|
main_data = yaml.safe_load(main_file)
|
|
custom_data = yaml.safe_load(custom_file)
|
|
|
|
# If both main file data and custom data are identical, no merge is needed
|
|
if main_data == custom_data:
|
|
return
|
|
|
|
# Handle empty YAML files as empty dictionaries for comparison purposes
|
|
main_data = {} if main_data is None else main_data
|
|
custom_data = {} if custom_data is None else custom_data
|
|
|
|
merged_data = main_data.copy()
|
|
|
|
merge_dicts(merged_data, custom_data)
|
|
|
|
with open(main_manifests_path, 'w') as main_file:
|
|
yaml.dump(merged_data, main_file, default_flow_style=False)
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main_manifests_path = sys.argv[1]
|
|
custom_manifests_path = sys.argv[2]
|
|
|
|
try:
|
|
handle_manifests_merge(main_manifests_path, custom_manifests_path)
|
|
except Exception as e:
|
|
print(f"Error trying to merge {main_manifests_path}: {e}")
|
|
sys.exit(1)
|