Skip to content

Commit

Permalink
Merge pull request #170 from zscaler/zt-#170-fix-missformatted-ids
Browse files Browse the repository at this point in the history
Fix: Fixed ZIA Firewall Rule nested attribute ID format type
  • Loading branch information
willguibr authored Feb 14, 2024
2 parents 2dab1ab + 5e60b39 commit d76cf0f
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 6 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## 1.0.1 (February, 14 2024)

### Notes

- Release date: **(February, 14 2024)**
- Supported Terraform version: **v1.x.x**

### Bug Fixes

- [PR #170](https://github.com/zscaler/zscaler-terraformer/pull/170) Fixed ZIA ``zia_firewall_filtering_rule`` missformatted ID for rules containing the `users` nested block
- [PR #170](https://github.com/zscaler/zscaler-terraformer/pull/170) Upgraded to [Zscaler-SDK-GO v2.3.9](https://github.com/zscaler/zscaler-sdk-go/releases/tag/v2.3.9)

## 1.0.0 (January, 30 2024)

### Notes
Expand Down
15 changes: 14 additions & 1 deletion docs/guides/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,23 @@ Track all Zscaler Terraformer Tool releases. New resources, features, and bug fi

---

``Last updated: v1.0.0``
``Last updated: v1.0.1``

---

## 1.0.1 (February, 14 2024)

### Notes

- Release date: **(February, 14 2024)**
- Supported Terraform version: **v1.x.x**

### Bug Fixes

- [PR #170](https://github.com/zscaler/zscaler-terraformer/pull/170) Fixed ZIA ``zia_firewall_filtering_rule`` missformatted ID for rules containing the `users` nested block
- [PR #170](https://github.com/zscaler/zscaler-terraformer/pull/170) Upgraded to [Zscaler-SDK-GO v2.3.9](https://github.com/zscaler/zscaler-sdk-go/releases/tag/v2.3.9)


## 1.0.0 (January, 30 2024)

### Notes
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/spf13/viper v1.18.2
github.com/stretchr/testify v1.8.4
github.com/zclconf/go-cty v1.14.2
github.com/zscaler/zscaler-sdk-go/v2 v2.3.8
github.com/zscaler/zscaler-sdk-go/v2 v2.3.9
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSW
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
github.com/zclconf/go-cty v1.14.2 h1:kTG7lqmBou0Zkx35r6HJHUQTvaRPr5bIAf3AoHS0izI=
github.com/zclconf/go-cty v1.14.2/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE=
github.com/zscaler/zscaler-sdk-go/v2 v2.3.8 h1:ajdAHp0SSbY5BahC2EfQo/812v2QwpKaDjsnwtYSbAM=
github.com/zscaler/zscaler-sdk-go/v2 v2.3.8/go.mod h1:v8TLsPbVlQ3kAvGs8sIWsuhSAVggLbowiyDzaGYPWKg=
github.com/zscaler/zscaler-sdk-go/v2 v2.3.9 h1:7EcMIOKJqHABJonOdQEE/i4zjmGnZtxvr4O5woPJy9w=
github.com/zscaler/zscaler-sdk-go/v2 v2.3.9/go.mod h1:v8TLsPbVlQ3kAvGs8sIWsuhSAVggLbowiyDzaGYPWKg=
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI=
Expand Down
10 changes: 10 additions & 0 deletions internal/app/zscaler-terraformer/cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,16 @@ func generate(cmd *cobra.Command, writer io.Writer, resourceType string) {
case cty.Number:
value := structData[apiAttrName]

// Special handling for idle_time_in_minutes and surrogate_refresh_time_in_minutes to prevent scientific notation
if attrName == "idle_time_in_minutes" || attrName == "surrogate_refresh_time_in_minutes" {
floatValue, ok := value.(float64)
if ok {
// Explicitly convert and format as integer
output += fmt.Sprintf("%s = %d\n", attrName, int64(floatValue))
continue // Skip the rest of the logic for these specific fields
}
}

// Handle parent_id specially to prevent scientific notation.
if attrName == "parent_id" {
intValue, ok := value.(float64)
Expand Down
6 changes: 4 additions & 2 deletions internal/app/zscaler-terraformer/cmd/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ func nestBlocks(resourceType string, schemaBlock *tfjson.SchemaBlock, structData
}
output += "}\n"
continue
} else if isInList(resourceType, []string{"zia_firewall_filtering_network_service_groups", "zia_url_filtering_rules", "zia_dlp_web_rules", "zia_user_management"}) && isInList(block, []string{"departments",
} else if isInList(resourceType, []string{"zia_firewall_filtering_network_service_groups", "zia_firewall_filtering_rule", "zia_url_filtering_rules", "zia_dlp_web_rules", "zia_user_management"}) && isInList(block, []string{"departments",
"groups",
"locations",
"dlp_engines",
Expand All @@ -410,7 +410,9 @@ func nestBlocks(resourceType string, schemaBlock *tfjson.SchemaBlock, structData
} else if isInList(resourceType, []string{"zia_firewall_filtering_rule"}) && isInList(block, []string{"dest_ip_groups", "nw_services",
"departments",
"groups",
"time_windows"}) {
"time_windows",
"users",
}) {
output += listIdsIntBlock(block, structData[mapTfFieldNameToApi(resourceType, block)])
continue
} else if isInList(resourceType, []string{"zpa_application_segment",
Expand Down

0 comments on commit d76cf0f

Please sign in to comment.