Skip to content

Commit cbbbcae

Browse files
authored
fix(deps): remove go-vela/types dep, update linter settings (#58)
* fix(deps): remove go-vela/types dep, update linter settings * fix: add version for alpine image
1 parent af88adf commit cbbbcae

File tree

7 files changed

+109
-101
lines changed

7 files changed

+109
-101
lines changed

.golangci.yml

+66-51
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,22 @@
88
# outputs it results from the linters it executes.
99
output:
1010
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
11-
format: colored-line-number
11+
formats:
12+
- format: colored-line-number
1213

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

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

19-
# make issues output unique by line, default is true
20-
uniq-by-line: true
21-
2220
# This section provides the configuration for each linter
2321
# we've instructed golangci to execute.
2422
linters-settings:
23+
# https://github.com/karamaru-alpha/copyloopvar
24+
copyloopvar:
25+
check-alias: true
26+
2527
# https://github.com/mibk/dupl
2628
dupl:
2729
threshold: 100
@@ -32,6 +34,18 @@ linters-settings:
3234
lines: 160
3335
statements: 70
3436

37+
# https://github.com/daixiang0/gci
38+
# ensure import order is consistent
39+
# gci write --custom-order -s standard -s default -s blank -s dot -s "prefix(github.com/go-vela)" .
40+
gci:
41+
custom-order: true
42+
sections:
43+
- standard
44+
- default
45+
- blank
46+
- dot
47+
- prefix(github.com/go-vela)
48+
3549
# https://github.com/denis-tingaikin/go-header
3650
goheader:
3751
template: |-
@@ -43,9 +57,9 @@ linters-settings:
4357

4458
# https://github.com/golangci/golangci-lint/blob/master/pkg/golinters/nolintlint
4559
nolintlint:
46-
allow-unused: false # allow nolint directives that don't address a linting issue
47-
require-explanation: true # require an explanation for nolint directives
48-
require-specific: true # require nolint directives to be specific about which linter is being skipped
60+
allow-unused: false # allow nolint directives that don't address a linting issue
61+
require-explanation: true # require an explanation for nolint directives
62+
require-specific: true # require nolint directives to be specific about which linter is being skipped
4963

5064
# This section provides the configuration for which linters
5165
# golangci will execute. Several of them were disabled by
@@ -56,46 +70,44 @@ linters:
5670

5771
# enable a specific set of linters to run
5872
enable:
59-
- bidichk # checks for dangerous unicode character sequences
60-
- bodyclose # checks whether HTTP response body is closed successfully
61-
- contextcheck # check the function whether use a non-inherited context
62-
- deadcode # finds unused code
63-
- dupl # code clone detection
64-
- errcheck # checks for unchecked errors
65-
- errorlint # find misuses of errors
66-
- exportloopref # check for exported loop vars
67-
- funlen # detects long functions
68-
- goconst # finds repeated strings that could be replaced by a constant
69-
- gocyclo # computes and checks the cyclomatic complexity of functions
70-
- godot # checks if comments end in a period
71-
- gofmt # checks whether code was gofmt-ed
72-
- goheader # checks is file header matches to pattern
73-
- goimports # fixes imports and formats code in same style as gofmt
74-
- gomoddirectives # manage the use of 'replace', 'retract', and 'excludes' directives in go.mod
75-
- goprintffuncname # checks that printf-like functions are named with f at the end
76-
- gosec # inspects code for security problems
77-
- gosimple # linter that specializes in simplifying a code
78-
- govet # reports suspicious constructs, ex. Printf calls whose arguments don't align with the format string
79-
- ineffassign # detects when assignments to existing variables aren't used
80-
- makezero # finds slice declarations with non-zero initial length
81-
- misspell # finds commonly misspelled English words in comments
82-
- nakedret # finds naked returns in functions greater than a specified function length
83-
- nilerr # finds the code that returns nil even if it checks that the error is not nil
84-
- noctx # noctx finds sending http request without context.Context
85-
- nolintlint # reports ill-formed or insufficient nolint directives
86-
- revive # linter for go
87-
- staticcheck # applies static analysis checks, go vet on steroids
88-
- structcheck # finds unused struct fields
89-
- stylecheck # replacement for golint
90-
- tenv # analyzer that detects using os.Setenv instead of t.Setenv since Go1.17
91-
- typecheck # parses and type-checks go code, like the front-end of a go compiler
92-
- unconvert # remove unnecessary type conversions
93-
- unparam # reports unused function parameters
94-
- unused # checks for unused constants, variables, functions and types
95-
- varcheck # finds unused global variables and constants
96-
- whitespace # detects leading and trailing whitespace
97-
- wsl # forces code to use empty lines
98-
73+
- bidichk # checks for dangerous unicode character sequences
74+
- bodyclose # checks whether HTTP response body is closed successfully
75+
- contextcheck # check the function whether use a non-inherited context
76+
- copyloopvar # detects places where loop variables are copied
77+
- dupl # code clone detection
78+
- errcheck # checks for unchecked errors
79+
- errorlint # find misuses of errors
80+
- funlen # detects long functions
81+
- gci # use goimports
82+
- goconst # finds repeated strings that could be replaced by a constant
83+
- gocyclo # computes and checks the cyclomatic complexity of functions
84+
- godot # checks if comments end in a period
85+
- gofmt # checks whether code was gofmt-ed
86+
- goheader # checks is file header matches to pattern
87+
- goimports # fixes imports and formats code in same style as gofmt
88+
- gomoddirectives # manage the use of 'replace', 'retract', and 'excludes' directives in go.mod
89+
- goprintffuncname # checks that printf-like functions are named with f at the end
90+
- gosec # inspects code for security problems
91+
- gosimple # linter that specializes in simplifying a code
92+
- govet # reports suspicious constructs, ex. Printf calls whose arguments don't align with the format string
93+
- ineffassign # detects when assignments to existing variables aren't used
94+
- makezero # finds slice declarations with non-zero initial length
95+
- misspell # finds commonly misspelled English words in comments
96+
- nakedret # finds naked returns in functions greater than a specified function length
97+
- nilerr # finds the code that returns nil even if it checks that the error is not nil
98+
- noctx # noctx finds sending http request without context.Context
99+
- nolintlint # reports ill-formed or insufficient nolint directives
100+
- revive # linter for go
101+
- staticcheck # applies static analysis checks, go vet on steroids
102+
- stylecheck # replacement for golint
103+
- typecheck # parses and type-checks go code, like the front-end of a go compiler
104+
- unconvert # remove unnecessary type conversions
105+
- unparam # reports unused function parameters
106+
- unused # checks for unused constants, variables, functions and types
107+
- usetesting # analyzer that detects using os.Setenv instead of t.Setenv since Go1.17
108+
- whitespace # detects leading and trailing whitespace
109+
- wsl # forces code to use empty lines
110+
99111
# static list of linters we know golangci can run but we've
100112
# chosen to leave disabled for now
101113
# - asciicheck - non-critical
@@ -106,12 +118,12 @@ linters:
106118
# - errname - unused
107119
# - exhaustive - unused
108120
# - exhaustivestruct - style preference
121+
# - exportloopref - check for exported loop vars
109122
# - forbidigo - unused
110123
# - forcetypeassert - unused
111-
# - gci - use goimports
112124
# - gochecknoinits - unused
113125
# - gochecknoglobals - global variables allowed
114-
# - gocognit - unused complexity metric
126+
# - gocognit - unused complexity metric
115127
# - gocritic - style preference
116128
# - godox - to be used in the future
117129
# - goerr113 - to be used in the future
@@ -122,7 +134,7 @@ linters:
122134
# - ifshort - use both styles
123135
# - ireturn - allow interfaces to be returned
124136
# - importas - want flexibility with naming
125-
# - lll - not too concerned about line length
137+
# - lll - not too concerned about line length
126138
# - interfacer - archived
127139
# - nestif - non-critical
128140
# - nilnil - style preference
@@ -131,7 +143,7 @@ linters:
131143
# - paralleltest - false-positives
132144
# - prealloc - don't use
133145
# - predeclared - unused
134-
# - promlinter - style preference
146+
# - promlinter - style preference
135147
# - rowserrcheck - unused
136148
# - scopelint - deprecated - replaced with exportloopref
137149
# - sqlclosecheck - unused
@@ -145,6 +157,8 @@ linters:
145157
# This section provides the configuration for how golangci
146158
# will report the issues it finds.
147159
issues:
160+
# make issues output unique by line, default is true
161+
uniq-by-line: true
148162
# Excluding configuration per-path, per-linter, per-text and per-source
149163
exclude-rules:
150164
# prevent linters from running on *_test.go files
@@ -154,3 +168,4 @@ issues:
154168
- funlen
155169
- goconst
156170
- gocyclo
171+

Dockerfile

+18-18
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,36 @@
44
## docker build --no-cache -t vela-ansible:local . ##
55
#########################################################
66

7-
FROM alpine:latest@sha256:0a4eaa0eecf5f8c050e5bba433f58c052be7587ee8af3e8b3910ef9ab5fbe9f5
7+
FROM alpine:3.20.2@sha256:0a4eaa0eecf5f8c050e5bba433f58c052be7587ee8af3e8b3910ef9ab5fbe9f5
88

99
ENV ANSIBLE_VERSION=11.2.0
1010

1111
RUN apk --update --no-cache add \
12-
git \
13-
openssl \
14-
openssh-client \
15-
python3\
16-
sshpass \
17-
py3-pip
12+
git \
13+
openssl \
14+
openssh-client \
15+
python3\
16+
sshpass \
17+
py3-pip
1818

1919
RUN apk --update add --virtual \
20-
.build-deps \
21-
python3-dev \
22-
libffi-dev \
23-
openssl-dev \
24-
build-base
20+
.build-deps \
21+
python3-dev \
22+
libffi-dev \
23+
openssl-dev \
24+
build-base
2525

2626
RUN pip3 install --upgrade \
27-
pip \
28-
cffi --break-system-packages
27+
pip \
28+
cffi --break-system-packages
2929

3030
RUN pip3 install \
31-
wheel \
32-
ansible==${ANSIBLE_VERSION} \
33-
ansible-lint --break-system-packages
31+
wheel \
32+
ansible==${ANSIBLE_VERSION} \
33+
ansible-lint --break-system-packages
3434

3535
RUN apk del \
36-
.build-deps
36+
.build-deps
3737

3838
RUN rm -rf /var/cache/apk/*
3939

cmd/vela-ansible/main.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ import (
99
"strings"
1010
"time"
1111

12+
"github.com/sirupsen/logrus"
13+
"github.com/urfave/cli/v2"
14+
1215
"github.com/go-vela/vela-ansible/action/lint"
1316
"github.com/go-vela/vela-ansible/action/playbook"
1417
"github.com/go-vela/vela-ansible/version"
15-
"github.com/sirupsen/logrus"
16-
"github.com/urfave/cli/v2"
1718
)
1819

1920
func main() {

cmd/vela-ansible/plugin.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ import (
88
"errors"
99
"strings"
1010

11+
"github.com/sirupsen/logrus"
12+
1113
"github.com/go-vela/vela-ansible/action/lint"
1214
"github.com/go-vela/vela-ansible/action/playbook"
13-
"github.com/sirupsen/logrus"
1415
)
1516

1617
// action constants.

go.mod

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
module github.com/go-vela/vela-ansible
22

3-
go 1.23.0
3+
go 1.23.6
44

55
require (
6-
github.com/Masterminds/semver/v3 v3.2.1
7-
github.com/go-vela/types v0.24.0
6+
github.com/Masterminds/semver/v3 v3.3.1
7+
github.com/go-vela/server v0.26.2
88
github.com/sirupsen/logrus v1.9.3
9-
github.com/urfave/cli/v2 v2.27.4
9+
github.com/urfave/cli/v2 v2.27.5
1010
)
1111

1212
require (
13-
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
13+
github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect
1414
github.com/russross/blackfriday/v2 v2.1.0 // indirect
1515
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
16-
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
16+
golang.org/x/sys v0.30.0 // indirect
1717
)

go.sum

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0=
2-
github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
3-
github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4=
4-
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
1+
github.com/Masterminds/semver/v3 v3.3.1 h1:QtNSWtVZ3nBfk8mAOu/B6v7FMJ+NHTIgUPi7rj+4nv4=
2+
github.com/Masterminds/semver/v3 v3.3.1/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
3+
github.com/cpuguy83/go-md2man/v2 v2.0.5 h1:ZtcqGrnekaHpVLArFSe4HK5DoKx1T0rq2DwVB0alcyc=
4+
github.com/cpuguy83/go-md2man/v2 v2.0.5/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
55
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
66
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
77
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
8-
github.com/go-vela/types v0.24.0 h1:KkkiXxw3uHckh/foyadmLY1YnLw6vhZbz9XwqONCj6o=
9-
github.com/go-vela/types v0.24.0/go.mod h1:YWj6BIapl9Kbj4yHq/fp8jltXdGiwD/gTy1ez32Rzag=
8+
github.com/go-vela/server v0.26.2 h1:UZymITBP+GiJ5KpQ8xRx+hS/i/aFZpiPZsSwpSvDxOU=
9+
github.com/go-vela/server v0.26.2/go.mod h1:Mc/Nu5XtSTeqdvd7ZwXtWcb4eU9E3JD2vAGk6OUTUjU=
1010
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
1111
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
1212
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
@@ -16,12 +16,13 @@ github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVs
1616
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
1717
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
1818
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
19-
github.com/urfave/cli/v2 v2.27.4 h1:o1owoI+02Eb+K107p27wEX9Bb8eqIoZCfLXloLUSWJ8=
20-
github.com/urfave/cli/v2 v2.27.4/go.mod h1:m4QzxcD2qpra4z7WhzEGn74WZLViBnMpb1ToCAKdGRQ=
19+
github.com/urfave/cli/v2 v2.27.5 h1:WoHEJLdsXr6dDWoJgMq/CboDmyY/8HMMH1fTECbih+w=
20+
github.com/urfave/cli/v2 v2.27.5/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ=
2121
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4=
2222
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
23-
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
2423
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
24+
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
25+
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
2526
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
2627
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
2728
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

version/version.go

+4-14
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
package version
44

55
import (
6-
"fmt"
76
"runtime"
87

9-
"github.com/go-vela/types/version"
10-
118
"github.com/Masterminds/semver/v3"
12-
139
"github.com/sirupsen/logrus"
10+
11+
"github.com/go-vela/server/version"
1412
)
1513

1614
var (
@@ -27,22 +25,14 @@ var (
2725
// OS represents the operating system information for the package.
2826
OS = runtime.GOOS
2927
// Tag represents the git tag information for the package.
30-
Tag string
28+
Tag = "v0.0.0"
3129
)
3230

3331
// New creates a new version object for Vela that is used throughout the application.
3432
func New() *version.Version {
35-
// check if a semantic tag was provided
36-
if len(Tag) == 0 {
37-
logrus.Warningf("no semantic tag provided - defaulting to v0.0.0")
38-
39-
// set a fallback default for the tag
40-
Tag = "v0.0.0"
41-
}
42-
4333
v, err := semver.NewVersion(Tag)
4434
if err != nil {
45-
fmt.Println(fmt.Errorf("unable to parse semantic version for %s: %w", Tag, err))
35+
logrus.Warningf("unable to parse semantic version for %s: %v", Tag, err)
4636
}
4737

4838
return &version.Version{

0 commit comments

Comments
 (0)