Skip to content

Commit 66759d1

Browse files
authored
Merge pull request #27 from doitintl/update/go
update go and linter
2 parents b5c878b + 9304889 commit 66759d1

17 files changed

+3363
-543
lines changed

.github/workflows/docker-release.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,24 @@ jobs:
1515

1616
steps:
1717
- name: Checkout
18-
uses: actions/checkout@v2
18+
uses: actions/checkout@v3
1919

2020
- name: Set up QEMU
21-
uses: docker/setup-qemu-action@v1
21+
uses: docker/setup-qemu-action@v2
2222

2323
- name: Set up Docker buildx
2424
id: buildx
25-
uses: docker/setup-buildx-action@v1
25+
uses: docker/setup-buildx-action@v2
2626

2727
- name: Login to Docker Registry
28-
uses: docker/login-action@v1
28+
uses: docker/login-action@v2
2929
with:
3030
registry: ${{ secrets.DOCKER_REGISTRY }}
3131
username: ${{ secrets.DOCKER_USERNAME }}
3232
password: ${{ secrets.DOCKER_PASSWORD }}
3333

3434
- name: Login to GitHub Container Registry
35-
uses: docker/login-action@v1
35+
uses: docker/login-action@v2
3636
with:
3737
registry: ghcr.io
3838
username: ${{ github.repository_owner }}
@@ -61,7 +61,7 @@ jobs:
6161
echo "::debug::docker image tag ${tag}"
6262
6363
- name: Cache Docker layers
64-
uses: actions/cache@v2
64+
uses: actions/cache@v3
6565
id: cache
6666
with:
6767
path: /tmp/.buildx-cache
@@ -71,7 +71,7 @@ jobs:
7171
7272
- name: Build and push Docker image
7373
id: build-push
74-
uses: docker/build-push-action@v2
74+
uses: docker/build-push-action@v3
7575
with:
7676
build-args: VERSION=${{ steps.tagger.outputs.tag }}
7777
platforms: linux/amd64,linux/arm64

.github/workflows/github-release.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ jobs:
1515

1616
steps:
1717
- name: Checkout
18-
uses: actions/checkout@v2
18+
uses: actions/checkout@v3
1919

2020
- name: Install Go
21-
uses: actions/setup-go@v2
21+
uses: actions/setup-go@v3
2222
with:
23-
go-version: 1.16.x
23+
go-version: '>=1.19.0'
2424

2525
- name: Cross-Platform build
2626
run: |
@@ -33,7 +33,7 @@ jobs:
3333

3434
- name: Release to GitHub
3535
if: startsWith(github.ref, 'refs/tags/')
36-
uses: anton-yurchenko/git-release@v3.4.4
36+
uses: docker://antonyurchenko/git-release:latest
3737
env:
3838
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3939
DRAFT_RELEASE: "true"

.github/workflows/test.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ jobs:
2020

2121
steps:
2222
- name: Checkout code
23-
uses: actions/checkout@v2
23+
uses: actions/checkout@v3
2424

2525
- name: Install Go
26-
uses: actions/setup-go@v2
26+
uses: actions/setup-go@v3
2727
with:
28-
go-version: 1.16.x
28+
go-version: '>=1.19.0'
2929

3030
- name: Lint
3131
run: |

.golangci.yaml

Lines changed: 80 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
1+
run:
2+
# which dirs to skip
3+
skip-dirs:
4+
- mocks
5+
# Timeout for analysis, e.g. 30s, 5m.
6+
# Default: 1m
7+
timeout: 5m
8+
# Exit code when at least one issue was found.
9+
# Default: 1
10+
issues-exit-code: 2
11+
# Include test files or not.
12+
# Default: true
13+
tests: false
14+
115
linters-settings:
216
govet:
317
check-shadowing: true
4-
golint:
5-
min-confidence: 0
618
gocyclo:
719
min-complexity: 15
820
maligned:
@@ -14,8 +26,8 @@ linters-settings:
1426
min-occurrences: 2
1527
misspell:
1628
locale: US
17-
lll:
18-
line-length: 140
29+
ignore-words:
30+
- "cancelled"
1931
goimports:
2032
local-prefixes: github.com/golangci/golangci-lint
2133
gocritic:
@@ -34,54 +46,99 @@ linters-settings:
3446
- whyNoLint
3547
- wrapperFunc
3648
funlen:
37-
lines: 100
49+
lines: 105
3850
statements: 50
3951

4052
linters:
4153
# please, do not use `enable-all`: it's deprecated and will be removed soon.
4254
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
4355
disable-all: true
4456
enable:
45-
# - rowserrcheck
57+
- asciicheck
58+
- bidichk
4659
- bodyclose
47-
- deadcode
60+
# - containedctx
61+
# - contextcheck disabled because of generics
62+
- dupword
63+
- decorder
4864
- depguard
4965
- dogsled
5066
- dupl
67+
- durationcheck
5168
- errcheck
69+
- errchkjson
70+
- errname
71+
- errorlint
72+
- exhaustive
73+
# - exhaustivestruct TODO: check how to fix it
74+
- exportloopref
75+
# - forbidigo TODO: configure forbidden code patterns
76+
# - forcetypeassert
5277
- funlen
78+
- gci
79+
# - gochecknoglobals TODO: remove globals from code
80+
# - gochecknoinits TODO: remove main.init
81+
- gocognit
5382
- goconst
5483
- gocritic
5584
- gocyclo
85+
# - godox
86+
- goerr113
5687
- gofmt
5788
- goimports
58-
- golint
89+
- gomnd
90+
# - gomoddirectives
5991
- gosec
6092
- gosimple
6193
- govet
94+
- goprintffuncname
95+
- grouper
96+
- importas
97+
# - ireturn TODO: not sure if it is a good linter
6298
- ineffassign
63-
- interfacer
64-
- lll
99+
- interfacebloat
100+
- loggercheck
101+
- maintidx
102+
- makezero
65103
- misspell
66104
- nakedret
67-
- scopelint
68-
- staticcheck
69-
- structcheck
105+
# - nestif
106+
- nilerr
107+
- nilnil
108+
# - noctx
109+
- nolintlint
110+
- prealloc
111+
- predeclared
112+
- promlinter
113+
- reassign
114+
- revive
115+
# - rowserrcheck disabled because of generics
116+
# - staticcheck doesn't work with go1.19
117+
# - structcheck disabled because of generics
70118
- stylecheck
119+
- tenv
120+
- testableexamples
71121
- typecheck
72122
- unconvert
73123
- unparam
74124
- unused
75-
- varcheck
125+
# - varnamelen TODO: review naming
126+
# - varcheck depricated 1.49
127+
# - wastedassign disabled because of generics
76128
- whitespace
77-
78-
# don't enable:
79-
# - gochecknoglobals
80-
# - gocognit
81-
# - godox
82-
# - maligned
83-
# - prealloc
129+
- wrapcheck
130+
# - wsl
84131

85132
issues:
86-
exclude:
87-
- Using the variable on range scope `tt` in function literal
133+
exclude-rules:
134+
- path: _test\.go
135+
linters:
136+
- funlen
137+
- bodyclose
138+
- gosec
139+
- dupl
140+
- gocognit
141+
- goconst
142+
- gocyclo
143+
exclude:
144+
- Using the variable on range scope `tt` in function literal

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# syntax = docker/dockerfile:experimental
22

3-
FROM --platform=${BUILDPLATFORM} golang:1.16-alpine as builder
3+
FROM --platform=${BUILDPLATFORM} golang:1.19-alpine as builder
44
# passed by buildkit
55
ARG TARGETOS
66
ARG TARGETARCH

Makefile

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export CGO_ENABLED=0
2828
export GOPROXY=https://proxy.golang.org
2929

3030
.PHONY: all
31-
all: fmt lint test ; $(info $(M) building executable) @ ## Build program binary
31+
all: fmt lint test ; $(info $(M) building executable...) @ ## Build program binary
3232
$Q env GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) $(GO) build \
3333
-tags release \
3434
-ldflags "$(LDFLAGS_VERSION) -X main.Platform=$(TARGETOS)/$(TARGETARCH)" \
@@ -52,7 +52,7 @@ platfrom-build: clean lint test ; $(info $(M) building binaries for multiple os/
5252
setup-tools: setup-lint setup-gocov setup-gocov-xml setup-go2xunit setup-mockery setup-ghr
5353

5454
setup-lint:
55-
$(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.39
55+
$(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.50.1
5656
setup-gocov:
5757
$(GO) install github.com/axw/gocov/...
5858
setup-gocov-xml:
@@ -80,10 +80,10 @@ test-verbose: ARGS=-v ## Run tests in verbose mode with coverage repo
8080
test-race: ARGS=-race ## Run tests with race detector
8181
$(TEST_TARGETS): NAME=$(MAKECMDGOALS:test-%=%)
8282
$(TEST_TARGETS): test
83-
check test tests: fmt ; $(info $(M) running $(NAME:%=% )tests) @ ## Run tests
83+
check test tests: fmt ; $(info $(M) running $(NAME:%=% )tests...) @ ## Run tests
8484
$Q $(GO) test -timeout $(TIMEOUT)s $(ARGS) $(TESTPKGS)
8585

86-
test-xml: fmt lint | $(GO2XUNIT) ; $(info $(M) running xUnit tests) @ ## Run tests with xUnit output
86+
test-xml: fmt lint | $(GO2XUNIT) ; $(info $(M) running xUnit tests...) @ ## Run tests with xUnit output
8787
$Q mkdir -p test
8888
$Q 2>&1 $(GO) test -timeout $(TIMEOUT)s -v $(TESTPKGS) | tee test/tests.output
8989
$(GO2XUNIT) -fail -input test/tests.output -output test/tests.xml
@@ -95,7 +95,7 @@ COVERAGE_HTML = $(COVERAGE_DIR)/index.html
9595
.PHONY: test-coverage test-coverage-tools
9696
test-coverage-tools: | $(GOCOV) $(GOCOVXML)
9797
test-coverage: COVERAGE_DIR := $(CURDIR)/test/coverage.$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
98-
test-coverage: fmt lint test-coverage-tools ; $(info $(M) running coverage tests) @ ## Run coverage tests
98+
test-coverage: fmt lint test-coverage-tools ; $(info $(M) running coverage tests...) @ ## Run coverage tests
9999
$Q mkdir -p $(COVERAGE_DIR)
100100
$Q $(GO) test \
101101
-coverpkg=$$($(GO) list -f '{{ join .Deps "\n" }}' $(TESTPKGS) | \
@@ -111,15 +111,15 @@ lint: setup-lint ; $(info $(M) running golangci-lint) @ ## Run golangci-lint
111111
$Q $(GOLINT) run --timeout=5m -v -c $(LINT_CONFIG) ./...
112112

113113
.PHONY: fmt
114-
fmt: ; $(info $(M) running gofmt) @ ## Run gofmt on all source files
114+
fmt: ; $(info $(M) running gofmt...) @ ## Run gofmt on all source files
115115
$Q $(GO) fmt $(PKGS)
116116

117117
.PHONY: mock
118-
mock: | $(GOMOCK) ; $(info $(M) generating mocks) @ ## Run mockery
118+
mock: ; $(info $(M) generating mocks...) @ ## Run mockery
119119
$Q $(GO) mod vendor -v
120-
$Q $(GOMOCK) -name SecretsManagerAPI -dir vendor/github.com/aws/aws-sdk-go/service/secretsmanager/secretsmanageriface
121-
$Q $(GOMOCK) -name SSMAPI -dir vendor/github.com/aws/aws-sdk-go/service/ssm/ssmiface
122-
$Q $(GOMOCK) -name GoogleSecretsManagerAPI -dir pkg/secrets/google
120+
$Q $(GOMOCK) --name SecretsManagerAPI --dir vendor/github.com/aws/aws-sdk-go/service/secretsmanager/secretsmanageriface
121+
$Q $(GOMOCK) --name SSMAPI --dir vendor/github.com/aws/aws-sdk-go/service/ssm/ssmiface
122+
$Q $(GOMOCK) --name GoogleSecretsManagerAPI --dir pkg/secrets/google
123123
$Q rm -rf vendor
124124

125125
# Misc
@@ -137,7 +137,7 @@ endif
137137
--token $(GITHUB_TOKEN)
138138

139139
.PHONY: clean
140-
clean: ; $(info $(M) cleaning) @ ## Cleanup everything
140+
clean: ; $(info $(M) cleaning...) @ ## Cleanup everything
141141
@rm -rf $(BIN)
142142
@rm -rf test/tests.* test/coverage.*
143143

go.mod

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,42 @@
11
module secrets-init
22

3-
go 1.14
3+
go 1.19
44

55
require (
6-
cloud.google.com/go v0.56.0
7-
github.com/aws/aws-sdk-go v1.24.1
8-
github.com/googleapis/gax-go/v2 v2.0.5
6+
cloud.google.com/go/secretmanager v1.8.0
7+
github.com/aws/aws-sdk-go v1.44.128
8+
github.com/googleapis/gax-go/v2 v2.6.0
99
github.com/pkg/errors v0.9.1
10-
github.com/sirupsen/logrus v1.4.2
11-
github.com/stretchr/testify v1.4.0
12-
github.com/urfave/cli/v2 v2.0.0
13-
golang.org/x/sys v0.0.0-20200331124033-c3d80250170d
14-
google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940
10+
github.com/sirupsen/logrus v1.9.0
11+
github.com/stretchr/testify v1.8.1
12+
github.com/urfave/cli/v2 v2.23.0
13+
golang.org/x/sys v0.1.0
14+
google.golang.org/genproto v0.0.0-20221010155953-15ba04fc1c0e
15+
)
16+
17+
require (
18+
cloud.google.com/go/compute v1.10.0 // indirect
19+
cloud.google.com/go/iam v0.5.0 // indirect
20+
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
21+
github.com/davecgh/go-spew v1.1.1 // indirect
22+
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
23+
github.com/golang/protobuf v1.5.2 // indirect
24+
github.com/google/go-cmp v0.5.9 // indirect
25+
github.com/googleapis/enterprise-certificate-proxy v0.2.0 // indirect
26+
github.com/jmespath/go-jmespath v0.4.0 // indirect
27+
github.com/kr/pretty v0.1.0 // indirect
28+
github.com/pmezard/go-difflib v1.0.0 // indirect
29+
github.com/russross/blackfriday/v2 v2.1.0 // indirect
30+
github.com/stretchr/objx v0.5.0 // indirect
31+
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
32+
go.opencensus.io v0.23.0 // indirect
33+
golang.org/x/net v0.0.0-20221012135044-0b7e1fb9d458 // indirect
34+
golang.org/x/oauth2 v0.0.0-20221006150949-b44042a4b9c1 // indirect
35+
golang.org/x/text v0.3.7 // indirect
36+
google.golang.org/api v0.99.0 // indirect
37+
google.golang.org/appengine v1.6.7 // indirect
38+
google.golang.org/grpc v1.50.1 // indirect
39+
google.golang.org/protobuf v1.28.1 // indirect
40+
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
41+
gopkg.in/yaml.v3 v3.0.1 // indirect
1542
)

0 commit comments

Comments
 (0)