Skip to content

Commit

Permalink
fix: Implemented fixes and deprecations (#199)
Browse files Browse the repository at this point in the history
* fix: Implemented fixes and deprecations

* fix: Implemented fixes and deprecations

* fix: Implemented fixes and deprecations
  • Loading branch information
willguibr authored Jun 8, 2024
1 parent 713118f commit c17a172
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 96 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog

## 1.2.0 (June, 7 2024)

### Notes

- Release date: **(June, 7 2024)**
- Supported Terraform version: **v1.x.x**

### Deprecations
- [PR #199](https://github.com/zscaler/zscaler-terraformer/pull/199) Deprecated the following ZPA resource:
- `zpa_cloud_browser_isolation_banner`
- `zpa_cloud_browser_isolation_certificate`
- `zpa_cloud_browser_isolation_external_profile`

### Fixes
- [PR #199](https://github.com/zscaler/zscaler-terraformer/pull/199) Implemented fix to resource `zpa_microtenant_controller`, to ignore the importing of `Default` Microtenant.

## 1.1.3 (May, 18 2024)

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

---

``Last updated: v1.1.3``
``Last updated: v1.2.0``

---

## 1.2.0 (June, 7 2024)

### Notes

- Release date: **(June, 7 2024)**
- Supported Terraform version: **v1.x.x**

### Deprecations
- [PR #199](https://github.com/zscaler/zscaler-terraformer/pull/199) Deprecated the following ZPA resource:
- `zpa_cloud_browser_isolation_banner`
- `zpa_cloud_browser_isolation_certificate`
- `zpa_cloud_browser_isolation_external_profile`

### Fixes
- [PR #199](https://github.com/zscaler/zscaler-terraformer/pull/199) Implemented fix to resource `zpa_microtenant_controller`, to ignore the importing of `Default` Microtenant.

## 1.1.3 (May, 18 2024)

### Notes
Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ toolchain go1.22.0
require (
github.com/dnaeon/go-vcr v1.2.0
github.com/google/uuid v1.6.0
github.com/hashicorp/hc-install v0.7.0
github.com/hashicorp/hc-install v0.6.4
github.com/hashicorp/terraform-exec v0.21.0
github.com/hashicorp/terraform-json v0.22.1
github.com/iancoleman/strcase v0.3.0
github.com/mitchellh/go-homedir v1.1.0
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.8.0
github.com/spf13/viper v1.19.0
github.com/spf13/viper v1.18.2
github.com/stretchr/testify v1.9.0
github.com/zclconf/go-cty v1.14.4
github.com/zscaler/zscaler-sdk-go/v2 v2.5.23
github.com/zscaler/zscaler-sdk-go/v2 v2.6.0
)

require (
Expand All @@ -44,7 +44,7 @@ require (
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/pelletier/go-toml/v2 v2.1.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
Expand All @@ -58,7 +58,7 @@ require (
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
golang.org/x/text v0.16.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
27 changes: 14 additions & 13 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/C
github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek=
github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/hc-install v0.7.0 h1:Uu9edVqjKQxxuD28mR5TikkKDd/p55S8vzPC1659aBk=
github.com/hashicorp/hc-install v0.7.0/go.mod h1:ELmmzZlGnEcqoUMKUuykHaPCIR1sYLYX+KSggWSKZuA=
github.com/hashicorp/hc-install v0.6.4 h1:QLqlM56/+SIIGvGcfFiwMY3z5WGXT066suo/v9Km8e0=
github.com/hashicorp/hc-install v0.6.4/go.mod h1:05LWLy8TD842OtgcfBbOT0WMoInBMUSHjmDx10zuBIA=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y=
Expand Down Expand Up @@ -101,8 +101,8 @@ github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8=
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
github.com/pelletier/go-toml/v2 v2.1.1 h1:LWAJwfNvjQZCFIDKWYQaM62NcYeYViCmWIwmOStowAI=
github.com/pelletier/go-toml/v2 v2.1.1/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4=
github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand Down Expand Up @@ -131,12 +131,11 @@ github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI=
github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg=
github.com/spf13/viper v1.18.2 h1:LUXCnvUvSM6FXAsj6nnfc8Q2tp1dIgUfY9Kc8GsSOiQ=
github.com/spf13/viper v1.18.2/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMVB+yk=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
Expand All @@ -150,8 +149,8 @@ github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM
github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw=
github.com/zclconf/go-cty v1.14.4 h1:uXXczd9QDGsgu0i/QFR/hzI5NYCHLf6NQw/atrbnhq8=
github.com/zclconf/go-cty v1.14.4/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE=
github.com/zscaler/zscaler-sdk-go/v2 v2.5.23 h1:34J7i52kVtQzrvpokFzYpNsgjKTQ7H8B0XzLDYXUQog=
github.com/zscaler/zscaler-sdk-go/v2 v2.5.23/go.mod h1:UgwsquQFF3nSn4mJGbbJRweh5Jpiwqkw+4mIxm14Eso=
github.com/zscaler/zscaler-sdk-go/v2 v2.6.0 h1:LnjrrxD2i5TMtBCouy7NJyC4AozM1klCSS3z6RTZ57E=
github.com/zscaler/zscaler-sdk-go/v2 v2.6.0/go.mod h1:lbdgIlORFfkAGvju4szC7SLxpLddJJKvZ6brfOECIL4=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
Expand All @@ -162,6 +161,8 @@ golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand All @@ -172,10 +173,10 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ=
golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
Expand Down
40 changes: 10 additions & 30 deletions internal/app/zscaler-terraformer/cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/urlcategories"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/user_authentication_settings"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/appconnectorgroup"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/microtenants"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/policysetcontroller"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/segmentgroup"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/servergroup"
Expand All @@ -52,9 +53,6 @@ var allGeneratableResources = []string{
"zpa_application_segment_inspection",
"zpa_application_segment_browser_access",
"zpa_ba_certificate",
"zpa_cloud_browser_isolation_banner",
"zpa_cloud_browser_isolation_certificate",
"zpa_cloud_browser_isolation_external_profile",
"zpa_segment_group",
"zpa_server_group",
"zpa_policy_access_rule",
Expand Down Expand Up @@ -367,30 +365,6 @@ func generate(cmd *cobra.Command, writer io.Writer, resourceType string) {
resourceCount = len(jsonPayload)
m, _ := json.Marshal(jsonPayload)
_ = json.Unmarshal(m, &jsonStructData)
case "zpa_cloud_browser_isolation_banner":
jsonPayload, _, err := api.zpa.cbibannercontroller.GetAll()
if err != nil {
log.Fatal(err)
}
resourceCount = len(jsonPayload)
m, _ := json.Marshal(jsonPayload)
_ = json.Unmarshal(m, &jsonStructData)
case "zpa_cloud_browser_isolation_certificate":
jsonPayload, _, err := api.zpa.cbicertificatecontroller.GetAll()
if err != nil {
log.Fatal(err)
}
resourceCount = len(jsonPayload)
m, _ := json.Marshal(jsonPayload)
_ = json.Unmarshal(m, &jsonStructData)
case "zpa_cloud_browser_isolation_external_profile":
jsonPayload, _, err := api.zpa.cbiprofilecontroller.GetAll()
if err != nil {
log.Fatal(err)
}
resourceCount = len(jsonPayload)
m, _ := json.Marshal(jsonPayload)
_ = json.Unmarshal(m, &jsonStructData)
case "zpa_segment_group":
list, _, err := api.zpa.segmentgroup.GetAll()
if err != nil {
Expand Down Expand Up @@ -551,10 +525,16 @@ func generate(cmd *cobra.Command, writer io.Writer, resourceType string) {
if err != nil {
log.Fatal(err)
}
resourceCount = len(jsonPayload)
m, _ := json.Marshal(jsonPayload)
// Filter out any resources with name == "Default"
var filteredPayload []microtenants.MicroTenant
for _, item := range jsonPayload {
if item.Name != "Default" {
filteredPayload = append(filteredPayload, item)
}
}
m, _ := json.Marshal(filteredPayload)
resourceCount = len(filteredPayload)
_ = json.Unmarshal(m, &jsonStructData)

case "zia_admin_users":
jsonPayload, err := api.zia.admins.GetAllAdminUsers()
if err != nil {
Expand Down
56 changes: 9 additions & 47 deletions internal/app/zscaler-terraformer/cmd/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/urlcategories"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/user_authentication_settings"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/appconnectorgroup"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/microtenants"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/policysetcontroller"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/segmentgroup"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/servergroup"
Expand All @@ -39,9 +40,6 @@ var resourceImportStringFormats = map[string]string{
"zpa_application_segment_pra": ":id",
"zpa_application_segment_inspection": ":id",
"zpa_application_segment_browser_access": ":id",
"zpa_cloud_browser_isolation_banner": ":id",
"zpa_cloud_browser_isolation_certificate": ":id",
"zpa_cloud_browser_isolation_external_profile": ":id",
"zpa_segment_group": ":id",
"zpa_server_group": ":id",
"zpa_policy_access_rule": ":id",
Expand Down Expand Up @@ -207,48 +205,6 @@ func importResource(cmd *cobra.Command, writer io.Writer, resourceType string) {
m, _ := json.Marshal(jsonPayload)
resourceCount = len(jsonPayload)
_ = json.Unmarshal(m, &jsonStructData)
case "zpa_cloud_browser_isolation_banner":
jsonPayload, _, err := api.zpa.cbibannercontroller.GetAll()
if err != nil {
isLicErr, reason := isLicenseError(err)
// If it's a license error, log and continue, otherwise, terminate.
if isLicErr {
log.Printf("[WARNING] License error encountered: %s. Continuing with the import.", reason)
} else {
log.Fatal(err)
}
}
m, _ := json.Marshal(jsonPayload)
resourceCount = len(jsonPayload)
_ = json.Unmarshal(m, &jsonStructData)
case "zpa_cloud_browser_isolation_external_profile":
jsonPayload, _, err := api.zpa.cbiprofilecontroller.GetAll()
if err != nil {
isLicErr, reason := isLicenseError(err)
// If it's a license error, log and continue, otherwise, terminate.
if isLicErr {
log.Printf("[WARNING] License error encountered: %s. Continuing with the import.", reason)
} else {
log.Fatal(err)
}
}
m, _ := json.Marshal(jsonPayload)
resourceCount = len(jsonPayload)
_ = json.Unmarshal(m, &jsonStructData)
case "zpa_cloud_browser_isolation_certificate":
jsonPayload, _, err := api.zpa.cbicertificatecontroller.GetAll()
if err != nil {
isLicErr, reason := isLicenseError(err)
// If it's a license error, log and continue, otherwise, terminate.
if isLicErr {
log.Printf("[WARNING] License error encountered: %s. Continuing with the import.", reason)
} else {
log.Fatal(err)
}
}
m, _ := json.Marshal(jsonPayload)
resourceCount = len(jsonPayload)
_ = json.Unmarshal(m, &jsonStructData)
case "zpa_segment_group":
list, _, err := api.zpa.segmentgroup.GetAll()
if err != nil {
Expand Down Expand Up @@ -425,8 +381,14 @@ func importResource(cmd *cobra.Command, writer io.Writer, resourceType string) {
log.Fatal(err)
}
}
m, _ := json.Marshal(jsonPayload)
resourceCount = len(jsonPayload)
var filteredPayload []microtenants.MicroTenant
for _, item := range jsonPayload {
if item.ID != "0" {
filteredPayload = append(filteredPayload, item)
}
}
m, _ := json.Marshal(filteredPayload)
resourceCount = len(filteredPayload)
_ = json.Unmarshal(m, &jsonStructData)
case "zia_admin_users":
jsonPayload, err := api.zia.admins.GetAllAdminUsers()
Expand Down

0 comments on commit c17a172

Please sign in to comment.