Skip to content

Commit

Permalink
Fix: Fixed Application Segment Port Configuration Resource
Browse files Browse the repository at this point in the history
  • Loading branch information
willguibr committed Oct 4, 2024
1 parent 7210f29 commit adc22ca
Show file tree
Hide file tree
Showing 31 changed files with 920 additions and 864 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/zpa-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ jobs:
ZPA_ACC_TEST_FORCE_SWEEPERS: ${{ secrets.ZPA_ACC_TEST_FORCE_SWEEPERS }}

zpa-prod-tenants:
needs: [zpa-beta-tenants]
# needs: [zpa-beta-tenants]
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Changelog

## 3.33.7 (October, 3 2024)

### Notes

- Release date: **(October, 3 2024)**
- Supported Terraform version: **v1.x**

### Bug Fixes
- [PR #496](/~https://github.com/zscaler/terraform-provider-zpa/pull/496) - Fixed issue with attribute `tcp_port_range`/`udp_port_range` and `tcp_port_ranges`/`udp_port_ranges` within `zpa_application_segment`. The fix ensure that both port configuration formats are suported separately without mid-conversion in between. The fix also ensure the port configuration order is ignored during apply and update process. [Issue #490](/~https://github.com/zscaler/terraform-provider-zpa/issues/490).

### Internal Changes
- [PR #496](/~https://github.com/zscaler/terraform-provider-zpa/pull/496) Consolidated multiple functions supported common/cross-shared resources. The following new common functions were introduced for simplicity:
- `expandCommonServerGroups`
- `expandCommonAppConnectorGroups`
- `expandCommonServiceEdgeGroups`
- `flattenCommonAppConnectorGroups`
- `flattenCommonAppServerGroups`
- `flattenCommonServiceEdgeGroups`

## 3.33.6 (October, 1 2024)

### Notes
Expand Down
6 changes: 3 additions & 3 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ test\:integration\:zpa:
build13: GOOS=$(shell go env GOOS)
build13: GOARCH=$(shell go env GOARCH)
ifeq ($(OS),Windows_NT) # is Windows_NT on XP, 2000, 7, Vista, 10...
build13: DESTINATION=$(APPDATA)/terraform.d/plugins/$(ZPA_PROVIDER_NAMESPACE)/3.33.6/$(GOOS)_$(GOARCH)
build13: DESTINATION=$(APPDATA)/terraform.d/plugins/$(ZPA_PROVIDER_NAMESPACE)/3.33.7/$(GOOS)_$(GOARCH)
else
build13: DESTINATION=$(HOME)/.terraform.d/plugins/$(ZPA_PROVIDER_NAMESPACE)/3.33.6/$(GOOS)_$(GOARCH)
build13: DESTINATION=$(HOME)/.terraform.d/plugins/$(ZPA_PROVIDER_NAMESPACE)/3.33.7/$(GOOS)_$(GOARCH)
endif
build13: fmtcheck
@echo "==> Installing plugin to $(DESTINATION)"
@mkdir -p $(DESTINATION)
go build -o $(DESTINATION)/terraform-provider-zpa_v3.33.6
go build -o $(DESTINATION)/terraform-provider-zpa_v3.33.7

vet:
@echo "==> Checking source code against go vet and staticcheck"
Expand Down
21 changes: 20 additions & 1 deletion docs/guides/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,29 @@ Track all ZPA Terraform provider's releases. New resources, features, and bug fi

---

``Last updated: v3.33.6``
``Last updated: v3.33.7``

---

## 3.33.7 (October, 3 2024)

### Notes

- Release date: **(October, 3 2024)**
- Supported Terraform version: **v1.x**

### Bug Fixes
- [PR #496](/~https://github.com/zscaler/terraform-provider-zpa/pull/496) - Fixed issue with attribute `tcp_port_range`/`udp_port_range` and `tcp_port_ranges`/`udp_port_ranges` within the resource `zpa_application_segment`. The fix ensure that both port configuration formats are suported separately without mid-conversion in between. The fix also ensure the port configuration order is ignored during apply and update process. [Issue #490](/~https://github.com/zscaler/terraform-provider-zpa/issues/490).

### Internal Changes
- [PR #496](/~https://github.com/zscaler/terraform-provider-zpa/pull/496) Consolidated multiple functions supported common/cross-shared resources. The following new common functions were introduced for simplicity:
- `expandCommonServerGroups`
- `expandCommonAppConnectorGroups`
- `expandCommonServiceEdgeGroups`
- `flattenCommonAppConnectorGroups`
- `flattenCommonAppServerGroups`
- `flattenCommonServiceEdgeGroups`

## 3.33.6 (October, 1 2024)

### Notes
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/hashicorp/terraform-plugin-docs v0.19.4
github.com/hashicorp/terraform-plugin-sdk v1.17.2
github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0
github.com/zscaler/zscaler-sdk-go/v2 v2.72.3
github.com/zscaler/zscaler-sdk-go/v2 v2.72.4
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,8 @@ github.com/zclconf/go-cty v1.14.4/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgr
github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b h1:FosyBZYxY34Wul7O/MSKey3txpPYyCqVO5ZyceuQJEI=
github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8=
github.com/zclconf/go-cty-yaml v1.0.2/go.mod h1:IP3Ylp0wQpYm50IHK8OZWKMu6sPJIUgKa8XhiVHura0=
github.com/zscaler/zscaler-sdk-go/v2 v2.72.3 h1:tkevJxm0QjZMuw2OQJBG12P5/xjQIbhcgLPo+6JOrtA=
github.com/zscaler/zscaler-sdk-go/v2 v2.72.3/go.mod h1:DW8JW8Cv2uxsfdlPN/Szk+CX9/nPyjhk/aERtTbJVYo=
github.com/zscaler/zscaler-sdk-go/v2 v2.72.4 h1:GMCmD87QiazaWxoJANTvfeGdmuCxbyaN2OQxBz09Me0=
github.com/zscaler/zscaler-sdk-go/v2 v2.72.4/go.mod h1:DW8JW8Cv2uxsfdlPN/Szk+CX9/nPyjhk/aERtTbJVYo=
go.abhg.dev/goldmark/frontmatter v0.2.0 h1:P8kPG0YkL12+aYk2yU3xHv4tcXzeVnN+gU0tJ5JnxRw=
go.abhg.dev/goldmark/frontmatter v0.2.0/go.mod h1:XqrEkZuM57djk7zrlRUB02x8I5J0px76YjkOzhB4YlU=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
Expand Down
128 changes: 127 additions & 1 deletion zpa/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/appconnectorgroup"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/applicationsegment"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/cloudconnectorgroup"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/common"
Expand All @@ -24,6 +25,8 @@ import (
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/samlattribute"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/scimattributeheader"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/segmentgroup"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/servergroup"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/serviceedgegroup"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/trustednetwork"
)

Expand Down Expand Up @@ -576,7 +579,7 @@ func expandNetwokPorts(d *schema.ResourceData, key string) []common.NetworkPorts

func resourceAppSegmentPortRange(desc string) *schema.Schema {
return &schema.Schema{
Type: schema.TypeSet,
Type: schema.TypeList,
Optional: true,
Computed: true,
// Activate the "Attributes as Blocks" processing mode to permit dynamic declaration of no ports
Expand Down Expand Up @@ -1415,3 +1418,126 @@ func flattenPredefinedControls(predControl []common.CustomCommonControls) []inte
}
return predControls
}

func expandCommonServerGroups(d *schema.ResourceData) []servergroup.ServerGroup {
serverGroupInterface, ok := d.GetOk("server_groups")
if ok {
serverGroupSet, ok := serverGroupInterface.(*schema.Set)
if !ok {
return []servergroup.ServerGroup{}
}
log.Printf("[INFO] server group data: %+v\n", serverGroupSet)
var serverGroups []servergroup.ServerGroup
for _, serverGroup := range serverGroupSet.List() {
serverGroupMap, ok := serverGroup.(map[string]interface{})
if ok && serverGroupMap != nil {
idSet, ok := serverGroupMap["id"].(*schema.Set)
if !ok {
continue
}
for _, id := range idSet.List() {
serverGroups = append(serverGroups, servergroup.ServerGroup{
ID: id.(string),
})
}
}
}
return serverGroups
}

return []servergroup.ServerGroup{}
}

func expandCommonAppConnectorGroups(d *schema.ResourceData) []appconnectorgroup.AppConnectorGroup {
appConnectorGroupInterface, ok := d.GetOk("app_connector_groups")
if ok {
appConnectorGroupSet, ok := appConnectorGroupInterface.(*schema.Set)
if !ok {
return []appconnectorgroup.AppConnectorGroup{}
}
log.Printf("[INFO] app connector group data: %+v\n", appConnectorGroupSet)
var appConnectorGroups []appconnectorgroup.AppConnectorGroup
for _, appConnectorGroup := range appConnectorGroupSet.List() {
appConnectorGroupMap, ok := appConnectorGroup.(map[string]interface{})
if ok && appConnectorGroupMap != nil {
idSet, ok := appConnectorGroupMap["id"].(*schema.Set)
if !ok {
continue
}
for _, id := range idSet.List() {
appConnectorGroups = append(appConnectorGroups, appconnectorgroup.AppConnectorGroup{
ID: id.(string),
})
}
}
}
return appConnectorGroups
}

return []appconnectorgroup.AppConnectorGroup{}
}

func expandCommonServiceEdgeGroups(d *schema.ResourceData) []serviceedgegroup.ServiceEdgeGroup {
serviceEdgeGroupInterface, ok := d.GetOk("service_edge_groups")
if ok {
serviceEdgeGroupSet, ok := serviceEdgeGroupInterface.(*schema.Set)
if !ok {
return []serviceedgegroup.ServiceEdgeGroup{}
}
log.Printf("[INFO] service edge group data: %+v\n", serviceEdgeGroupSet)
var serviceEdgeGroups []serviceedgegroup.ServiceEdgeGroup
for _, serviceEdgeGroup := range serviceEdgeGroupSet.List() {
serviceEdgeGroupMap, ok := serviceEdgeGroup.(map[string]interface{})
if ok && serviceEdgeGroupMap != nil {
idSet, ok := serviceEdgeGroupMap["id"].(*schema.Set)
if !ok {
continue
}
for _, id := range idSet.List() {
serviceEdgeGroups = append(serviceEdgeGroups, serviceedgegroup.ServiceEdgeGroup{
ID: id.(string),
})
}
}
}
return serviceEdgeGroups
}

return []serviceedgegroup.ServiceEdgeGroup{}
}

func flattenCommonAppConnectorGroups(appConnectorGroups []appconnectorgroup.AppConnectorGroup) []interface{} {
result := make([]interface{}, 1)
mapIds := make(map[string]interface{})
ids := make([]string, len(appConnectorGroups))
for i, appConnectorGroup := range appConnectorGroups {
ids[i] = appConnectorGroup.ID
}
mapIds["id"] = ids
result[0] = mapIds
return result
}

func flattenCommonAppServerGroups(serverGroups []servergroup.ServerGroup) []interface{} {
result := make([]interface{}, 1)
mapIds := make(map[string]interface{})
ids := make([]string, len(serverGroups))
for i, serverGroup := range serverGroups {
ids[i] = serverGroup.ID
}
mapIds["id"] = ids
result[0] = mapIds
return result
}

func flattenCommonServiceEdgeGroups(serviceEdgeGroups []serviceedgegroup.ServiceEdgeGroup) []interface{} {
result := make([]interface{}, 1)
mapIds := make(map[string]interface{})
ids := make([]string, len(serviceEdgeGroups))
for i, serviceEdgeGroup := range serviceEdgeGroups {
ids[i] = serviceEdgeGroup.ID
}
mapIds["id"] = ids
result[0] = mapIds
return result
}
Loading

0 comments on commit adc22ca

Please sign in to comment.