Skip to content

Commit fe2f224

Browse files
jkralikcoderabbitai[bot]Copilot
authored
chore: bump Go/Alpine base images, improve tests, and centralize MongoDB error handling (#1428)
* chore/helm: update mongodb to 16.5.45 * chore/web: npx update-browserslist-db@latest * tests/update-golang: allow redirect to download golang 1.23.9 * chore: upgrade golang to 1.25 and alpine to 3.23 * fix linter issues, upgrade mongo-driver * fix golangci-lint issues * fix issue * fix test compilation * fix sonar issues * allow images from public.ecr.aws * Update bundle/Dockerfile Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update bundle/Dockerfile Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix golangci-lint --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 334f508 commit fe2f224

41 files changed

Lines changed: 246 additions & 176 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/builds.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ jobs:
1212
matrix:
1313
include:
1414
# check support for oldest supported golang version
15-
- name: go1.23
16-
go-version: "~1.23"
15+
- name: go1.25
16+
go-version: "~1.25"
1717
runs-on: ubuntu-24.04
1818
steps:
1919
- name: Checkout
@@ -22,7 +22,7 @@ jobs:
2222
- name: Set up Go
2323
uses: actions/setup-go@v5
2424
with:
25-
go-version: ${{ matrix.go-version || '^1.23' }}
25+
go-version: ${{ matrix.go-version || '^1.25' }}
2626
check-latest: true
2727

2828
- run: |

.github/workflows/golangci-lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ jobs:
2424
- uses: actions/checkout@v4
2525
- uses: actions/setup-go@v5
2626
with:
27-
go-version: "1.23" # The Go version to download (if necessary) and use.
27+
go-version: "1.25" # The Go version to download (if necessary) and use.
2828
check-latest: false
2929
cache: false
3030

3131
- run: go version
3232
- name: golangci-lint
3333
uses: golangci/golangci-lint-action@v8
3434
with:
35-
version: v2.1.6 # switch to latest if development is unfreezed
35+
version: v2.8.0 # switch to latest if development is unfreezed
3636
args: --timeout=5m

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
version: "2"
22
run:
3-
go: "1.23"
3+
go: "1.25"
44
# issues:
55
# fix: true
66
linters:

Dockerfile.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
FROM ubuntu:22.04 AS hub-test
22
RUN apt-get update \
33
&& DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \
4-
build-essential ca-certificates curl git make patch sudo \
4+
build-essential ca-certificates curl git lsof make patch sudo \
55
&& apt-get clean \
66
&& curl --proto "=https" -sSL https://get.docker.com/ | sh
77
WORKDIR /
88
# apt: ca-certificates git make sudo
99
RUN git clone https://github.com/udhos/update-golang.git \
1010
&& cd update-golang \
11-
&& sudo RELEASE=1.23.9 ./update-golang.sh \
11+
&& sudo RELEASE=1.25.6 FORCE_IPV4="-L" ./update-golang.sh \
1212
&& ln -s /usr/local/go/bin/go /usr/bin/go
1313
WORKDIR $GOPATH/src/github.com/plgd-dev/hub
1414
COPY go.mod go.sum ./

bundle/Dockerfile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# syntax=docker/dockerfile:1
2-
FROM golang:1.23.9-alpine AS build
2+
FROM golang:1.25.6-alpine AS build
33
RUN apk add --no-cache build-base curl git
44
WORKDIR $GOPATH/src/github.com/plgd-dev/hub
55
COPY go.mod go.sum ./
@@ -202,7 +202,13 @@ RUN go build \
202202
#device-provisioning-service
203203
ARG service=device-provisioning-service
204204
WORKDIR $root_directory/$service
205-
RUN go build -ldflags "-linkmode external -extldflags -static -X github.com/plgd-dev/hub/v2/pkg/build.CommitDate=$COMMIT_DATE -X github.com/plgd-dev/hub/v2/pkg/build.CommitHash=$SHORT_COMMIT -X github.com/plgd-dev/hub/v2/pkg/build.BuildDate=$DATE -X github.com/plgd-dev/hub/v2/pkg/build.Version=$VERSION -X github.com/plgd-dev/hub/v2/pkg/build.ReleaseURL=$RELEASE_URL" \
205+
RUN go build \
206+
-ldflags "-linkmode external -extldflags -static \
207+
-X github.com/plgd-dev/hub/v2/pkg/build.CommitDate=$COMMIT_DATE \
208+
-X github.com/plgd-dev/hub/v2/pkg/build.CommitHash=$SHORT_COMMIT \
209+
-X github.com/plgd-dev/hub/v2/pkg/build.BuildDate=$DATE \
210+
-X github.com/plgd-dev/hub/v2/pkg/build.Version=$VERSION \
211+
-X github.com/plgd-dev/hub/v2/pkg/build.ReleaseURL=$RELEASE_URL" \
206212
-o "/go/bin/$service" \
207213
./cmd/service
208214

@@ -216,8 +222,8 @@ RUN apkArch="$(apk --print-arch)"; \
216222
x86_64) ARCH='amd64' ;; \
217223
*) echo >&2 "error: unsupported architecture: $apkArch"; exit 1 ;; \
218224
esac; \
219-
curl -L https://github.com/nats-io/nats-server/releases/download/v2.3.1/nats-server-v2.3.1-linux-${ARCH}.zip -o ./nats-server.zip ; \
220-
curl -L https://github.com/nats-io/natscli/releases/download/0.0.24/nats-0.0.24-linux-${ARCH}.zip -o ./nats.zip \
225+
curl -L "https://github.com/nats-io/nats-server/releases/download/v2.3.1/nats-server-v2.3.1-linux-${ARCH}.zip" -o ./nats-server.zip && \
226+
curl -L "https://github.com/nats-io/natscli/releases/download/0.0.24/nats-0.0.24-linux-${ARCH}.zip" -o ./nats.zip \
221227
&& mkdir -p ./nats-server \
222228
&& unzip ./nats-server.zip -d ./nats-server \
223229
&& cp ./nats-server/*/nats-server /go/bin/nats-server \

certificate-authority/service/grpc/signCertificate_test.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,24 @@ func testSigningByFunction(t *testing.T, signFn ClientSignFunc, csr ...[]byte) {
3434
type args struct {
3535
req *pb.SignCertificateRequest
3636
}
37-
tests := []struct {
37+
tests := make([]struct {
38+
name string
39+
args args
40+
want *pb.SignCertificateResponse
41+
wantErr bool
42+
}, 0, 1+len(csr))
43+
tests = append(tests, struct {
3844
name string
3945
args args
4046
want *pb.SignCertificateResponse
4147
wantErr bool
4248
}{
43-
{
44-
name: "invalid csr",
45-
args: args{
46-
req: &pb.SignCertificateRequest{},
47-
},
48-
wantErr: true,
49+
name: "invalid csr",
50+
args: args{
51+
req: &pb.SignCertificateRequest{},
4952
},
50-
}
53+
wantErr: true,
54+
})
5155
for idx, csr := range csr {
5256
tests = append(tests, struct {
5357
name string

certificate-authority/store/mongodb/signingRecords.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func (s *Store) UpdateSigningRecord(ctx context.Context, signingRecord *store.Si
3939
return err
4040
}
4141

42-
func toCommonNameQueryFilter(owner string, commonName string) bson.D {
42+
func toCommonNameQueryFilter(owner, commonName string) bson.D {
4343
f := bson.D{
4444
{Key: store.CommonNameKey, Value: commonName},
4545
}
@@ -49,7 +49,7 @@ func toCommonNameQueryFilter(owner string, commonName string) bson.D {
4949
return f
5050
}
5151

52-
func toDeviceIDQueryFilter(owner string, deviceID string) bson.D {
52+
func toDeviceIDQueryFilter(owner, deviceID string) bson.D {
5353
f := bson.D{
5454
{Key: store.DeviceIDKey, Value: deviceID},
5555
}
@@ -59,7 +59,7 @@ func toDeviceIDQueryFilter(owner string, deviceID string) bson.D {
5959
return f
6060
}
6161

62-
func toIDQueryFilter(owner string, id string) bson.D {
62+
func toIDQueryFilter(owner, id string) bson.D {
6363
f := bson.D{
6464
{Key: "_id", Value: id},
6565
}
@@ -70,7 +70,8 @@ func toIDQueryFilter(owner string, id string) bson.D {
7070
}
7171

7272
func toSigningRecordsQueryFilter(owner string, queries *store.SigningRecordsQuery) interface{} {
73-
or := []bson.D{}
73+
n := len(queries.GetIdFilter()) + len(queries.GetCommonNameFilter()) + len(queries.GetDeviceIdFilter())
74+
or := make([]bson.D, 0, n)
7475
for _, q := range queries.GetIdFilter() {
7576
or = append(or, toIDQueryFilter(owner, q))
7677
}

charts/plgd-hub/Chart.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ dependencies:
44
version: 1.1.9
55
- name: mongodb
66
repository: https://charts.bitnami.com/bitnami
7-
version: 15.4.4
7+
version: 16.5.45
88
- name: scylla
99
repository: https://scylla-operator-charts.storage.googleapis.com/stable
1010
version: v1.10.0
11-
digest: sha256:2c3e908c6556633c6fd5467498177029023aa737b9436d1001907ecd9ba282ec
12-
generated: "2024-05-20T14:26:43.823740553Z"
11+
digest: sha256:9971025d84d32173972f9ab2dee404b98214c98367b93496de63f04d6536a914
12+
generated: "2026-01-27T10:16:34.731286183+01:00"

charts/plgd-hub/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ dependencies:
1515
repository: "https://nats-io.github.io/k8s/helm/charts/"
1616
condition: nats.enabled
1717
- name: "mongodb"
18-
version: "15.4.4"
18+
version: "16.5.45"
1919
repository: "https://charts.bitnami.com/bitnami"
2020
condition: mongodb.enabled
2121
- name: "scylla"

charts/plgd-hub/values.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,10 @@ mongodb:
209209
enabled: false
210210
image:
211211
debug: true
212+
registry: public.ecr.aws
213+
global:
214+
security:
215+
allowInsecureImages: true
212216
tls:
213217
enabled: false
214218
standbyTool:

0 commit comments

Comments
 (0)