Skip to content

Commit

Permalink
Merge pull request #173 from zscaler/zt-#173-exclude-flag-improvement
Browse files Browse the repository at this point in the history
feat: Added multi exclude flag functionality
  • Loading branch information
willguibr authored Feb 29, 2024
2 parents ae28548 + 3e1f1d7 commit e0bbf1e
Show file tree
Hide file tree
Showing 34 changed files with 536 additions and 322 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
on: [pull_request]

permissions:
contents: read
pull-requests: read

name: Lint
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # needed for `only-new-issues` to compare diffs
- name: install go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: go1.20-${{ hashFiles('**/go.sum') }}
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
version: latest
# args: "--config .golintci.yml"
only-new-issues: true
skip-cache: true
22 changes: 0 additions & 22 deletions .github/workflows/linter.yml

This file was deleted.

59 changes: 38 additions & 21 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
name: tests
name: ZT Test

on:
push:
branches: [ master ]
paths-ignore:
- 'README.md'
- 'CHANGELOG.md'
- 'LICENSE'

pull_request:
branches: [ master ]
paths-ignore:
- 'README.md'
- 'CHANGELOG.md'
- 'LICENSE'
types: [opened, synchronize]
merge_group:
types: [checks_requested]
push:
branches:
- master

schedule:
- cron: '0 14 * * 1-5' # UTC
Expand All @@ -23,27 +17,43 @@ jobs:
test:
strategy:
matrix:
go-version: ['1.20']
goVersion: [1.20]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: install go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
go-version: "1.20"

- name: checkout
uses: actions/checkout@v4
- uses: actions/[email protected]
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}

- name: Setup Go Tools
run: make tools

- name: Download Go Dependencies
run: go mod tidy && go mod vendor
run: |
go mod tidy && go mod vendor
- name: Setup Go Tools
run: make tools

- name: Check Formatting
run: make fmtcheck

- name: Vet
run: go vet ./...

- name: Check out code into the Go module directory
uses: actions/checkout@v4

- name: Check Build
run: make build

- name: setup Terraform
uses: hashicorp/setup-terraform@v3

- name: write ZPA Terraform configuration
run: |
cat > main.tf <<EOF
Expand All @@ -56,8 +66,10 @@ jobs:
}
}
EOF
- name: terraform init
run: terraform init

- name: write ZIA Terraform configuration
run: |
cat > main.tf <<EOF
Expand All @@ -70,17 +82,22 @@ jobs:
}
}
EOF
- name: terraform init
run: terraform init

- name: Run go test
env:
ZPA_CLIENT_ID: ${{ secrets.ZPA_CLIENT_ID }}
ZPA_CLIENT_SECRET: ${{ secrets.ZPA_CLIENT_SECRET }}
ZPA_CUSTOMER_ID: ${{ secrets.ZPA_CUSTOMER_ID }}
ZPA_CLOUD: ${{ secrets.ZPA_CLOUD }}
ZIA_USERNAME: ${{ secrets.ZIA_USERNAME }}
ZIA_PASSWORD: ${{ secrets.ZIA_PASSWORD }}
ZIA_API_KEY: ${{ secrets.ZIA_API_KEY }}
ZIA_CLOUD: ${{ secrets.ZIA_CLOUD }}
ZSCALER_TERRAFORM_INSTALL_PATH: ${{ github.workspace }}
run: make test
run: |
make test_zpa
make test_zia
85 changes: 18 additions & 67 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,74 +1,25 @@
# This file contains all available configuration options
# with their default values.

# options for analysis running
run:
# default concurrency is a available CPU number
concurrency: 8
# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 30m
# exit code when at least one issue was found, default is 1
timeout: 5m
issues-exit-code: 1

# which dirs to skip: issues from them won't be reported;
# can use regexp here: generated.*, regexp is applied on full path;
# default value is empty list, but default dirs are skipped independently
# from this option's value (see skip-dirs-use-default).
skip-dirs:

# default is true. Enables skipping of directories:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
tests: true
skip-dirs-use-default: true

# which files to skip: they will be analyzed, but issues from them
# won't be reported. Default value is empty list, but there is
# no need to include all autogenerated files, we confidently recognize
# autogenerated files. If it's not please let us know.
skip-files:

# by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules":
# If invoked with -mod=readonly, the go command is disallowed from the implicit
# automatic updating of go.mod described above. Instead, it fails when any changes
# to go.mod are needed. This setting is most useful to check that go.mod does
# not need updates, such as in a continuous integration and testing system.
# If invoked with -mod=vendor, the go command assumes that the vendor
# directory holds the correct copies of dependencies and ignores
# the dependency descriptions in go.mod.
modules-download-mode: readonly


# output configuration options
output:
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
format: colored-line-number

# print lines of code with issue, default is true
print-issued-lines: true

# print linter name in the end of issue text, default is true
print-linter-name: true

# make issues output unique by line, default is true
uniq-by-line: true
issues:
max-issues-per-linter: 0
max-same-issues: 0
linters:
disable-all: true
enable:
- deadcode
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- structcheck
- typecheck
- unused
- varcheck
- gofmt
- revive
- goimports
- gocritic
- unconvert
- unparam
fast: false
# - bodyclose # ensure HTTP response bodies are successfully closed.
- contextcheck # check we are passing context an inherited context.
- gofmt # checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification.
- errname # checks that sentinel errors are prefixed with the `Err` and error types are suffixed with the `Error`.
- errcheck # a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases.
- errorlint # used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13.
- godot # check if comments end in a period.
- misspell # finds commonly misspelled English words in comments.
- nilerr # checks that there is no simultaneous return of nil error and an invalid value.
- tparallel # detects inappropriate usage of t.Parallel() method in your Go test codes.
- unparam # reports unused function parameters.
- whitespace # detection of leading and trailing whitespace.

output:
format: colored-line-number
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## 1.0.3 (February, 29 2024)

### Notes

- Release date: **(February, 29 2024)**
- Supported Terraform version: **v1.x.x**

### Enhancements

- [PR #173](https://github.com/zscaler/zscaler-terraformer/pull/173) Introduced the ability to exclude multiple resource names during the importing process.

## 1.0.2 (February, 15 2024)

### Notes
Expand Down
41 changes: 36 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
TEST ?= $$(go list ./...)
GO_FILES ?= $$(find . -name '*.go')

GOFMT_FILES ?= $$(find . -name '*.go')
VERSION ?= $$(git describe --tags --abbrev=0)-pre-release+$$(git rev-parse --short=12 HEAD)
ROOT_DIR = $$PWD

ZSCALER_TERRAFORM_INSTALL_PATH=$$PWD
HASHICORP_CHECKPOINT_TIMEMOUT ?= 30000
TFPROVIDERLINT=tfproviderlint
STATICCHECK=staticcheck

build:
@go build \
Expand All @@ -20,6 +21,7 @@ test_zpa:
ZPA_CLIENT_ID="$(ZPA_CLIENT_ID)" \
ZPA_CLIENT_SECRET="$(ZPA_CLIENT_SECRET)" \
ZPA_CUSTOMER_ID="$(ZPA_CUSTOMER_ID)" \
ZPA_CLOUD="$(ZPA_CLOUD)" \
go test $(TEST) -timeout 120m -v $(TESTARGS)

test_zia:
Expand All @@ -31,8 +33,37 @@ test_zia:
ZIA_API_KEY="$(ZIA_API_KEY)" \
ZIA_CLOUD="$(ZIA_CLOUD)" \
go test $(TEST) -timeout 120m -v $(TESTARGS)

vet:
@echo "==> Checking source code against go vet and staticcheck"
@go vet ./...
@staticcheck ./...

imports:
goimports -w $(GOFMT_FILES)

fmt:
gofmt -w $(GO_FILES)
gofmt -w $(GOFMT_FILES)

fmtcheck:
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"

errcheck:
@sh -c "'$(CURDIR)/scripts/errcheck.sh'"

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

tools:
@which $(GOFMT) || go install mvdan.cc/[email protected]
@which $(TFPROVIDERLINT) || go install github.com/bflad/tfproviderlint/cmd/[email protected]
@which $(STATICCHECK) || go install honnef.co/go/tools/cmd/[email protected]

tools-update:
@go install mvdan.cc/[email protected]
@go install github.com/bflad/tfproviderlint/cmd/[email protected]
@go install honnef.co/go/tools/cmd/[email protected]

validate-tf:
@bash scripts/validate-tf.sh
Expand All @@ -55,4 +86,4 @@ install:
-ldflags="-X github.com/zscaler/zscaler-terraformer/internal/app/zscaler-terraformer/cmd.versionString=$(VERSION)" \
-o $(DESTINATION)/zscaler-terraformer ./cmd/zscaler-terraformer/main.go

.PHONY: build test fmt validate-tf
.PHONY: build test fmt validate-tf vendor-status vet fmt fmtcheck errcheck tools vendor-status
Loading

0 comments on commit e0bbf1e

Please sign in to comment.