Skip to content

Conversation

@takaishi
Copy link
Collaborator

@takaishi takaishi commented Jul 5, 2023

When using module, terraform-j2md should print module information in details, but doesn't print now. This PR fix it.

Expected:

### 1 to add, 0 to change, 0 to destroy, 0 to replace.
- add
    - module.test1.env_variable.test1
<details><summary>Change details</summary>

````````diff
# env_variable.test1 will be created
@@ -1 +1,3 @@
-null
+{
+  "name": "test1"
+}
````````

</details>

Current:

### 1 to add, 0 to change, 0 to destroy, 0 to replace.
- add
    - module.test1.env_variable.test1
<details><summary>Change details</summary>

````````diff
# module.test1.env_variable.test1 will be created
@@ -1 +1,3 @@
-null
+{
+  "name": "test1"
+}
````````

</details>

@takaishi takaishi self-assigned this Jul 5, 2023
@takaishi takaishi marked this pull request as ready for review July 5, 2023 23:59
@takaishi takaishi requested review from akihiro17 and okkez July 5, 2023 23:59
Copy link
Contributor

@okkez okkez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

Copy link
Contributor

@akihiro17 akihiro17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1点コメントしましたが良さそうです 🙆


func (r ResourceChangeData) Header() string {
var h []string
for _, s := range []string{r.ResourceChange.ModuleAddress, r.ResourceChange.Type, r.ResourceChange.Name} {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[IMO] Headerに使う要素が可変で事前に分からないときはこれで良いと思いますがこの3つしか使わないと分かっているので配列のループ回すよりは、r.ResourceChange.ModuleAddressが空じゃない場合は文字列にr.ResourceChange.ModuleAddress.を追加して、最後に r.ResourceChange.Type. r.ResourceChange.Nameを追加した方が分かりやすいんじゃないかと思いました。

@takaishi takaishi merged commit 7ba552f into master Jul 7, 2023
@takaishi takaishi deleted the fix_display_module_address branch July 7, 2023 00:12
@akihiro17
Copy link
Contributor

https://github.com/reproio/terraform-j2md/releases/tag/v0.0.6 リリースしました

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants