From a5dbdbb422acee7fa9196970f8598c6d21093569 Mon Sep 17 00:00:00 2001 From: Carlos Tadeu Panato Junior Date: Wed, 11 Sep 2024 16:00:59 +0200 Subject: [PATCH] drop old terraform version/add news and enable golangci-lint (#168) - drop old terraform versions - add new terraform versions - enable golangci-lint - fix lints --- .github/workflows/test.yml | 26 ++++++++++++++++++-------- .golangci.yml | 11 ++++++----- internal/provider/append_resource.go | 4 +++- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 394a5a3..fb4db2b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,12 +28,9 @@ jobs: - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 with: go-version-file: 'go.mod' - - run: go mod download - - run: go build -v . - # - name: Run linters - # uses: golangci/golangci-lint-action@08e2f20817b15149a52b5b3ebe7de50aff2ba8c5 # v3.4.0 - # with: - # version: latest + - run: | + go mod download + go build -v . generate: runs-on: ubuntu-latest @@ -60,10 +57,9 @@ jobs: matrix: # list whatever Terraform versions here you would like to support terraform: - - '1.5.*' - - '1.6.*' - '1.7.*' - '1.8.*' + - '1.9.*' steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 @@ -79,3 +75,17 @@ jobs: TF_ACC: "1" run: go test -v -cover ./internal/provider/ timeout-minutes: 10 + + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 + with: + go-version-file: 'go.mod' + cache: false + - name: golangci-lint + uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86 # v6.1.0 + with: + version: v1.60 diff --git a/.golangci.yml b/.golangci.yml index 4c6bb5a..4d3a243 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,7 +1,9 @@ -# Visit https://golangci-lint.run/ for usage documentation -# and information on other useful linters +--- +run: + timeout: 5m + issues: - max-per-linter: 0 + max-issues-per-linter: 0 max-same-issues: 0 linters: @@ -9,7 +11,6 @@ linters: enable: - durationcheck - errcheck - - exportloopref - forcetypeassert - godot - gofmt @@ -24,4 +25,4 @@ linters: - unconvert - unparam - unused - - vet + diff --git a/internal/provider/append_resource.go b/internal/provider/append_resource.go index a19014a..95e8493 100644 --- a/internal/provider/append_resource.go +++ b/internal/provider/append_resource.go @@ -292,7 +292,9 @@ func (r *AppendResource) doAppend(ctx context.Context, data *AppendResourceModel return nil, []diag.Diagnostic{diag.NewErrorDiagnostic("Unable to close gzip writer", fmt.Sprintf("Unable to close gzip writer, got error: %s", err))} } - l, err := tarball.LayerFromReader(&b) + l, err := tarball.LayerFromOpener(func() (io.ReadCloser, error) { + return io.NopCloser(bytes.NewBuffer(b.Bytes())), nil + }) if err != nil { return nil, []diag.Diagnostic{diag.NewErrorDiagnostic("Unable to create layer", fmt.Sprintf("Unable to create layer, got error: %s", err))} }