Skip to content

Commit

Permalink
(fix) Added rule reorder support for all policy types (#369)
Browse files Browse the repository at this point in the history
* (fix) Added rule reorder support for all policy types
* (doc): Fix changelog and release-notes
* (doc) fix index and resource-importer document
  • Loading branch information
willguibr authored Sep 20, 2023
1 parent 9706d60 commit 7fa9f70
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 19 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Changelog

## 3.0.1-beta (September, 20 2023)

### Notes

- Release date: **(September, 20 2023)**
- Supported Terraform version: **v1.x**

### Fixes

- [PR #369](https://github.com/zscaler/terraform-provider-zpa/pull/369) - Added fix to resource `zpa_policy_access_rule_reorder` to support multiple policy types. The reorder operation is now supported for the following policy types:
- ``ACCESS_POLICY or GLOBAL_POLICY``
- ``TIMEOUT_POLICY or REAUTH_POLICY``
- ``BYPASS_POLICY or CLIENT_FORWARDING_POLICY``
- ``INSPECTION_POLICY``
- ``ISOLATION_POLICY``
- ``CREDENTIAL_POLICY``
- ``CAPABILITIES_POLICY``
- ``CLIENTLESS_SESSION_PROTECTION_POLICY``

## 3.0.0-beta (September, 18 2023)

### Notes
Expand Down
6 changes: 3 additions & 3 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ testacc:
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.0.0-beta/$(GOOS)_$(GOARCH)
build13: DESTINATION=$(APPDATA)/terraform.d/plugins/$(ZPA_PROVIDER_NAMESPACE)/3.0.1-beta/$(GOOS)_$(GOARCH)
else
build13: DESTINATION=$(HOME)/.terraform.d/plugins/$(ZPA_PROVIDER_NAMESPACE)/3.0.0-beta/$(GOOS)_$(GOARCH)
build13: DESTINATION=$(HOME)/.terraform.d/plugins/$(ZPA_PROVIDER_NAMESPACE)/3.0.1-beta/$(GOOS)_$(GOARCH)
endif
build13: fmtcheck
go mod tidy && go mod vendor
@echo "==> Installing plugin to $(DESTINATION)"
@mkdir -p $(DESTINATION)
go build -o $(DESTINATION)/terraform-provider-zpa_v3.0.0-beta
go build -o $(DESTINATION)/terraform-provider-zpa_v3.0.1-beta

lint: vendor
@echo "✓ Linting source code with https://staticcheck.io/ ..."
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.0.0-beta``
``Last updated: v3.0.1-beta``

---

## 3.0.1-beta (September, 20 2023)

### Notes

- Release date: **(September, 20 2023)**
- Supported Terraform version: **v1.x**

### Fixes

- [PR #369](https://github.com/zscaler/terraform-provider-zpa/pull/369) - Added fix to resource `zpa_policy_access_rule_reorder` to support multiple policy types. The reorder operation is now supported for the following policy types:
- ``ACCESS_POLICY or GLOBAL_POLICY``
- ``TIMEOUT_POLICY or REAUTH_POLICY``
- ``BYPASS_POLICY or CLIENT_FORWARDING_POLICY``
- ``INSPECTION_POLICY``
- ``ISOLATION_POLICY``
- ``CREDENTIAL_POLICY``
- ``CAPABILITIES_POLICY``
- ``CLIENTLESS_SESSION_PROTECTION_POLICY``

## 3.0.0-beta (September, 18 2023)

### Notes
Expand Down
6 changes: 5 additions & 1 deletion docs/guides/resource-importer.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ page_title: "Resource Importer"

# Zscaler Terraformer Tool

!> **Disclaimer:** Please refer to our [General Support Statement](support.md) before proceeding with the use of this provider.
Support Disclaimer

-------
-> **Disclaimer:** Please refer to our [General Support Statement](support.md) before proceeding with the use of this provider. You can also refer to our [troubleshooting guide](troubleshooting.md) for guidance on typical problems.

## Overview

Expand All @@ -19,6 +22,7 @@ write the Terraform configuration to describe them.
> NOTE: This tool has been developed and tested with Terraform v1.x.x only.
[![Zscaler Terraformer Migration Tool](https://raw.githubusercontent.com/zscaler/zscaler-terraformer/master/images/zscaler_terraformer.svg)](https://community.zscaler.com/zenith/s/question/0D54u00009evlDrCAI/video-zscaler-terraformer-migration-tool-launch)

## Usage

```bash
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Use the navigation on the left to read about the available resources.
Support Disclaimer

-------
!> **Disclaimer:** Please refer to our [General Support Statement](guides/support.md) before proceeding with the use of this provider.
-> **Disclaimer:** Please refer to our [General Support Statement](guides/support.md) before proceeding with the use of this provider. You can also refer to our [troubleshooting guide](guides/troubleshooting.md) for guidance on typical problems.

## Zenith Community - ZPA Terraform Provider Introduction

Expand Down
5 changes: 4 additions & 1 deletion docs/resources/zpa_policy_access_rule_reorder.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,15 @@ resource "zpa_policy_access_rule_reorder" "access_policy_reorder" {
### Required

* `name` - (Required) This is the name of the policy rule.
* `policy_set_id` - (Required) Use [zpa_policy_type](https://registry.terraform.io/providers/zscaler/zpa/latest/docs/data-sources/zpa_policy_type) data source to retrieve the necessary policy Set ID ``policy_set_id``
* `policy_type` (Required) - Supported values:
* ``ACCESS_POLICY or GLOBAL_POLICY``
* ``TIMEOUT_POLICY or REAUTH_POLICY``
* ``BYPASS_POLICY or CLIENT_FORWARDING_POLICY``
* ``INSPECTION_POLICY``
* ``ISOLATION_POLICY``
* ``CREDENTIAL_POLICY``
* ``CAPABILITIES_POLICY``
* ``CLIENTLESS_SESSION_PROTECTION_POLICY``

## Attributes Reference

Expand Down
21 changes: 20 additions & 1 deletion zpa/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -687,14 +687,33 @@ func GetString(v interface{}) string {
return fmt.Sprintf("%v", v)
}

var AllowedPolicyTypes = map[string]struct{}{
"ACCESS_POLICY": {},
"GLOBAL_POLICY": {},
"TIMEOUT_POLICY": {},
"REAUTH_POLICY": {},
"CLIENT_FORWARDING_POLICY": {},
"BYPASS_POLICY": {},
"ISOLATION_POLICY": {},
"INSPECTION_POLICY": {},
"CREDENTIAL_POLICY": {},
"CAPABILITIES_POLICY": {},
"CLIENTLESS_SESSION_PROTECTION_POLICY": {},
}

func GetGlobalPolicySetByPolicyType(policysetcontroller policysetcontroller.Service, policyType string) (*policysetcontroller.PolicySet, error) {
// Check if the provided policy type is allowed
if _, ok := AllowedPolicyTypes[policyType]; !ok {
return nil, fmt.Errorf("invalid policy type: %s", policyType)
}

policySetsMutex.Lock()
defer policySetsMutex.Unlock()

if p, ok := policySets[policyType]; ok {
return &p, nil
}
globalPolicySet, _, err := policysetcontroller.GetByPolicyType("ACCESS_POLICY")
globalPolicySet, _, err := policysetcontroller.GetByPolicyType(policyType)
if err != nil {
return nil, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ func TestAccDataSourceCBIExternalProfile_Basic(t *testing.T) {
},
})
}
*/
*/
11 changes: 6 additions & 5 deletions zpa/provider_sweeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ func setupSweeper(resourceType string, del func(*testClient) error) {
},
})
}

/*
//TODO: Tests is failing on QA2 tenant. Needs further investigation.
func sweepTestAppConnectorGroup(client *testClient) error {
Expand Down Expand Up @@ -367,11 +368,11 @@ func sweepTestLSSConfigController(client *testClient) error {
*/

var defaultPolicyNames = map[string]string{
"ACCESS_POLICY": "Global_Policy",
"TIMEOUT_POLICY": "ReAuth_Policy",
"CLIENT_FORWARDING_POLICY": "Bypass_Policy",
"INSPECTION_POLICY": "Inspection_Policy",
"ISOLATION_POLICY": "Isolation_Policy",
"ACCESS_POLICY": "Global_Policy",
"TIMEOUT_POLICY": "ReAuth_Policy",
"CLIENT_FORWARDING_POLICY": "Bypass_Policy",
"INSPECTION_POLICY": "Inspection_Policy",
"ISOLATION_POLICY": "Isolation_Policy",
}

func sweepTestAccessPolicyRuleByType(client *testClient) error {
Expand Down
3 changes: 1 addition & 2 deletions zpa/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ func TestMain(m *testing.M) {
setupSweeper(resourcetype.ZPACBIExternalIsolationProfile, sweepTestCBIExternalProfile)
}


resource.TestMain(m)
resource.TestMain(m)
}

func TestProvider(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions zpa/resource_zpa_service_edge_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ func resourceServiceEdgeGroup() *schema.Resource {
Computed: true,
},
"country_code": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validateCountryCode,
},
"description": {
Expand Down

0 comments on commit 7fa9f70

Please sign in to comment.