Skip to content

Commit 577256c

Browse files
authored
ci: Update setup-go action (#189)
* ci: Update setup-go action * refactor: Remove ioutils deprecated package usage
1 parent 9118967 commit 577256c

21 files changed

+99
-99
lines changed

.github/workflows/ci-master.yml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,11 @@ jobs:
4444
uses: actions/checkout@v2
4545

4646
- name: Set up Go
47-
uses: actions/setup-go@v2
47+
uses: actions/setup-go@v3
4848
with:
4949
go-version: ${{ env.GO_VERSION }}
50+
check-latest: true
51+
cache: true
5052

5153
- name: Build project
5254
run: GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -o terraform-provider-sysdig
@@ -60,21 +62,16 @@ jobs:
6062
uses: actions/checkout@v2
6163

6264
- name: Set up Go
63-
uses: actions/setup-go@v2
65+
uses: actions/setup-go@v3
6466
with:
6567
go-version: ${{ env.GO_VERSION }}
66-
67-
- name: Cache modules
68-
uses: actions/cache@v1
69-
with:
70-
path: ~/go/pkg/mod
71-
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
72-
restore-keys: |
73-
${{ runner.os }}-go-
68+
check-latest: true
69+
cache: true
7470

7571
- name: Get dependencies
7672
run: |
77-
go get -u -v github.com/onsi/ginkgo/ginkgo
73+
go install github.com/onsi/ginkgo/v2/ginkgo@latest
74+
go mod tidy
7875
7976
- name: Test
8077
run: make test

.github/workflows/ci-provider-docs.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ jobs:
2323
path: terraform-plugin-dir
2424
key: ${{ runner.os }}-terraform-plugin-dir-${{ hashFiles('go.sum') }}-${{ hashFiles('sysdig/**') }}
2525
- if: steps.cache-terraform-plugin-dir.outputs.cache-hit != 'true' || steps.cache-terraform-plugin-dir.outcome == 'failure'
26-
uses: actions/setup-go@v2
26+
uses: actions/setup-go@v3
2727
with:
2828
go-version: ${{ env.GO_VERSION }}
29+
check-latest: true
30+
cache: true
2931
# See also: https://github.com/actions/setup-go/issues/54
3032
- if: steps.cache-terraform-plugin-dir.outputs.cache-hit != 'true' || steps.cache-terraform-plugin-dir.outcome == 'failure'
3133
name: go env
@@ -90,9 +92,11 @@ jobs:
9092
runs-on: ubuntu-latest
9193
steps:
9294
- uses: actions/checkout@v2
93-
- uses: actions/setup-go@v2
95+
- uses: actions/setup-go@v3
9496
with:
9597
go-version: ${{ env.GO_VERSION }}
98+
check-latest: true
99+
cache: true
96100
- uses: actions/cache@v2
97101
continue-on-error: true
98102
timeout-minutes: 2

.github/workflows/ci-pull-request.yml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,11 @@ jobs:
4444
uses: actions/checkout@v2
4545

4646
- name: Set up Go
47-
uses: actions/setup-go@v2
47+
uses: actions/setup-go@v3
4848
with:
4949
go-version: ${{ env.GO_VERSION }}
50+
check-latest: true
51+
cache: true
5052

5153
- name: Build project
5254
run: GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -o terraform-provider-sysdig
@@ -60,21 +62,15 @@ jobs:
6062
uses: actions/checkout@v2
6163

6264
- name: Set up Go
63-
uses: actions/setup-go@v2
65+
uses: actions/setup-go@v3
6466
with:
6567
go-version: ${{ env.GO_VERSION }}
66-
67-
- name: Cache modules
68-
uses: actions/cache@v1
69-
with:
70-
path: ~/go/pkg/mod
71-
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
72-
restore-keys: |
73-
${{ runner.os }}-go-
68+
check-latest: true
69+
cache: true
7470

7571
- name: Get dependencies
7672
run: |
77-
go get -u -v github.com/onsi/ginkgo/ginkgo
73+
go install github.com/onsi/ginkgo/v2/ginkgo@latest
7874
go mod tidy
7975
8076
- name: Test

.github/workflows/release.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ jobs:
2727
- name: Unshallow
2828
run: git fetch --prune --unshallow
2929
- name: Set up Go
30-
uses: actions/setup-go@v2
30+
uses: actions/setup-go@v3
3131
with:
3232
go-version: ${{ env.GO_VERSION }}
33+
check-latest: true
34+
cache: true
3335
- name: Import GPG key
3436
id: import_gpg
3537
uses: paultyng/[email protected]

GNUmakefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
SWEEP?=us-east-1,us-west-2
22
TEST?=./...
3-
GOFMT_FILES?=$$(find . -name '*.go' |grep -v vendor)
43
PKG_NAME=sysdig
54
WEBSITE_REPO=github.com/hashicorp/terraform-website
65
VERSION=$(shell [ ! -z `git tag -l --contains HEAD` ] && git tag -l --contains HEAD || git rev-parse --short HEAD)
@@ -31,7 +30,9 @@ vet:
3130
fi
3231

3332
fmt:
34-
gofmt -w $(GOFMT_FILES)
33+
go install mvdan.cc/gofumpt@latest
34+
go fmt ./...
35+
gofumpt -w ./
3536

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

scripts/errcheck.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ echo "==> Checking for unchecked errors..."
55

66
if ! which errcheck > /dev/null; then
77
echo "==> Installing errcheck..."
8-
go get -u github.com/kisielk/errcheck
8+
go install github.com/kisielk/errcheck@latest
99
fi
1010

1111
err_files=$(errcheck -ignoretests \

sysdig/data_source_sysdig_fargate_ECS_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package sysdig
33
import (
44
"context"
55
"encoding/json"
6-
"io/ioutil"
6+
"os"
77
"sort"
88
"testing"
99

@@ -55,7 +55,7 @@ func sortAndCompare(t *testing.T, expected []byte, actual []byte) {
5555
}
5656

5757
func TestECStransformation(t *testing.T) {
58-
inputfile, err := ioutil.ReadFile("testfiles/ECSinput.json")
58+
inputfile, err := os.ReadFile("testfiles/ECSinput.json")
5959

6060
if err != nil {
6161
t.Fatalf("Cannot find testfiles/ECSinput.json")
@@ -89,7 +89,7 @@ func TestECStransformation(t *testing.T) {
8989
t.Fatalf("Cannot execute PatchFargateTaskDefinition : %v", err.Error())
9090
}
9191

92-
expectedOutput, err := ioutil.ReadFile("testfiles/ECSInstrumented.json")
92+
expectedOutput, err := os.ReadFile("testfiles/ECSInstrumented.json")
9393
if err != nil {
9494
t.Fatalf("Cannot find testfiles/ECSinput.json")
9595
}
@@ -145,9 +145,9 @@ func TestTransform(t *testing.T) {
145145
RecipeConfig: string(jsonConfig),
146146
}
147147

148-
inputContainerDefinition, _ := ioutil.ReadFile("testfiles/" + testName + ".json")
148+
inputContainerDefinition, _ := os.ReadFile("testfiles/" + testName + ".json")
149149
patched, _ := patchFargateTaskDefinition(context.Background(), string(inputContainerDefinition), kiltConfig, nil)
150-
expectedContainerDefinition, _ := ioutil.ReadFile("testfiles/" + testName + "_expected.json")
150+
expectedContainerDefinition, _ := os.ReadFile("testfiles/" + testName + "_expected.json")
151151

152152
sortAndCompare(t, expectedContainerDefinition, []byte(*patched))
153153
})
@@ -170,9 +170,9 @@ func TestLogGroup(t *testing.T) {
170170
"region": "test_region",
171171
}
172172

173-
inputContainerDefinition, _ := ioutil.ReadFile("testfiles/fargate_log_group.json")
173+
inputContainerDefinition, _ := os.ReadFile("testfiles/fargate_log_group.json")
174174
patched, _ := patchFargateTaskDefinition(context.Background(), string(inputContainerDefinition), kiltConfig, logConfig)
175-
expectedContainerDefinition, _ := ioutil.ReadFile("testfiles/fargate_log_group_expected.json")
175+
expectedContainerDefinition, _ := os.ReadFile("testfiles/fargate_log_group_expected.json")
176176

177177
sortAndCompare(t, expectedContainerDefinition, []byte(*patched))
178178
}

sysdig/internal/client/common/users.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55
"encoding/json"
66
"fmt"
7-
"io/ioutil"
7+
"io"
88
"net/http"
99
)
1010

@@ -20,7 +20,7 @@ func (client *sysdigCommonClient) GetUserById(ctx context.Context, id int) (u *U
2020
return
2121
}
2222

23-
body, _ := ioutil.ReadAll(response.Body)
23+
body, _ := io.ReadAll(response.Body)
2424
user := UserFromJSON(body)
2525
return &user, nil
2626
}
@@ -68,7 +68,7 @@ func (client *sysdigCommonClient) CreateUser(ctx context.Context, uRequest *User
6868
return
6969
}
7070

71-
body, _ := ioutil.ReadAll(response.Body)
71+
body, _ := io.ReadAll(response.Body)
7272
user := UserFromJSON(body)
7373
return &user, nil
7474
}
@@ -85,7 +85,7 @@ func (client *sysdigCommonClient) UpdateUser(ctx context.Context, uRequest *User
8585
return
8686
}
8787

88-
body, _ := ioutil.ReadAll(response.Body)
88+
body, _ := io.ReadAll(response.Body)
8989
user := UserFromJSON(body)
9090
return &user, nil
9191
}
@@ -115,7 +115,7 @@ func (client *sysdigCommonClient) GetCurrentUser(ctx context.Context) (u *User,
115115
return
116116
}
117117

118-
body, _ := ioutil.ReadAll(response.Body)
118+
body, _ := io.ReadAll(response.Body)
119119
user := UserFromJSON(body)
120120
return &user, nil
121121
}

sysdig/internal/client/monitor/alerts.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package monitor
33
import (
44
"context"
55
"fmt"
6-
"io/ioutil"
6+
"io"
77
"net/http"
88
)
99

@@ -19,7 +19,7 @@ func (c *sysdigMonitorClient) CreateAlert(ctx context.Context, alert Alert) (cre
1919
return
2020
}
2121

22-
body, err := ioutil.ReadAll(response.Body)
22+
body, err := io.ReadAll(response.Body)
2323
if err != nil {
2424
return
2525
}
@@ -52,7 +52,7 @@ func (c *sysdigMonitorClient) UpdateAlert(ctx context.Context, alert Alert) (upd
5252
return
5353
}
5454

55-
body, err := ioutil.ReadAll(response.Body)
55+
body, err := io.ReadAll(response.Body)
5656
if err != nil {
5757
return
5858
}
@@ -71,7 +71,7 @@ func (c *sysdigMonitorClient) GetAlertById(ctx context.Context, alertID int) (al
7171
return
7272
}
7373

74-
body, err := ioutil.ReadAll(response.Body)
74+
body, err := io.ReadAll(response.Body)
7575
if err != nil {
7676
return
7777
}

sysdig/internal/client/monitor/dashboards.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package monitor
33
import (
44
"context"
55
"fmt"
6-
"io/ioutil"
6+
"io"
77
"net/http"
88

99
"github.com/draios/terraform-provider-sysdig/sysdig/internal/client/monitor/model"
@@ -20,7 +20,7 @@ func (client *sysdigMonitorClient) GetDashboardByID(ctx context.Context, ID int)
2020
return nil, errorFromResponse(response)
2121
}
2222

23-
body, err := ioutil.ReadAll(response.Body)
23+
body, err := io.ReadAll(response.Body)
2424
if err != nil {
2525
return nil, nil
2626
}
@@ -38,7 +38,7 @@ func (client *sysdigMonitorClient) CreateDashboard(ctx context.Context, dashboar
3838
return nil, errorFromResponse(response)
3939
}
4040

41-
body, err := ioutil.ReadAll(response.Body)
41+
body, err := io.ReadAll(response.Body)
4242
if err != nil {
4343
return nil, err
4444
}
@@ -56,7 +56,7 @@ func (client *sysdigMonitorClient) UpdateDashboard(ctx context.Context, dashboar
5656
return nil, errorFromResponse(response)
5757
}
5858

59-
body, err := ioutil.ReadAll(response.Body)
59+
body, err := io.ReadAll(response.Body)
6060
if err != nil {
6161
return nil, err
6262
}

0 commit comments

Comments
 (0)