mirror of
https://github.com/TeamPiped/Piped-Kubernetes.git
synced 2025-04-27 07:10:33 +05:30
fix(ci): Refactor YAML dumping of annotations for improved clarity and structure
This commit is contained in:
parent
3c8da7e8ca
commit
800070646f
26
.github/scripts/renovate-releasenotes.py
vendored
26
.github/scripts/renovate-releasenotes.py
vendored
@ -9,7 +9,7 @@ from pathlib import Path
|
|||||||
|
|
||||||
from ruamel.yaml import YAML
|
from ruamel.yaml import YAML
|
||||||
from ruamel.yaml.comments import CommentedMap
|
from ruamel.yaml.comments import CommentedMap
|
||||||
from ruamel.yaml.scalarstring import LiteralScalarString, PreservedScalarString
|
from ruamel.yaml.scalarstring import PreservedScalarString
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
app = typer.Typer(add_completion=False)
|
app = typer.Typer(add_completion=False)
|
||||||
@ -190,17 +190,27 @@ def main(
|
|||||||
})
|
})
|
||||||
|
|
||||||
if annotations:
|
if annotations:
|
||||||
annotations_stream = io.StringIO()
|
annotations_data = [
|
||||||
yaml.exclude_start = False
|
{"kind": annotation["kind"], "description": annotation["description"]}
|
||||||
yaml.dump_all([annotations], annotations_stream)
|
for annotation in annotations
|
||||||
|
]
|
||||||
|
|
||||||
annotations_string = annotations_stream.getvalue().strip()
|
with io.StringIO() as annotations_stream:
|
||||||
annotations_stream.close()
|
yaml.explicit_start = False # You likely want this to be false so that the output doesn't have '---'
|
||||||
|
|
||||||
|
for annotation in annotations_data:
|
||||||
|
annotations_stream.write(
|
||||||
|
f"- kind: {annotation['kind']}\n"
|
||||||
|
f" description: {annotation['description']}\n"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Get the final YAML string and strip leading/trailing whitespace
|
||||||
|
annotations_string = annotations_stream.getvalue().strip()
|
||||||
|
|
||||||
if "annotations" not in new_chart_metadata:
|
if "annotations" not in new_chart_metadata:
|
||||||
new_chart_metadata["annotations"] = CommentedMap()
|
new_chart_metadata["annotations"] = CommentedMap()
|
||||||
|
|
||||||
new_chart_metadata["annotations"]["artifacthub.io/changes"] = LiteralScalarString(annotations_string)
|
new_chart_metadata["annotations"]["artifacthub.io/changes"] = PreservedScalarString(annotations_string)
|
||||||
|
|
||||||
logger.debug(f"Annotations: {annotations_string}")
|
logger.debug(f"Annotations: {annotations_string}")
|
||||||
logger.debug(new_chart_metadata)
|
logger.debug(new_chart_metadata)
|
||||||
@ -208,7 +218,7 @@ def main(
|
|||||||
new_chart_metadata = bump_patch_version(new_chart_metadata)
|
new_chart_metadata = bump_patch_version(new_chart_metadata)
|
||||||
|
|
||||||
with chart_metadata_file.open("w") as f:
|
with chart_metadata_file.open("w") as f:
|
||||||
yaml.exclude_start = False
|
yaml.explicit_start = True
|
||||||
yaml.dump(new_chart_metadata, f)
|
yaml.dump(new_chart_metadata, f)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user