Skip to content

Commit

Permalink
Update structured output based on experience using in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
allenporter committed Feb 27, 2023
1 parent 9323004 commit 627cb55
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
7 changes: 3 additions & 4 deletions flux_local/tool/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,16 @@ def str_presenter(dumper: yaml.Dumper, data: Any) -> Any:
diff_text = difflib.unified_diff(
a=a_resources.get(resource_key, []),
b=b_resources.get(resource_key, []),
fromfile=f"{kustomization_key.label} {resource_key.label}",
tofile=f"{kustomization_key.label} {resource_key.label}",
n=n,
)
diff_content = "\n".join(diff_text)
if not diff_content:
continue
obj = {
**asdict(resource_key, dict_factory=omit_none),
"diff_markdown": f"""{resource_key.kind} {resource_key.namespace}/{resource_key.name}
```diff
{diff_content}
```""", # noqa: E501
"diff": diff_content,
}
resource_diffs.append(obj)
if resource_diffs:
Expand Down
4 changes: 2 additions & 2 deletions flux_local/tool/visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ def label(self) -> str:
parts = []
if self.path:
parts.append(self.path)
parts.append(" - ")
parts.append(" ")
parts.append(self.kind)
parts.append("=")
parts.append(": ")
if self.namespace:
parts.append(self.namespace)
parts.append("/")
Expand Down
4 changes: 2 additions & 2 deletions tests/tool/test_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ async def test_diff_ks() -> None:

assert (
result
== """--- tests/testdata/cluster/apps/prod - Kustomization=flux-system/apps ConfigMap=podinfo/podinfo-config
== """--- tests/testdata/cluster/apps/prod Kustomization: flux-system/apps ConfigMap: podinfo/podinfo-config
+++ tests/testdata/cluster/apps/prod - Kustomization=flux-system/apps ConfigMap=podinfo/podinfo-config
+++ tests/testdata/cluster/apps/prod Kustomization: flux-system/apps ConfigMap: podinfo/podinfo-config
@@ -1,9 +0,0 @@
Expand Down

0 comments on commit 627cb55

Please sign in to comment.