Skip to content

Commit

Permalink
Merge branch 'master' into zia-#212-workloadgroups
Browse files Browse the repository at this point in the history
  • Loading branch information
willguibr authored Jan 26, 2024
2 parents 784805e + 6bc6968 commit b7caa81
Show file tree
Hide file tree
Showing 62 changed files with 199 additions and 122 deletions.
12 changes: 4 additions & 8 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
version: 2
updates:
- package-ecosystem: gomod
directory: "/"
schedule:
interval: daily
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: gomod
directory: "/"
schedule:
interval: daily
6 changes: 3 additions & 3 deletions .github/workflows/reuse-zcon-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ jobs:
go-version: 1.19
- name: Checkout code
uses: actions/checkout@v4
- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ubuntu-go1.19-${{ hashFiles('**/go.mod') }}-${{ hashFiles('**/go.sum') }}
- name: Run tests with retry on Ubuntu
uses: nick-invision/retry@v2
with:
max_attempts: 3
timeout_minutes: 10 # Adjust as needed
timeout_minutes: 20 # Adjust as needed
command: |
make test:integration:zcon
make zconActivator
Expand All @@ -56,7 +56,7 @@ jobs:
go-version: 1.19
- name: Checkout code
uses: actions/checkout@v4
- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: macos-go1.19-${{ hashFiles('**/go.mod') }}-${{ hashFiles('**/go.sum') }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reuse-zdx-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v4
- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go${{ matrix.go-version }}-${{ hashFiles('**/go.mod') }}-${{ hashFiles('**/go.sum') }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/reuse-zia-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
go-version: 1.19
- name: Checkout code
uses: actions/checkout@v4
- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ubuntu-go1.19-${{ hashFiles('**/go.mod') }}-${{ hashFiles('**/go.sum') }}
Expand Down Expand Up @@ -71,7 +71,7 @@ jobs:
go-version: 1.19
- name: Checkout code
uses: actions/checkout@v4
- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: macos-go1.19-${{ hashFiles('**/go.mod') }}-${{ hashFiles('**/go.sum') }}
Expand Down
30 changes: 20 additions & 10 deletions .github/workflows/reuse-zpa-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,36 @@ on:
jobs:
zpa-test:
environment: ${{ inputs.environment }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
go-version: [1.19]
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
goVersion: ["1.19", "1.20"]
steps:
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Checkout
uses: actions/checkout@v4

- name: Checkout code
uses: actions/checkout@v4
- uses: actions/cache@v3

- name: Setup Go
uses: actions/setup-go@v5
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go${{ matrix.go-version }}-${{ hashFiles('**/go.mod') }}-${{ hashFiles('**/go.sum') }}
go-version: ${{ matrix.goVersion }}

- name: Set Go env
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Pull external libraries
run: make vendor

- name: Run tests with retry
uses: nick-invision/retry@v2
with:
max_attempts: 3
timeout_minutes: 10 # Adjust as needed
timeout_minutes: 30 # Adjust as needed
command: |
make test:unit
make test:unit:zpa
Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
name: Test
on:
pull_request:
types: [opened, synchronize]
merge_group:
types: [checks_requested]
push:
branches:
- master
- develop
- beta
- alpha
- '[0-9]+.x'
- '[0-9]+.[0-9]+.x'
pull_request:

# For systems with an upstream API that could drift unexpectedly (like most SaaS systems, etc.),
# we recommend testing at a regular interval not necessarily tied to code changes. This will
Expand Down
38 changes: 35 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,39 @@ help:
@echo "$(COLOR_OK) test:zpa Run only zpa integration tests$(COLOR_NONE)"
@echo "$(COLOR_OK) test:unit Run only unit tests$(COLOR_NONE)"

build:
@echo "$(COLOR_ZSCALER)Building SDK...$(COLOR_NONE)"
make test:all
default: build

build: vendor
@echo "$(COLOR_ZSCALER)✓ Building SDK Source Code with Go Build...$(COLOR_NONE)"
@go build -mod vendor -v

vendor:
@echo "✓ Filling vendor folder with library code ..."
@go mod vendor

fmt:
@echo "✓ Formatting source code with goimports ..."
@go run golang.org/x/tools/cmd/goimports@latest -w $(shell find . -type f -name '*.go' -not -path "./vendor/*")
@echo "✓ Formatting source code with gofmt ..."
@gofmt -w $(shell find . -type f -name '*.go' -not -path "./vendor/*")

doc:
@echo "Open http://localhost:6060"
@go run golang.org/x/tools/cmd/godoc@latest -http=localhost:6060

lint: vendor
@echo "✓ Linting source code with https://staticcheck.io/ ..."
@go run honnef.co/go/tools/cmd/[email protected] ./...

test: lint
@echo "✓ Running tests ..."
@go run gotest.tools/gotestsum@latest --format pkgname-and-test-fails \
--no-summary=skipped --raw-command go test -v \
-json -short -coverprofile=coverage.txt ./...

coverage: test
@echo "✓ Opening coverage for unit tests ..."
@go tool cover -html=coverage.txt

test:
make test:all
Expand Down Expand Up @@ -142,3 +172,5 @@ import: check-goimports

check-goimports:
@which $(GOIMPORTS) > /dev/null || GO111MODULE=on go install golang.org/x/tools/cmd/goimports@latest

.PHONY: fmt vendor fmt coverage test lint doc
3 changes: 1 addition & 2 deletions cache/nop-cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import (
"net/http"
)

type nopCache struct {
}
type nopCache struct{}

func NewNopCache() Cache {
return &nopCache{}
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ go 1.19
require (
github.com/allegro/bigcache/v3 v3.1.0
github.com/google/go-querystring v1.1.0
github.com/google/uuid v1.5.0
github.com/google/uuid v1.6.0
github.com/hashicorp/go-retryablehttp v0.7.5
github.com/hashicorp/terraform-plugin-sdk v1.17.2
github.com/hashicorp/terraform-plugin-sdk/v2 v2.31.0
github.com/stretchr/testify v1.8.4
github.com/zscaler/zscaler-sdk-go v1.7.0
golang.org/x/text v0.14.0
)

Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hf
github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU=
github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
Expand Down Expand Up @@ -287,8 +287,6 @@ github.com/zclconf/go-cty v1.2.1/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q
github.com/zclconf/go-cty v1.8.2/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk=
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 v1.7.0 h1:vE0DhIqNMxEnD7AUzSpm66wrWog29LMGBOfdCiRoem4=
github.com/zscaler/zscaler-sdk-go v1.7.0/go.mod h1:MNjkC5vOnUdlQUVgPk8ePOR5YuRgcRf003PS1N1tYqc=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
Expand Down
1 change: 1 addition & 0 deletions staticcheck.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
checks = ["inherit", "-SA1019"]
2 changes: 1 addition & 1 deletion zcon/services/adminuserrolemgmt/adminusers/adminusers.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const (
)

type AdminUsers struct {
//Admin or auditor's user ID
// Admin or auditor's user ID
ID int `json:"id,omitempty"`

// Admin or auditor's login name. loginName is in email format and uses the domain name associated to the Zscaler account
Expand Down
1 change: 1 addition & 0 deletions zcon/services/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ type ECInstances struct {
func GetPageSize() int {
return pageSize
}

func ReadAllPages[T any](client *zcon.Client, endpoint string, list *[]T) error {
if list == nil {
return nil
Expand Down
2 changes: 1 addition & 1 deletion zcon/services/locationmanagement/location/location.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ type Locations struct {
// Enable Basic Authentication at the location
ECLocation bool `json:"ecLocation"`

//Enable Surrogate IP. When set to true, users are mapped to internal device IP addresses
// Enable Surrogate IP. When set to true, users are mapped to internal device IP addresses
SurrogateIP bool `json:"surrogateIP"`

// Idle Time to Disassociation. The user mapping idle time (in minutes) is required if a Surrogate IP is enabled
Expand Down
4 changes: 2 additions & 2 deletions zcon/services/locationmanagement/locationlite/locationlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type LocationLite struct {
// Note: For sub-locations, this attribute is a read-only field as the value is inherited from the parent location.
XFFForwardEnabled bool `json:"xffForwardEnabled,omitempty"`

//Enable AUP. When set to true, AUP is enabled for the location. To learn more, see About End User Notifications
// Enable AUP. When set to true, AUP is enabled for the location. To learn more, see About End User Notifications
AUPEnabled bool `json:"aupEnabled"`

// Enable Caution. When set to true, a caution notifcation is enabled for the location
Expand All @@ -41,7 +41,7 @@ type LocationLite struct {
// For First Time AUP Behavior, Force SSL Inspection. When set, Zscaler forces SSL Inspection in order to enforce AUP for HTTPS traffic.
AUPForceSSLInspection bool `json:"aupForceSslInspection"`

//Enable Surrogate IP. When set to true, users are mapped to internal device IP addresses
// Enable Surrogate IP. When set to true, users are mapped to internal device IP addresses
SurrogateIP bool `json:"surrogateIP"`

// Enforce Surrogate IP for Known Browsers. When set to true, IP Surrogate is enforced for all known browsers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const (
)

type LocationTemplate struct {
//ID of Cloud & Branch Connector location template
// ID of Cloud & Branch Connector location template
ID int `json:"id,omitempty"`

// Name of Cloud & Branch Connector location template
Expand All @@ -38,7 +38,7 @@ type LocationTemplate struct {
}

type LocationTemplateDetails struct {
//Prefix of Cloud & Branch Connector location template
// Prefix of Cloud & Branch Connector location template
TemplatePrefix string `json:"templatePrefix,omitempty"`

// Enable if you want the Zscaler service to use the X-Forwarded-For (XFF) headers that your on-premise proxy server inserts in outbound HTTP requests
Expand Down
4 changes: 2 additions & 2 deletions zdx/services/administration/administration.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ type GetDepartmentsFilters struct {
common.GetFromToFilters
// The Zscaler location (ID). You can add multiple location IDs.
Loc []int `json:"loc,omitempty" url:"loc,omitempty"`
//The search string used to support search by name or department ID.
// The search string used to support search by name or department ID.
Search string `json:"search,omitempty" url:"search,omitempty"`
}

type GetLocationsFilters struct {
common.GetFromToFilters
// The Zscaler location (ID). You can add multiple location IDs.
Loc []int `json:"loc,omitempty" url:"loc,omitempty"`
//The search string used to support search by name or department ID.
// The search string used to support search by name or department ID.
Search string `json:"q,omitempty" url:"q,omitempty"`
}

Expand Down
2 changes: 1 addition & 1 deletion zia/services/adminuserrolemgmt/admins/adminusers.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const (
)

type AdminUsers struct {
//Admin or auditor's user ID
// Admin or auditor's user ID
ID int `json:"id,omitempty"`

// Admin or auditor's login name. loginName is in email format and uses the domain name associated to the Zscaler account
Expand Down
7 changes: 5 additions & 2 deletions zia/services/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ type SandboxRSS struct {
func GetPageSize() int {
return pageSize
}

func ReadAllPages[T any](client *zia.Client, endpoint string, list *[]T) error {
if list == nil {
return nil
Expand Down Expand Up @@ -141,8 +142,10 @@ func ReadPage[T any](client *zia.Client, endpoint string, page int, list *[]T) e
return nil
}

type SortOrder string
type SortField string
type (
SortOrder string
SortField string
)

const (
ASCSortOrder SortOrder = "ASC"
Expand Down
1 change: 0 additions & 1 deletion zia/services/devicegroups/devicegroups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func TestDeviceGroup_data(t *testing.T) {
t.Errorf("Expected error when getting by non-existent name, got nil")
return
}

}

func TestResponseFormatValidation(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const (
)

type DlpNotificationTemplates struct {

// The unique identifier for a DLP notification template.
ID int `json:"id"`

Expand Down
Loading

0 comments on commit b7caa81

Please sign in to comment.