Skip to content

Commit ca38c6e

Browse files
authored
Bump Go to 1.24.4, fixed code smells (#75)
1 parent d6ebcfd commit ca38c6e

File tree

12 files changed

+150
-56
lines changed

12 files changed

+150
-56
lines changed

.devcontainer/Dockerfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
ARG GO_VERSION=1.24.3
2-
ARG ALPINE_VERSION=3.21
1+
ARG GO_VERSION=1.24.4
2+
ARG ALPINE_VERSION=3.22
33

44
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION}
55

66
# Install packages
7-
RUN apk add -q --update --progress --no-cache git make openssh-client sudo
7+
RUN apk add -q --update --progress --no-cache \
8+
git \
9+
make \
10+
openssh-client \
11+
sudo

.github/workflows/master.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ jobs:
1717
with:
1818
fetch-depth: 0
1919

20-
- name: Set up Go 1.24.3
20+
- name: Set up Go 1.24.4
2121
uses: actions/setup-go@v5
2222
with:
23-
go-version: '1.24.3'
23+
go-version: '1.24.4'
2424

2525
- name: Start MongoDB
2626
uses: supercharge/[email protected]

.github/workflows/re-release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ jobs:
2020
fetch-depth: 0
2121
ref: ${{ github.event.inputs.tag }}
2222

23-
- name: Set up Go 1.24.3
23+
- name: Set up Go 1.24.4
2424
uses: actions/setup-go@v5
2525
with:
26-
go-version: '1.24.3'
26+
go-version: '1.24.4'
2727

2828
- name: Start MongoDB
2929
uses: supercharge/[email protected]

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ jobs:
1515
with:
1616
fetch-depth: 0
1717

18-
- name: Set up Go 1.24.3
18+
- name: Set up Go 1.24.4
1919
uses: actions/setup-go@v5
2020
with:
21-
go-version: '1.24.3'
21+
go-version: '1.24.4'
2222

2323
- name: Start MongoDB
2424
uses: supercharge/[email protected]

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.24.3-alpine AS builder
1+
FROM golang:1.24.4-alpine AS builder
22

33
WORKDIR /app
44
COPY . .

go.mod

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
module github.com/switcherapi/switcher-gitops
22

3-
go 1.24.3
3+
go 1.24.4
44

55
require (
66
github.com/go-git/go-billy/v5 v5.6.2
7-
github.com/go-git/go-git/v5 v5.16.0
7+
github.com/go-git/go-git/v5 v5.16.2
88
github.com/golang-jwt/jwt/v5 v5.2.2
99
github.com/gorilla/mux v1.8.1
1010
github.com/joho/godotenv v1.5.1
1111
github.com/stretchr/testify v1.10.0
12-
go.mongodb.org/mongo-driver v1.17.3
12+
go.mongodb.org/mongo-driver v1.17.4
1313
)
1414

1515
require (
1616
dario.cat/mergo v1.0.2 // indirect
1717
github.com/Microsoft/go-winio v0.6.2 // indirect
18-
github.com/ProtonMail/go-crypto v1.2.0 // indirect
18+
github.com/ProtonMail/go-crypto v1.3.0 // indirect
1919
github.com/cloudflare/circl v1.6.1 // indirect
2020
github.com/cyphar/filepath-securejoin v0.4.1 // indirect
2121
github.com/davecgh/go-spew v1.1.1 // indirect
@@ -29,18 +29,18 @@ require (
2929
github.com/montanaflynn/stats v0.7.1 // indirect
3030
github.com/pjbgf/sha1cd v0.3.2 // indirect
3131
github.com/pmezard/go-difflib v1.0.0 // indirect
32-
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
32+
github.com/sergi/go-diff v1.4.0 // indirect
3333
github.com/skeema/knownhosts v1.3.1 // indirect
3434
github.com/xanzy/ssh-agent v0.3.3 // indirect
3535
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
3636
github.com/xdg-go/scram v1.1.2 // indirect
3737
github.com/xdg-go/stringprep v1.0.4 // indirect
3838
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
39-
golang.org/x/crypto v0.38.0 // indirect
40-
golang.org/x/net v0.40.0 // indirect
41-
golang.org/x/sync v0.14.0 // indirect
39+
golang.org/x/crypto v0.39.0 // indirect
40+
golang.org/x/net v0.41.0 // indirect
41+
golang.org/x/sync v0.15.0 // indirect
4242
golang.org/x/sys v0.33.0 // indirect
43-
golang.org/x/text v0.25.0 // indirect
43+
golang.org/x/text v0.26.0 // indirect
4444
gopkg.in/warnings.v0 v0.1.2 // indirect
4545
gopkg.in/yaml.v3 v3.0.1 // indirect
4646
)

go.sum

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ dario.cat/mergo v1.0.2/go.mod h1:E/hbnu0NxMFBjpMIE34DRGLWqDy0g5FuKDhCb31ngxA=
33
github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY=
44
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
55
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
6-
github.com/ProtonMail/go-crypto v1.2.0 h1:+PhXXn4SPGd+qk76TlEePBfOfivE0zkWFenhGhFLzWs=
7-
github.com/ProtonMail/go-crypto v1.2.0/go.mod h1:9whxjD8Rbs29b4XWbB8irEcE8KHMqaR2e7GWU1R+/PE=
6+
github.com/ProtonMail/go-crypto v1.3.0 h1:ILq8+Sf5If5DCpHQp4PbZdS1J7HDFRXz/+xKBiRGFrw=
7+
github.com/ProtonMail/go-crypto v1.3.0/go.mod h1:9whxjD8Rbs29b4XWbB8irEcE8KHMqaR2e7GWU1R+/PE=
88
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8=
99
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4=
1010
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
@@ -28,8 +28,8 @@ github.com/go-git/go-billy/v5 v5.6.2 h1:6Q86EsPXMa7c3YZ3aLAQsMA0VlWmy43r6FHqa/UN
2828
github.com/go-git/go-billy/v5 v5.6.2/go.mod h1:rcFC2rAsp/erv7CMz9GczHcuD0D32fWzH+MJAU+jaUU=
2929
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4=
3030
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII=
31-
github.com/go-git/go-git/v5 v5.16.0 h1:k3kuOEpkc0DeY7xlL6NaaNg39xdgQbtH5mwCafHO9AQ=
32-
github.com/go-git/go-git/v5 v5.16.0/go.mod h1:4Ge4alE/5gPs30F2H1esi2gPd69R0C39lolkucHBOp8=
31+
github.com/go-git/go-git/v5 v5.16.2 h1:fT6ZIOjE5iEnkzKyxTHK1W4HGAsPhqEqiSAssSO77hM=
32+
github.com/go-git/go-git/v5 v5.16.2/go.mod h1:4Ge4alE/5gPs30F2H1esi2gPd69R0C39lolkucHBOp8=
3333
github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8=
3434
github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
3535
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 h1:f+oWsMOmNPc8JmEHVZIycC7hBoQxHH9pNKQORJNozsQ=
@@ -67,8 +67,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
6767
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
6868
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
6969
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
70-
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
71-
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
70+
github.com/sergi/go-diff v1.4.0 h1:n/SP9D5ad1fORl+llWyN+D6qoUETXNZARKjyY2/KVCw=
71+
github.com/sergi/go-diff v1.4.0/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
7272
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
7373
github.com/skeema/knownhosts v1.3.1 h1:X2osQ+RAjK76shCbvhHHHVl3ZlgDm8apHEHFqRjnBY8=
7474
github.com/skeema/knownhosts v1.3.1/go.mod h1:r7KTdC8l4uxWRyK2TpQZ/1o5HaSzh06ePQNxPwTcfiY=
@@ -88,26 +88,26 @@ github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gi
8888
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM=
8989
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI=
9090
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
91-
go.mongodb.org/mongo-driver v1.17.3 h1:TQyXhnsWfWtgAhMtOgtYHMTkZIfBTpMTsMnd9ZBeHxQ=
92-
go.mongodb.org/mongo-driver v1.17.3/go.mod h1:Hy04i7O2kC4RS06ZrhPRqj/u4DTYkFDAAccj+rVKqgQ=
91+
go.mongodb.org/mongo-driver v1.17.4 h1:jUorfmVzljjr0FLzYQsGP8cgN/qzzxlY9Vh0C9KFXVw=
92+
go.mongodb.org/mongo-driver v1.17.4/go.mod h1:Hy04i7O2kC4RS06ZrhPRqj/u4DTYkFDAAccj+rVKqgQ=
9393
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
9494
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
9595
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
96-
golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8=
97-
golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw=
96+
golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM=
97+
golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U=
9898
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8=
9999
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY=
100100
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
101101
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
102102
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
103103
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
104104
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
105-
golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY=
106-
golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds=
105+
golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw=
106+
golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA=
107107
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
108108
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
109-
golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ=
110-
golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
109+
golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8=
110+
golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
111111
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
112112
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
113113
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -128,8 +128,8 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
128128
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
129129
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
130130
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
131-
golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4=
132-
golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA=
131+
golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M=
132+
golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA=
133133
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
134134
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
135135
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=

sonar-project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ sonar.sources=src
88
sonar.exclusions=**/*_test.go
99
sonar.tests=src
1010
sonar.test.inclusions=**/*_test.go
11-
sonar.coverage.exclusions=src/server/**/*,src/db/**/*,src/cmd/**/*,src/repository/**/*
11+
sonar.coverage.exclusions=src/server/**/*,src/db/**/*,src/cmd/**/*
1212

1313
sonar.language=go
1414
sonar.go.coverage.reportPaths=coverage.out

src/core/comparator.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,10 @@ func (c *ComparatorService) RemoveDeleted(diffResult model.DiffResult) model.Dif
7070
func checkGroupDiff(left model.Snapshot, right model.Snapshot, diffType DiffType, diffResult model.DiffResult) model.DiffResult {
7171
for _, leftGroup := range left.Domain.Group {
7272
if !slices.Contains(model.GroupNames(right.Domain.Group), leftGroup.Name) {
73-
if diffType == NEW {
73+
switch diffType {
74+
case NEW:
7475
appendDiffResults(string(diffType), string(GROUP), []string{}, leftGroup, &diffResult)
75-
} else if diffType == DELETED {
76+
case DELETED:
7677
appendDiffResults(string(diffType), string(GROUP), []string{leftGroup.Name}, nil, &diffResult)
7778
}
7879
} else {
@@ -103,9 +104,10 @@ func checkConfigDiff(leftGroup model.Group, rightGroup model.Group, diffResult *
103104

104105
for _, leftConfig := range leftGroup.Config {
105106
if !slices.Contains(model.ConfigKeys(rightGroup.Config), leftConfig.Key) {
106-
if diffType == NEW {
107+
switch diffType {
108+
case NEW:
107109
appendDiffResults(string(diffType), string(CONFIG), []string{leftGroup.Name}, leftConfig, diffResult)
108-
} else if diffType == DELETED {
110+
case DELETED:
109111
appendDiffResults(string(diffType), string(CONFIG), []string{leftGroup.Name, leftConfig.Key}, nil, diffResult)
110112
}
111113
} else {
@@ -139,10 +141,11 @@ func checkStrategyDiff(leftConfig model.Config, rightConfig model.Config, leftGr
139141

140142
for _, leftStrategy := range leftConfig.Strategies {
141143
if !slices.Contains(model.StrategyNames(rightConfig.Strategies), leftStrategy.Strategy) {
142-
if diffType == NEW {
144+
switch diffType {
145+
case NEW:
143146
appendDiffResults(string(diffType), string(STRATEGY),
144147
[]string{leftGroup.Name, leftConfig.Key}, leftStrategy, diffResult)
145-
} else if diffType == DELETED {
148+
case DELETED:
146149
appendDiffResults(string(diffType), string(STRATEGY),
147150
[]string{leftGroup.Name, leftConfig.Key, leftStrategy.Strategy}, nil, diffResult)
148151
}

src/model/snapshot.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,27 +69,27 @@ func StrategyNames(strategies []Strategy) []string {
6969
}
7070

7171
func GetStrategyByName(strategies []Strategy, name string) Strategy {
72-
for _, s := range strategies {
73-
if s.Strategy == name {
74-
return s
72+
for i := range strategies {
73+
if strategies[i].Strategy == name {
74+
return strategies[i]
7575
}
7676
}
7777
return Strategy{}
7878
}
7979

8080
func GetConfigByKey(configs []Config, key string) Config {
81-
for _, c := range configs {
82-
if c.Key == key {
83-
return c
81+
for i := range configs {
82+
if configs[i].Key == key {
83+
return configs[i]
8484
}
8585
}
8686
return Config{}
8787
}
8888

8989
func GetGroupByName(groups []Group, name string) Group {
90-
for _, g := range groups {
91-
if g.Name == name {
92-
return g
90+
for i := range groups {
91+
if groups[i].Name == name {
92+
return groups[i]
9393
}
9494
}
9595
return Group{}

0 commit comments

Comments
 (0)