|
1 | 1 | import textwrap |
2 | 2 | from dataclasses import dataclass, field |
3 | 3 | from textwrap import indent |
4 | | -from typing import Callable |
| 4 | +from typing import Callable, Type |
5 | 5 |
|
6 | 6 |
|
7 | 7 | def heading(text: str, level: int=1) -> str: |
@@ -95,6 +95,7 @@ class Output: |
95 | 95 | type: str = None |
96 | 96 | aliases: list[str] = field(default_factory=list) |
97 | 97 | meta_output: bool = False |
| 98 | + available_in: list[Type[Terraform] | Type[OpenTofu]] = field(default_factory=lambda: [Terraform, OpenTofu]) |
98 | 99 |
|
99 | 100 | def markdown(self, tool: Tool) -> str: |
100 | 101 | if self.meta_output: |
@@ -182,6 +183,7 @@ def assert_ordering(self): |
182 | 183 | "plan_path", |
183 | 184 | "json_plan_path", |
184 | 185 | "text_plan_path", |
| 186 | + "junit-xml-path", |
185 | 187 | "to_add", |
186 | 188 | "failure-reason", |
187 | 189 | "lock-info", |
@@ -231,6 +233,8 @@ def markdown(self, tool: Tool) -> str: |
231 | 233 | s += text_chunk(self.outputs_intro) |
232 | 234 |
|
233 | 235 | for output in self.outputs: |
| 236 | + if tool not in output.available_in: |
| 237 | + continue |
234 | 238 | s += text_chunk(output.markdown(tool)) |
235 | 239 |
|
236 | 240 | if self.environment_variables: |
@@ -273,10 +277,10 @@ def action_yaml(self, tool: Tool) -> str: |
273 | 277 |
|
274 | 278 | s += '\n' |
275 | 279 |
|
276 | | - if [output for output in self.outputs if not output.meta_output]: |
| 280 | + if [output for output in self.outputs if not output.meta_output and tool in output.available_in]: |
277 | 281 | s += 'outputs:\n' |
278 | 282 |
|
279 | | - for output in self.outputs: |
| 283 | + for output in (output for output in self.outputs if not output.meta_output and tool in output.available_in): |
280 | 284 | if output.meta_output: |
281 | 285 | continue |
282 | 286 |
|
|
0 commit comments