Skip to content

Commit

Permalink
Merge pull request #151 from zscaler/zt-#151-fix-sdk-pointers
Browse files Browse the repository at this point in the history
Fix: Fixed Pointers to new SDK v2.2.2 structure
  • Loading branch information
willguibr authored Dec 11, 2023
2 parents 4fbc934 + 0aa7a32 commit 62dec63
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 72 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
test:
strategy:
matrix:
go-version: [1.19]
go-version: ['1.20']
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -50,7 +50,7 @@ jobs:
required_providers {
zpa = {
source = "zscaler/zpa"
version = ">= 2"
version = ">= 3"
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## 0.3.4 (December, 11 2023)

### Notes

- Release date: **(December, 11 2023)**
- Supported Terraform version: **v1.x.x**

### Bug Fixes

- [PR #151](https://github.com/zscaler/zscaler-terraformer/pull/151) Fixed ZIA ``zia_admin_users`` resource schema
- [PR #151](https://github.com/zscaler/zscaler-terraformer/pull/151) Upgraded to [Zscaler-SDK-GO v2.2.2](https://github.com/zscaler/zscaler-sdk-go/releases/tag/v2.2.2)

## 0.3.3 (October 18, 2023)

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

---

``Last updated: v0.3.3``
``Last updated: v0.3.4``

---

## 0.3.4 (December, 11 2023)

### Notes

- Release date: **(December, 11 2023)**
- Supported Terraform version: **v1.x.x**

### Bug Fixes

- [PR #151](https://github.com/zscaler/zscaler-terraformer/pull/151) Fixed ZIA ``zia_admin_users`` resource schema
- [PR #151](https://github.com/zscaler/zscaler-terraformer/pull/151) Upgraded to [Zscaler-SDK-GO v2.2.2](https://github.com/zscaler/zscaler-sdk-go/releases/tag/v2.2.2)

## 0.3.3 (October 18, 2023)

### Notes
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/zscaler/zscaler-terraformer

go 1.19
go 1.20

require (
github.com/dnaeon/go-vcr v1.2.0
Expand Down
1 change: 0 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/zclconf/go-cty v1.14.1 h1:t9fyA35fwjjUMcmL5hLER+e/rEPqrbCK1/OSE4SI9KA=
github.com/zclconf/go-cty v1.14.1/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE=
github.com/zscaler/zscaler-sdk-go v1.7.0 h1:vE0DhIqNMxEnD7AUzSpm66wrWog29LMGBOfdCiRoem4=
github.com/zscaler/zscaler-sdk-go/v2 v2.2.2 h1:iY/xxn69DESF1dPuLHrVdhgsdKUwtG6raS56k0r8lf0=
github.com/zscaler/zscaler-sdk-go/v2 v2.2.2/go.mod h1:ZuSr5SoINzMxCVQPV1lh5xBEwsQLDmpEznEV9ey+gHg=
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
Expand Down
14 changes: 7 additions & 7 deletions internal/app/zscaler-terraformer/cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/zclconf/go-cty/cty"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/dlpdictionaries"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/dlp/dlpdictionaries"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/firewallpolicies/filteringrules"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/firewallpolicies/networkapplications"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/firewallpolicies/networkapplicationgroups"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/firewallpolicies/networkservices"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/security_policy_settings"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/urlcategories"
Expand Down Expand Up @@ -473,7 +473,7 @@ func generate(cmd *cobra.Command, writer io.Writer, resourceType string) {
m, _ := json.Marshal(jsonPayload)
_ = json.Unmarshal(m, &jsonStructData)
case "zia_admin_users":
jsonPayload, err := api.zia.adminuserrolemgmt.GetAllAdminUsers()
jsonPayload, err := api.zia.admins.GetAllAdminUsers()
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -558,19 +558,19 @@ func generate(cmd *cobra.Command, writer io.Writer, resourceType string) {
m, _ := json.Marshal(servicesFiltered)
_ = json.Unmarshal(m, &jsonStructData)
case "zia_firewall_filtering_network_service_groups":
jsonPayload, err := api.zia.networkservices.GetAllNetworkServiceGroups()
jsonPayload, err := api.zia.networkservicegroups.GetAllNetworkServiceGroups()
if err != nil {
log.Fatal(err)
}
resourceCount = len(jsonPayload)
m, _ := json.Marshal(jsonPayload)
_ = json.Unmarshal(m, &jsonStructData)
case "zia_firewall_filtering_network_application_groups":
groups, err := api.zia.networkapplications.GetAllNetworkApplicationGroups()
groups, err := api.zia.networkapplicationgroups.GetAllNetworkApplicationGroups()
if err != nil {
log.Fatal(err)
}
groupsFiltered := []networkapplications.NetworkApplicationGroups{}
groupsFiltered := []networkapplicationgroups.NetworkApplicationGroups{}
for _, group := range groups {
if isInList(group.Name, []string{"Microsoft Office365"}) {
continue
Expand Down Expand Up @@ -662,7 +662,7 @@ func generate(cmd *cobra.Command, writer io.Writer, resourceType string) {
m, _ := json.Marshal(jsonPayload)
_ = json.Unmarshal(m, &jsonStructData)
case "zia_user_management":
jsonPayload, err := api.zia.usermanagement.GetAllUsers()
jsonPayload, err := api.zia.users.GetAllUsers()
if err != nil {
log.Fatal(err)
}
Expand Down
30 changes: 16 additions & 14 deletions internal/app/zscaler-terraformer/cmd/generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,33 @@ import (
"github.com/spf13/viper"
"github.com/stretchr/testify/assert"
"github.com/zscaler/zscaler-sdk-go/v2/zia"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/adminuserrolemgmt"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/adminuserrolemgmt/admins"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/devicegroups"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/dlp_engines"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/dlp_notification_templates"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/dlp_web_rules"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/dlpdictionaries"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/dlp/dlp_engines"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/dlp/dlp_notification_templates"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/dlp/dlp_web_rules"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/dlp/dlpdictionaries"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/firewallpolicies/filteringrules"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/firewallpolicies/ipdestinationgroups"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/firewallpolicies/ipsourcegroups"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/firewallpolicies/networkapplications"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/firewallpolicies/networkapplicationgroups"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/firewallpolicies/networkservicegroups"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/firewallpolicies/networkservices"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/firewallpolicies/timewindow"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/locationmanagement"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/locationmanagement/locationgroups"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/location/locationgroups"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/location/locationmanagement"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/rule_labels"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/security_policy_settings"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/trafficforwarding/greinternalipranges"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/trafficforwarding/gretunnelinfo"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/trafficforwarding/gretunnels"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/trafficforwarding/staticips"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/trafficforwarding/virtualipaddresslist"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/trafficforwarding/virtualipaddress"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/trafficforwarding/vpncredentials"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/urlcategories"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/urlfilteringpolicies"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/user_authentication_settings"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/usermanagement/usermanagement"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/usermanagement/users"
"github.com/zscaler/zscaler-sdk-go/v2/zpa"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/appconnectorcontroller"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/appconnectorgroup"
Expand Down Expand Up @@ -260,16 +261,17 @@ func createClientMock(r http.RoundTripper, resourceType, zpaClientID, zpaClientS
cli = &Client{
ZiaClient: ziaClient,
zia: &ZIAClient{
adminuserrolemgmt: adminuserrolemgmt.New(ziaClient),
admins: admins.New(ziaClient),
filteringrules: filteringrules.New(ziaClient),
ipdestinationgroups: ipdestinationgroups.New(ziaClient),
ipsourcegroups: ipsourcegroups.New(ziaClient),
networkapplications: networkapplications.New(ziaClient),
networkapplicationgroups: networkapplicationgroups.New(ziaClient),
networkservicegroups: networkservicegroups.New(ziaClient),
networkservices: networkservices.New(ziaClient),
timewindow: timewindow.New(ziaClient),
urlcategories: urlcategories.New(ziaClient),
urlfilteringpolicies: urlfilteringpolicies.New(ziaClient),
virtualipaddresslist: virtualipaddresslist.New(ziaClient),
virtualipaddress: virtualipaddress.New(ziaClient),
vpncredentials: vpncredentials.New(ziaClient),
gretunnels: gretunnels.New(ziaClient),
gretunnelinfo: gretunnelinfo.New(ziaClient),
Expand All @@ -285,7 +287,7 @@ func createClientMock(r http.RoundTripper, resourceType, zpaClientID, zpaClientS
rule_labels: rule_labels.New(ziaClient),
security_policy_settings: security_policy_settings.New(ziaClient),
user_authentication_settings: user_authentication_settings.New(ziaClient),
usermanagement: usermanagement.New(ziaClient),
users: users.New(ziaClient),
},
}
}
Expand Down
18 changes: 9 additions & 9 deletions internal/app/zscaler-terraformer/cmd/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import (

"strconv"

"fmt"

"github.com/spf13/cobra"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/dlpdictionaries"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/dlp/dlpdictionaries"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/firewallpolicies/filteringrules"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/firewallpolicies/networkapplications"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/firewallpolicies/networkapplicationgroups"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/firewallpolicies/networkservices"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/security_policy_settings"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/urlcategories"
Expand All @@ -20,8 +22,6 @@ import (
"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"

"fmt"
)

// resourceImportStringFormats contains a mapping of the resource type to the
Expand Down Expand Up @@ -328,7 +328,7 @@ func importResource(cmd *cobra.Command, writer io.Writer, resourceType string) {
resourceCount = len(jsonPayload)
_ = json.Unmarshal(m, &jsonStructData)
case "zia_admin_users":
jsonPayload, err := api.zia.adminuserrolemgmt.GetAllAdminUsers()
jsonPayload, err := api.zia.admins.GetAllAdminUsers()
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -413,19 +413,19 @@ func importResource(cmd *cobra.Command, writer io.Writer, resourceType string) {
resourceCount = len(servicesFiltered)
_ = json.Unmarshal(m, &jsonStructData)
case "zia_firewall_filtering_network_service_groups":
jsonPayload, err := api.zia.networkservices.GetAllNetworkServiceGroups()
jsonPayload, err := api.zia.networkservicegroups.GetAllNetworkServiceGroups()
if err != nil {
log.Fatal(err)
}
m, _ := json.Marshal(jsonPayload)
resourceCount = len(jsonPayload)
_ = json.Unmarshal(m, &jsonStructData)
case "zia_firewall_filtering_network_application_groups":
groups, err := api.zia.networkapplications.GetAllNetworkApplicationGroups()
groups, err := api.zia.networkapplicationgroups.GetAllNetworkApplicationGroups()
if err != nil {
log.Fatal(err)
}
groupsFiltered := []networkapplications.NetworkApplicationGroups{}
groupsFiltered := []networkapplicationgroups.NetworkApplicationGroups{}
for _, rule := range groups {
if isInList(rule.Name, []string{"Microsoft Office365"}) {
continue
Expand Down Expand Up @@ -518,7 +518,7 @@ func importResource(cmd *cobra.Command, writer io.Writer, resourceType string) {
resourceCount = len(jsonPayload)
_ = json.Unmarshal(m, &jsonStructData)
case "zia_user_management":
jsonPayload, err := api.zia.usermanagement.GetAllUsers()
jsonPayload, err := api.zia.users.GetAllUsers()
if err != nil {
log.Fatal(err)
}
Expand Down
30 changes: 16 additions & 14 deletions internal/app/zscaler-terraformer/cmd/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,33 @@ package cmd

import (
"github.com/zscaler/zscaler-sdk-go/v2/zia"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/adminuserrolemgmt"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/adminuserrolemgmt/admins"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/devicegroups"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/dlp_engines"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/dlp_notification_templates"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/dlp_web_rules"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/dlpdictionaries"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/dlp/dlp_engines"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/dlp/dlp_notification_templates"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/dlp/dlp_web_rules"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/dlp/dlpdictionaries"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/firewallpolicies/filteringrules"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/firewallpolicies/ipdestinationgroups"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/firewallpolicies/ipsourcegroups"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/firewallpolicies/networkapplications"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/firewallpolicies/networkapplicationgroups"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/firewallpolicies/networkservicegroups"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/firewallpolicies/networkservices"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/firewallpolicies/timewindow"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/locationmanagement"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/locationmanagement/locationgroups"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/location/locationgroups"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/location/locationmanagement"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/rule_labels"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/security_policy_settings"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/trafficforwarding/greinternalipranges"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/trafficforwarding/gretunnelinfo"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/trafficforwarding/gretunnels"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/trafficforwarding/staticips"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/trafficforwarding/virtualipaddresslist"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/trafficforwarding/virtualipaddress"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/trafficforwarding/vpncredentials"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/urlcategories"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/urlfilteringpolicies"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/user_authentication_settings"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/usermanagement/usermanagement"
"github.com/zscaler/zscaler-sdk-go/v2/zia/services/usermanagement/users"
"github.com/zscaler/zscaler-sdk-go/v2/zpa"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/appconnectorcontroller"
"github.com/zscaler/zscaler-sdk-go/v2/zpa/services/appconnectorgroup"
Expand Down Expand Up @@ -91,21 +92,22 @@ type ZPAClient struct {
}

type ZIAClient struct {
adminuserrolemgmt *adminuserrolemgmt.Service
admins *admins.Service
filteringrules *filteringrules.Service
ipdestinationgroups *ipdestinationgroups.Service
ipsourcegroups *ipsourcegroups.Service
networkapplications *networkapplications.Service
networkapplicationgroups *networkapplicationgroups.Service
networkservicegroups *networkservicegroups.Service
networkservices *networkservices.Service
timewindow *timewindow.Service
urlcategories *urlcategories.Service
urlfilteringpolicies *urlfilteringpolicies.Service
usermanagement *usermanagement.Service
users *users.Service
gretunnels *gretunnels.Service
gretunnelinfo *gretunnelinfo.Service
greinternalipranges *greinternalipranges.Service
staticips *staticips.Service
virtualipaddresslist *virtualipaddresslist.Service
virtualipaddress *virtualipaddress.Service
vpncredentials *vpncredentials.Service
locationmanagement *locationmanagement.Service
locationgroups *locationgroups.Service
Expand Down
Loading

0 comments on commit 62dec63

Please sign in to comment.