Skip to content

Commit

Permalink
Use go1.22, lint updates (#198)
Browse files Browse the repository at this point in the history
* Use go1.22, lint updates

Signed-off-by: Kimmo Lehto <[email protected]>

* Go mod tidy

Signed-off-by: Kimmo Lehto <[email protected]>

---------

Signed-off-by: Kimmo Lehto <[email protected]>
  • Loading branch information
kke authored May 6, 2024
1 parent 443adb9 commit db2e6d7
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 58 deletions.
36 changes: 17 additions & 19 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,45 @@
run:
timeout: 8m

skip-dirs-use-default: false
skip-files:
- ".*\\.gen\\.go"
- examples/*
- test/*
tests: false
allow-parallel-runners: true

linters:
enable-all: true
disable:
- nonamedreturns
- deadcode
- depguard
- dogsled
- execinquery
- exhaustivestruct
- exhaustruct
- exhaustive
- forbidigo
- gochecknoinits
- gochecknoglobals
- gochecknoinits
- gocognit # cyclop is used instead
- gocyclo # cyclop is used instead
- godox
- goheader
- golint
- gomnd
- ifshort
- interfacer
- ireturn
- lll
- maligned
- mnd
- nlreturn
- nonamedreturns
- nosnakecase
- paralleltest
- scopelint
- tparallel
- wsl
- tagliatelle
- structcheck
- nosnakecase
- deadcode
- varcheck
- ifshort
- goheader
- dogsled
- lll
- gomnd
- depguard
- tagalign
- tagliatelle
- tparallel
- varcheck
- wsl

linters-settings:
funlen:
Expand Down
16 changes: 8 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
module github.com/k0sproject/rig/v2

go 1.21
go 1.22.0

require (
github.com/Microsoft/go-winio v0.6.2
github.com/davidmz/go-pageant v1.0.2
github.com/masterzen/winrm v0.0.0-20231128182143-52a9e15d5730
github.com/masterzen/winrm v0.0.0-20231227165926-e811dad5ac77
github.com/stretchr/testify v1.9.0
golang.org/x/crypto v0.22.0
golang.org/x/term v0.19.0
golang.org/x/term v0.20.0
gopkg.in/yaml.v2 v2.4.0
)

require (
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 // indirect
github.com/ChrisTrenkamp/goxpath v0.0.0-20210404020558-97928f7e12b6 // indirect
github.com/bodgit/ntlmssp v0.0.0-20231128222409-0a45a2447e7c // indirect
github.com/bodgit/ntlmssp v0.0.0-20240405225621-bc7a66a52237 // indirect
github.com/bodgit/windows v1.0.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/gofrs/uuid v4.4.0+incompatible // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
Expand All @@ -31,8 +31,8 @@ require (
github.com/masterzen/simplexml v0.0.0-20190410153822-31eea3082786 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/tidwall/transform v0.0.0-20201103190739-32f242e2dbde // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
28 changes: 14 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ github.com/ChrisTrenkamp/goxpath v0.0.0-20210404020558-97928f7e12b6 h1:w0E0fgc1Y
github.com/ChrisTrenkamp/goxpath v0.0.0-20210404020558-97928f7e12b6/go.mod h1:nuWgzSkT5PnyOd+272uUmV0dnAnAn42Mk7PiQC5VzN4=
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
github.com/bodgit/ntlmssp v0.0.0-20231128222409-0a45a2447e7c h1:W7dgPjcG1Rx+wOtKeviTPYSrzf/Um/ew9wBXY0IjP2s=
github.com/bodgit/ntlmssp v0.0.0-20231128222409-0a45a2447e7c/go.mod h1:X0rVAs8xRc5mkV/xTR3yCWqCN64bVnLxjqI8DHAbN0k=
github.com/bodgit/ntlmssp v0.0.0-20240405225621-bc7a66a52237 h1:IRHxBGP4NtipmCHvxhEFpxuypBszYx+WRo6Wc6xxjXo=
github.com/bodgit/ntlmssp v0.0.0-20240405225621-bc7a66a52237/go.mod h1:ZcREh7an/iQI1JTsS+K9YAlig9Twd+OAGqB75LT+5+8=
github.com/bodgit/windows v1.0.1 h1:tF7K6KOluPYygXa3Z2594zxlkbKPAOvqr97etrGNIz4=
github.com/bodgit/windows v1.0.1/go.mod h1:a6JLwrB4KrTR5hBpp8FI9/9W9jJfeQ2h4XDXU74ZCdM=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davidmz/go-pageant v1.0.2 h1:bPblRCh5jGU+Uptpz6LgMZGD5hJoOt7otgT454WvHn0=
github.com/davidmz/go-pageant v1.0.2/go.mod h1:P2EDDnMqIwG5Rrp05dTRITj9z2zpGcD9efWSkTNKLIE=
github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY=
github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA=
github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
Expand Down Expand Up @@ -46,8 +46,8 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/masterzen/simplexml v0.0.0-20190410153822-31eea3082786 h1:2ZKn+w/BJeL43sCxI2jhPLRv73oVVOjEKZjKkflyqxg=
github.com/masterzen/simplexml v0.0.0-20190410153822-31eea3082786/go.mod h1:kCEbxUJlNDEBNbdQMkPSp6yaKcRXVI6f4ddk8Riv4bc=
github.com/masterzen/winrm v0.0.0-20231128182143-52a9e15d5730 h1:zLVOWGRxX/IsRpqHjl0hjVq6BORcs7ubih+G2dGhTEs=
github.com/masterzen/winrm v0.0.0-20231128182143-52a9e15d5730/go.mod h1:qfAjztAGRm7J7Ci10OA9vrx8WRDM0mlhdsFu7gBtMK8=
github.com/masterzen/winrm v0.0.0-20231227165926-e811dad5ac77 h1:psY7rHKhnfqjTEgkleIYpF1vVxVfYsUYFTO/cL5Z6xM=
github.com/masterzen/winrm v0.0.0-20231227165926-e811dad5ac77/go.mod h1:otHfftEJdo9JWGoq9GcJRaeNLp/uhqNq8JOk5lL+8Ks=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand Down Expand Up @@ -75,8 +75,8 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand All @@ -85,19 +85,19 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q=
golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk=
golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw=
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
Expand Down
2 changes: 1 addition & 1 deletion kv/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func (ra *reflectAssigner) setup() error {
}

typ := elem.Type()
for i := 0; i < elem.NumField(); i++ {
for i := range elem.NumField() {
field := elem.Field(i)
structField := typ.Field(i)
ra.fields = append(ra.fields, newFieldInfo(field, structField))
Expand Down
2 changes: 1 addition & 1 deletion rigtest/assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type Receiver interface {
NotReceived(matchFn CommandMatcher) error
}

func logExtraMsg(t TestingT, msgAndArgs ...any) {
func logExtraMsg(t TestingT, msgAndArgs ...any) { //nolint:varnamelen
if len(msgAndArgs) == 0 {
return
}
Expand Down
5 changes: 3 additions & 2 deletions rigtest/mockrunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ type MockWaiter struct {
fn CommandHandler
}

// Close the mock command.
func (m *MockWaiter) Close() error {
log.Trace(m.ctx, "closing waiter streams", log.KeyCommand, m.cmd)
if in, ok := m.in.(io.Closer); ok {
Expand Down Expand Up @@ -291,15 +292,15 @@ func (m *MockStarter) AddCommandOutput(matchFn CommandMatcher, output string) {
}})
}

// AddCommandOutput adds a matcher and a function to the starter that writes the given output to the stdout of the process.
// AddCommandSuccess adds a command matcher that should always succeed.
func (m *MockStarter) AddCommandSuccess(matchFn CommandMatcher) {
m.matchers = append(m.matchers, matcher{fn: matchFn, waiterFn: func(a *A) error {
log.Trace(a.Ctx, "returning nil from command", log.KeyCommand, a.Command)
return nil
}})
}

// AddCommandOutput adds a matcher and a function to the starter that writes the given output to the stdout of the process.
// AddCommandFailure adds a command matcher that should always fail with the given error.
func (m *MockStarter) AddCommandFailure(matchFn CommandMatcher, err error) {
m.matchers = append(m.matchers, matcher{fn: matchFn, waiterFn: func(a *A) error {
log.Trace(a.Ctx, "returning error from command", log.KeyCommand, a.Command, log.KeyError, err)
Expand Down
4 changes: 2 additions & 2 deletions sh/shellescape/expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func Expand(input string, opts ...ExpandOption) (string, error) { //nolint:cyclo
stack := builderStack{}
openParen := 0

for i := 0; i < len(input); i++ {
for i := range len(input) {
currCh := input[i]

if inEscape {
Expand Down Expand Up @@ -414,7 +414,7 @@ func expandCurly(input string) (string, error) {
}

idx := -1
for i := 0; i < len(input); i++ {
for i := range len(input) {
idx = i
if !isValidVarNameChar(input[i], i == 0) {
break
Expand Down
2 changes: 1 addition & 1 deletion sh/shellescape/split.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func Split(input string) ([]string, error) { //nolint:cyclop

var inDoubleQuotes, inSingleQuotes, isEscaped bool

for i := 0; i < len(input); i++ {
for i := range len(input) {
currentChar := input[i]

if isEscaped {
Expand Down
2 changes: 1 addition & 1 deletion sh/shellescape/unquote.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func Unquote(input string) (string, error) { //nolint:cyclop

var inDoubleQuotes, inSingleQuotes, isEscaped bool

for i := 0; i < len(input); i++ {
for i := range len(input) {
currentChar := input[i]

if isEscaped {
Expand Down
6 changes: 3 additions & 3 deletions sshconfig/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (p *printer) stringerslicejoin(key string, separator rune) (string, bool) {
return "", false
}
sb := &strings.Builder{}
for i := 0; i < field.Len(); i++ {
for i := range field.Len() {
if i > 0 {
sb.WriteRune(separator)
}
Expand Down Expand Up @@ -187,7 +187,7 @@ func (p *printer) channeltimeout(key string) (string, bool) {
}
if field, err := p.get(key, reflect.Slice); err == nil {
sb := &strings.Builder{}
for i := 0; i < field.Len(); i++ {
for i := range field.Len() {
if s, ok := p.stringify(field.Index(i)); ok {
if sb.Len() > 0 {
sb.WriteRune(' ')
Expand Down Expand Up @@ -223,7 +223,7 @@ func (p *printer) forward(key string) (string, bool) {
}
if field, err := p.get(key, reflect.Slice); err == nil {
sb := &strings.Builder{}
for i := 0; i < field.Len(); i++ {
for i := range field.Len() {
if s, ok := p.stringify(field.Index(i)); ok {
if sb.Len() > 0 {
sb.WriteRune(' ')
Expand Down
12 changes: 6 additions & 6 deletions sshconfig/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func (s *Setter) discoverFields() {

s.elemFields = make(map[string]reflect.Value)

for i := 0; i < s.elem.NumField(); i++ {
for i := range s.elem.NumField() {
field := s.elem.Field(i)
structField := s.elem.Type().Field(i)
s.elemFields[structField.Name] = field
Expand Down Expand Up @@ -1286,7 +1286,7 @@ func (s *Setter) ExpandSlice(key string) ([]string, error) { //nolint:cyclop
return nil, nil
}
var values []string
for i := 0; i < field.Len(); i++ {
for i := range field.Len() {
f := field.Index(i)
switch {
case f.Kind() == reflect.String:
Expand Down Expand Up @@ -1318,7 +1318,7 @@ func (s *Setter) isInIgnoreUnknown(key string) bool {
if err != nil {
return false
}
for i := 0; i < field.Len(); i++ {
for i := range field.Len() {
match, err := patternMatch(key, field.Index(i).String())
if err != nil {
return false
Expand Down Expand Up @@ -1349,7 +1349,7 @@ func (s *Setter) matchesHost(conditions ...string) (bool, error) {
// matchesMatch checks if the Match directive conditions are met.
func (s *Setter) matchesMatch(conditions ...string) (bool, error) { //nolint:funlen,cyclop // TODO extract functions
log.Trace(context.Background(), "matching Match directive", "conditions", conditions)
for i := 0; i < len(conditions); i++ {
for i := range len(conditions) {
condition := conditions[i]
log.Trace(context.Background(), "matching Match directive", "condition", condition)
var negate bool
Expand Down Expand Up @@ -1514,7 +1514,7 @@ func (s *Setter) hasProxyJump() bool {
if proxyJump.Kind() == reflect.String {
return proxyJump.String() != "" && proxyJump.String() != none
} else if proxyJump.Kind() == reflect.Slice {
for i := 0; i < proxyJump.Len(); i++ {
for i := range proxyJump.Len() {
if proxyJump.Index(i).String() != "" && proxyJump.Index(i).String() != none {
return true
}
Expand Down Expand Up @@ -1637,7 +1637,7 @@ func (s *Setter) canonicalizePermittedCNAMEs() map[string]string {
if permittedCnames.Len() == 0 || (permittedCnames.Len() == 1 && permittedCnames.Index(0).String() == none) {
return res
}
for i := 0; i < permittedCnames.Len(); i++ {
for i := range permittedCnames.Len() {
parts := strings.Split(permittedCnames.Index(i).String(), ":")
if len(parts) != 2 {
continue
Expand Down

0 comments on commit db2e6d7

Please sign in to comment.