Skip to content

Commit 53659fc

Browse files
committed
refactor: split into files
Split the `x509/` package into smaller files, previously it was 1500 lines monolith with different methods and types mixed together, split it so it's mostly one type per file (or closely related files). I added a couple of unit-tests, but no code changes. Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
1 parent 0d45dee commit 53659fc

18 files changed

+2205
-1912
lines changed

.github/renovate.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"description": "THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.",
4+
"prHeader": "Update Request | Renovate Bot",
5+
"extends": [
6+
":dependencyDashboard",
7+
":gitSignOff",
8+
":semanticCommitScopeDisabled",
9+
"schedule:earlyMondays"
10+
],
11+
"packageRules": [
12+
{
13+
"groupName": "dependencies",
14+
"matchUpdateTypes": [
15+
"major",
16+
"minor",
17+
"patch",
18+
"pin",
19+
"digest"
20+
]
21+
},
22+
{
23+
"enabled": false,
24+
"matchFileNames": [
25+
"Dockerfile"
26+
]
27+
},
28+
{
29+
"enabled": false,
30+
"matchFileNames": [
31+
".github/workflows/*.yaml"
32+
]
33+
}
34+
],
35+
"separateMajorMinor": false
36+
}

.golangci.yml

Lines changed: 107 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,32 @@
11
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
22
#
3-
# Generated on 2024-12-04T08:15:33Z by kres 232fe63.
3+
# Generated on 2025-05-14T13:00:06Z by kres 5ad3e5f.
4+
5+
version: "2"
46

57
# options for analysis running
68
run:
7-
timeout: 10m
9+
modules-download-mode: readonly
810
issues-exit-code: 1
911
tests: true
10-
build-tags: [ ]
11-
modules-download-mode: readonly
1212

1313
# output configuration options
1414
output:
1515
formats:
16-
- format: colored-line-number
16+
text:
1717
path: stdout
18-
print-issued-lines: true
19-
print-linter-name: true
20-
uniq-by-line: true
18+
print-issued-lines: true
19+
print-linter-name: true
2120
path-prefix: ""
2221

23-
# all available settings of specific linters
24-
linters-settings:
25-
dogsled:
26-
max-blank-identifiers: 2
27-
dupl:
28-
threshold: 150
29-
errcheck:
30-
check-type-assertions: true
31-
check-blank: true
32-
exhaustive:
33-
default-signifies-exhaustive: false
34-
gci:
35-
sections:
36-
- standard # Standard section: captures all standard packages.
37-
- default # Default section: contains all imports that could not be matched to another section type.
38-
- localmodule # Imports from the same module.
39-
gocognit:
40-
min-complexity: 30
41-
nestif:
42-
min-complexity: 5
43-
goconst:
44-
min-len: 3
45-
min-occurrences: 3
46-
gocritic:
47-
disabled-checks: [ ]
48-
gocyclo:
49-
min-complexity: 20
50-
godot:
51-
scope: declarations
52-
gofmt:
53-
simplify: true
54-
gomodguard: { }
55-
govet:
56-
enable-all: true
57-
lll:
58-
line-length: 200
59-
tab-width: 4
60-
misspell:
61-
locale: US
62-
ignore-words: [ ]
63-
nakedret:
64-
max-func-lines: 30
65-
prealloc:
66-
simple: true
67-
range-loops: true # Report preallocation suggestions on range loops, true by default
68-
for-loops: false # Report preallocation suggestions on for loops, false by default
69-
nolintlint:
70-
allow-unused: false
71-
allow-no-explanation: [ ]
72-
require-explanation: false
73-
require-specific: true
74-
rowserrcheck: { }
75-
testpackage: { }
76-
unparam:
77-
check-exported: false
78-
unused:
79-
local-variables-are-used: false
80-
whitespace:
81-
multi-if: false # Enforces newlines (or comments) after every multi-line if statement
82-
multi-func: false # Enforces newlines (or comments) after every multi-line function signature
83-
wsl:
84-
strict-append: true
85-
allow-assign-and-call: true
86-
allow-multiline-assign: true
87-
allow-cuddle-declarations: false
88-
allow-trailing-comment: false
89-
force-case-trailing-whitespace: 0
90-
force-err-cuddling: false
91-
allow-separated-leading-comment: false
92-
gofumpt:
93-
extra-rules: false
94-
cyclop:
95-
# the maximal code complexity to report
96-
max-complexity: 20
97-
depguard:
98-
rules:
99-
prevent_unmaintained_packages:
100-
list-mode: lax # allow unless explicitly denied
101-
files:
102-
- $all
103-
deny:
104-
- pkg: io/ioutil
105-
desc: "replaced by io and os packages since Go 1.16: https://tip.golang.org/doc/go1.16#ioutil"
10622

10723
linters:
108-
enable-all: true
109-
disable-all: false
110-
fast: false
24+
default: all
11125
disable:
11226
- exhaustruct
11327
- err113
11428
- forbidigo
29+
- funcorder
11530
- funlen
11631
- gochecknoglobals
11732
- gochecknoinits
@@ -132,18 +47,109 @@ linters:
13247
- testifylint # complains about our assert recorder and has a number of false positives for assert.Greater(t, thing, 1)
13348
- protogetter # complains about us using Value field on typed spec, instead of GetValue which has a different signature
13449
- perfsprint # complains about us using fmt.Sprintf in non-performance critical code, updating just kres took too long
135-
- goimports # same as gci
13650
- musttag # seems to be broken - goes into imported libraries and reports issues there
51+
- nolintlint # gives false positives - disable until https://github.com/golangci/golangci-lint/issues/3228 is resolved
52+
# all available settings of specific linters
53+
settings:
54+
cyclop:
55+
# the maximal code complexity to report
56+
max-complexity: 20
57+
dogsled:
58+
max-blank-identifiers: 2
59+
dupl:
60+
threshold: 150
61+
errcheck:
62+
check-type-assertions: true
63+
check-blank: true
64+
exhaustive:
65+
default-signifies-exhaustive: false
66+
gocognit:
67+
min-complexity: 30
68+
nestif:
69+
min-complexity: 5
70+
goconst:
71+
min-len: 3
72+
min-occurrences: 3
73+
gocritic:
74+
disabled-checks: [ ]
75+
gocyclo:
76+
min-complexity: 20
77+
godot:
78+
scope: declarations
79+
gomodguard: { }
80+
govet:
81+
enable-all: true
82+
lll:
83+
line-length: 200
84+
tab-width: 4
85+
misspell:
86+
locale: US
87+
nakedret:
88+
max-func-lines: 30
89+
prealloc:
90+
simple: true
91+
range-loops: true # Report preallocation suggestions on range loops, true by default
92+
for-loops: false # Report preallocation suggestions on for loops, false by default
93+
rowserrcheck: { }
94+
testpackage: { }
95+
unparam:
96+
check-exported: false
97+
unused:
98+
local-variables-are-used: false
99+
whitespace:
100+
multi-if: false # Enforces newlines (or comments) after every multi-line if statement
101+
multi-func: false # Enforces newlines (or comments) after every multi-line function signature
102+
wsl:
103+
strict-append: true
104+
allow-assign-and-call: true
105+
allow-multiline-assign: true
106+
allow-trailing-comment: false
107+
force-case-trailing-whitespace: 0
108+
allow-separated-leading-comment: false
109+
allow-cuddle-declarations: false
110+
force-err-cuddling: false
111+
depguard:
112+
rules:
113+
prevent_unmaintained_packages:
114+
list-mode: lax # allow unless explicitly denied
115+
files:
116+
- $all
117+
deny:
118+
- pkg: io/ioutil
119+
desc: "replaced by io and os packages since Go 1.16: https://tip.golang.org/doc/go1.16#ioutil"
137120

121+
exclusions:
122+
generated: lax
123+
paths:
124+
- third_party$
125+
- builtin$
126+
- examples$
138127
issues:
139-
exclude: [ ]
140-
exclude-rules: [ ]
141-
exclude-use-default: false
142-
exclude-case-sensitive: false
143128
max-issues-per-linter: 10
144129
max-same-issues: 3
130+
uniq-by-line: true
145131
new: false
146132

147133
severity:
148-
default-severity: error
149-
case-sensitive: false
134+
default: error
135+
formatters:
136+
enable:
137+
- gci
138+
- gofmt
139+
- gofumpt
140+
settings:
141+
gci:
142+
sections:
143+
- standard
144+
- default
145+
- localmodule
146+
gofmt:
147+
simplify: true
148+
gofumpt:
149+
extra-rules: false
150+
exclusions:
151+
generated: lax
152+
paths:
153+
- third_party$
154+
- builtin$
155+
- examples$

Dockerfile

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
# syntax = docker/dockerfile-upstream:1.11.1-labs
1+
# syntax = docker/dockerfile-upstream:1.15.1-labs
22

33
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
44
#
5-
# Generated on 2024-12-04T08:15:33Z by kres 232fe63.
5+
# Generated on 2025-05-21T15:18:29Z by kres 9f64b0d.
66

77
ARG TOOLCHAIN
88

99
# cleaned up specs and compiled versions
1010
FROM scratch AS generate
1111

1212
# runs markdownlint
13-
FROM docker.io/oven/bun:1.1.36-alpine AS lint-markdown
13+
FROM docker.io/oven/bun:1.2.13-alpine AS lint-markdown
1414
WORKDIR /src
15-
RUN bun i markdownlint-cli@0.43.0 sentences-per-line@0.2.1
15+
RUN bun i markdownlint-cli@0.45.0 sentences-per-line@0.3.0
1616
COPY .markdownlint.json .
1717
COPY ./README.md ./README.md
18-
RUN bunx markdownlint --ignore "CHANGELOG.md" --ignore "**/node_modules/**" --ignore '**/hack/chglog/**' --rules node_modules/sentences-per-line/index.js .
18+
RUN bunx markdownlint --ignore "CHANGELOG.md" --ignore "**/node_modules/**" --ignore '**/hack/chglog/**' --rules sentences-per-line .
1919

2020
# base toolchain image
2121
FROM --platform=${BUILDPLATFORM} ${TOOLCHAIN} AS toolchain
@@ -32,12 +32,12 @@ ARG GOEXPERIMENT
3232
ENV GOEXPERIMENT=${GOEXPERIMENT}
3333
ENV GOPATH=/go
3434
ARG DEEPCOPY_VERSION
35-
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg go install github.com/siderolabs/deep-copy@${DEEPCOPY_VERSION} \
35+
RUN --mount=type=cache,target=/root/.cache/go-build,id=crypto/root/.cache/go-build --mount=type=cache,target=/go/pkg,id=crypto/go/pkg go install github.com/siderolabs/deep-copy@${DEEPCOPY_VERSION} \
3636
&& mv /go/bin/deep-copy /bin/deep-copy
3737
ARG GOLANGCILINT_VERSION
38-
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg go install github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCILINT_VERSION} \
38+
RUN --mount=type=cache,target=/root/.cache/go-build,id=crypto/root/.cache/go-build --mount=type=cache,target=/go/pkg,id=crypto/go/pkg go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@${GOLANGCILINT_VERSION} \
3939
&& mv /go/bin/golangci-lint /bin/golangci-lint
40-
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg go install golang.org/x/vuln/cmd/govulncheck@latest \
40+
RUN --mount=type=cache,target=/root/.cache/go-build,id=crypto/root/.cache/go-build --mount=type=cache,target=/go/pkg,id=crypto/go/pkg go install golang.org/x/vuln/cmd/govulncheck@latest \
4141
&& mv /go/bin/govulncheck /bin/govulncheck
4242
ARG GOFUMPT_VERSION
4343
RUN go install mvdan.cc/gofumpt@${GOFUMPT_VERSION} \
@@ -49,11 +49,11 @@ WORKDIR /src
4949
COPY go.mod go.mod
5050
COPY go.sum go.sum
5151
RUN cd .
52-
RUN --mount=type=cache,target=/go/pkg go mod download
53-
RUN --mount=type=cache,target=/go/pkg go mod verify
52+
RUN --mount=type=cache,target=/go/pkg,id=crypto/go/pkg go mod download
53+
RUN --mount=type=cache,target=/go/pkg,id=crypto/go/pkg go mod verify
5454
COPY ./tls ./tls
5555
COPY ./x509 ./x509
56-
RUN --mount=type=cache,target=/go/pkg go list -mod=readonly all >/dev/null
56+
RUN --mount=type=cache,target=/go/pkg,id=crypto/go/pkg go list -mod=readonly all >/dev/null
5757

5858
# runs gofumpt
5959
FROM base AS lint-gofumpt
@@ -64,25 +64,24 @@ FROM base AS lint-golangci-lint
6464
WORKDIR /src
6565
COPY .golangci.yml .
6666
ENV GOGC=50
67-
RUN golangci-lint config verify --config .golangci.yml
68-
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/root/.cache/golangci-lint --mount=type=cache,target=/go/pkg golangci-lint run --config .golangci.yml
67+
RUN --mount=type=cache,target=/root/.cache/go-build,id=crypto/root/.cache/go-build --mount=type=cache,target=/root/.cache/golangci-lint,id=crypto/root/.cache/golangci-lint,sharing=locked --mount=type=cache,target=/go/pkg,id=crypto/go/pkg golangci-lint run --config .golangci.yml
6968

7069
# runs govulncheck
7170
FROM base AS lint-govulncheck
7271
WORKDIR /src
73-
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg govulncheck ./...
72+
RUN --mount=type=cache,target=/root/.cache/go-build,id=crypto/root/.cache/go-build --mount=type=cache,target=/go/pkg,id=crypto/go/pkg govulncheck ./...
7473

7574
# runs unit-tests with race detector
7675
FROM base AS unit-tests-race
7776
WORKDIR /src
7877
ARG TESTPKGS
79-
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg --mount=type=cache,target=/tmp CGO_ENABLED=1 go test -v -race -count 1 ${TESTPKGS}
78+
RUN --mount=type=cache,target=/root/.cache/go-build,id=crypto/root/.cache/go-build --mount=type=cache,target=/go/pkg,id=crypto/go/pkg --mount=type=cache,target=/tmp,id=crypto/tmp CGO_ENABLED=1 go test -v -race -count 1 ${TESTPKGS}
8079

8180
# runs unit-tests
8281
FROM base AS unit-tests-run
8382
WORKDIR /src
8483
ARG TESTPKGS
85-
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg --mount=type=cache,target=/tmp go test -v -covermode=atomic -coverprofile=coverage.txt -coverpkg=${TESTPKGS} -count 1 ${TESTPKGS}
84+
RUN --mount=type=cache,target=/root/.cache/go-build,id=crypto/root/.cache/go-build --mount=type=cache,target=/go/pkg,id=crypto/go/pkg --mount=type=cache,target=/tmp,id=crypto/tmp go test -v -covermode=atomic -coverprofile=coverage.txt -coverpkg=${TESTPKGS} -count 1 ${TESTPKGS}
8685

8786
FROM scratch AS unit-tests
8887
COPY --from=unit-tests-run /src/coverage.txt /coverage-unit-tests.txt

0 commit comments

Comments
 (0)