Skip to content

Commit 65be168

Browse files
committed
chore: update Go, dependencies, linter, workflows
1 parent 0d8d358 commit 65be168

File tree

21 files changed

+182
-142
lines changed

21 files changed

+182
-142
lines changed

.github/workflows/go-cross.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ jobs:
2525

2626
# https://github.com/marketplace/actions/checkout
2727
- name: Checkout code
28-
uses: actions/checkout@v4
28+
uses: actions/checkout@v5
2929

3030
# https://github.com/marketplace/actions/setup-go-environment
3131
- name: Set up Go ${{ matrix.go-version }}
32-
uses: actions/setup-go@v5
32+
uses: actions/setup-go@v6
3333
with:
3434
go-version: ${{ matrix.go-version }}
3535

.github/workflows/main.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ jobs:
1515
runs-on: ubuntu-latest
1616
env:
1717
GO_VERSION: stable
18-
GOLANGCI_LINT_VERSION: v2.0.1
18+
GOLANGCI_LINT_VERSION: v2.6.1
1919
CGO_ENABLED: 0
2020

2121
steps:
22-
- uses: actions/checkout@v4
23-
- uses: actions/setup-go@v5
22+
- uses: actions/checkout@v5
23+
- uses: actions/setup-go@v6
2424
with:
2525
go-version: ${{ env.GO_VERSION }}
2626

@@ -31,11 +31,11 @@ jobs:
3131
git diff --exit-code go.mod
3232
git diff --exit-code go.sum
3333
34-
# https://golangci-lint.run/usage/install#other-ci
3534
- name: Install golangci-lint ${{ env.GOLANGCI_LINT_VERSION }}
36-
run: |
37-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_LINT_VERSION}
38-
golangci-lint --version
35+
uses: golangci/[email protected]
36+
with:
37+
version: ${{ env.GOLANGCI_LINT_VERSION }}
38+
install-only: true
3939

4040
- name: Make
4141
run: make

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ jobs:
3535
docker-images: true
3636
swap-storage: false
3737

38-
- uses: actions/checkout@v4
38+
- uses: actions/checkout@v5
3939
with:
4040
fetch-depth: 0
41-
- uses: actions/setup-go@v5
41+
- uses: actions/setup-go@v6
4242
with:
4343
go-version: ${{ env.GO_VERSION }}
4444

.golangci.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ linters:
2828
- tparallel
2929
- varnamelen
3030
- wrapcheck
31-
- wsl
31+
- noinlineerr
32+
- wsl # deprecated
3233
settings:
3334
depguard:
3435
rules:
@@ -102,6 +103,10 @@ linters:
102103
text: 'ST1000: at least one file in a package should have a package comment'
103104
- path: (.+)\.go$
104105
text: 'package-comments: should have a package comment'
106+
paths:
107+
- internal/traefikv1/
108+
- internal/traefikv2/
109+
- internal/traefikv3/
105110

106111
issues:
107112
max-issues-per-linter: 0

cmd/kv.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ func createTLSConfig(cmd *cobra.Command) (*tls.Config, error) {
5757
}
5858

5959
ca := cmd.Flag("tls.ca").Value.String()
60+
6061
caPool, err := getCertPool(ca)
6162
if err != nil {
6263
return nil, err
@@ -108,13 +109,15 @@ func getCAContent(ca string) ([]byte, error) {
108109
if os.IsNotExist(err) {
109110
return []byte(ca), nil
110111
}
112+
111113
return nil, err
112114
}
113115

114116
caContent, err := os.ReadFile(filepath.Clean(ca))
115117
if err != nil {
116118
return nil, err
117119
}
120+
118121
return caContent, nil
119122
}
120123

@@ -126,6 +129,7 @@ func getClientAuth(ca string, caOptional bool) tls.ClientAuthType {
126129
if caOptional {
127130
return tls.VerifyClientCertIfGiven
128131
}
132+
129133
return tls.RequireAndVerifyClientCert
130134
}
131135

@@ -158,5 +162,6 @@ func getCertificate(privateKey, certContent string) (tls.Certificate, error) {
158162
if errCertIsFile != nil {
159163
return tls.Certificate{}, errCertIsFile
160164
}
165+
161166
return tls.Certificate{}, errKeyIsFile
162167
}

cmd/root.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ func tree(root, indent string) error {
119119
}
120120

121121
fmt.Println(fi.Name())
122+
122123
if !fi.IsDir() {
123124
return nil
124125
}
@@ -129,6 +130,7 @@ func tree(root, indent string) error {
129130
}
130131

131132
var names []string
133+
132134
for _, fi := range fis {
133135
if fi.Name()[0] != '.' {
134136
names = append(names, fi.Name())
@@ -137,8 +139,10 @@ func tree(root, indent string) error {
137139

138140
for i, name := range names {
139141
add := "│ "
142+
140143
if i == len(names)-1 {
141144
fmt.Print(indent + "└──")
145+
142146
add = " "
143147
} else {
144148
fmt.Print(indent + "├──")

dumper/file/file.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ func dump(acmeFile string, baseConfig *dumper.BaseConfig) error {
7878

7979
func dumpV1(acmeFile string, baseConfig *dumper.BaseConfig) error {
8080
data := &traefikv1.StoredData{}
81+
8182
err := readJSONFile(acmeFile, data)
8283
if err != nil {
8384
return err
@@ -88,6 +89,7 @@ func dumpV1(acmeFile string, baseConfig *dumper.BaseConfig) error {
8889

8990
func dumpV2(acmeFile string, baseConfig *dumper.BaseConfig) error {
9091
data := map[string]*traefikv2.StoredData{}
92+
9193
err := readJSONFile(acmeFile, &data)
9294
if err != nil {
9395
return err
@@ -98,6 +100,7 @@ func dumpV2(acmeFile string, baseConfig *dumper.BaseConfig) error {
98100

99101
func dumpV3(acmeFile string, baseConfig *dumper.BaseConfig) error {
100102
data := map[string]*traefikv3.StoredData{}
103+
101104
err := readJSONFile(acmeFile, &data)
102105
if err != nil {
103106
return err
@@ -106,18 +109,20 @@ func dumpV3(acmeFile string, baseConfig *dumper.BaseConfig) error {
106109
return dumperv3.Dump(data, baseConfig)
107110
}
108111

109-
func readJSONFile(acmeFile string, data interface{}) error {
112+
func readJSONFile(acmeFile string, data any) error {
110113
source, err := os.Open(filepath.Clean(acmeFile))
111114
if err != nil {
112115
return fmt.Errorf("failed to open file %q: %w", acmeFile, err)
113116
}
117+
114118
defer func() { _ = source.Close() }()
115119

116120
err = json.NewDecoder(source).Decode(data)
117121
if errors.Is(err, io.EOF) {
118122
log.Printf("warn: file %q may not be ready: %v", acmeFile, err)
119123
return nil
120124
}
125+
121126
if err != nil {
122127
return fmt.Errorf("failed to unmarshal file %q: %w", acmeFile, err)
123128
}
@@ -134,6 +139,7 @@ func watch(ctx context.Context, acmeFile string, baseConfig *dumper.BaseConfig)
134139
defer func() { _ = watcher.Close() }()
135140

136141
done := make(chan bool)
142+
137143
go func() {
138144
var previousHash []byte
139145

@@ -151,7 +157,9 @@ func watch(ctx context.Context, acmeFile string, baseConfig *dumper.BaseConfig)
151157
hash, errW := manageEvent(ctx, watcher, event, acmeFile, previousHash, baseConfig)
152158
if errW != nil {
153159
log.Println("error:", errW)
160+
154161
done <- true
162+
155163
return
156164
}
157165

@@ -163,7 +171,9 @@ func watch(ctx context.Context, acmeFile string, baseConfig *dumper.BaseConfig)
163171
}
164172

165173
log.Println("error:", errW)
174+
166175
done <- true
176+
167177
return
168178
}
169179
}
@@ -226,9 +236,11 @@ func calculateHash(acmeFile string) ([]byte, error) {
226236
if err != nil {
227237
return nil, err
228238
}
239+
229240
defer func() { _ = file.Close() }()
230241

231242
h := sha256.New()
243+
232244
_, err = io.Copy(h, file)
233245
if err != nil {
234246
return nil, err

dumper/kv/convert.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ func convertOldAccount(account *AccountOld) *traefikv1.StoredData {
6262
Key: oldCert.Certificate.PrivateKey,
6363
})
6464
}
65+
6566
storedData.Certificates = certs
6667

6768
return storedData

dumper/v1/dumper.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ func Dump(data *traefikv1.StoredData, baseConfig *dumper.BaseConfig) error {
5252
}
5353

5454
privateKeyPem := extractPEMPrivateKey(data.Account)
55+
5556
return os.WriteFile(filepath.Join(baseConfig.DumpPath, keysSubDir, "letsencrypt"+baseConfig.KeyInfo.Ext), privateKeyPem, 0o600)
5657
}
5758

@@ -81,6 +82,7 @@ func writeKey(dumpPath string, cert *traefikv1.Certificate, info dumper.FileInfo
8182

8283
func extractPEMPrivateKey(account *traefikv1.Account) []byte {
8384
var block *pem.Block
85+
8486
switch account.KeyType {
8587
case certcrypto.RSA2048, certcrypto.RSA4096, certcrypto.RSA8192:
8688
block = &pem.Block{

dumper/v1/filename.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build !windows
2-
// +build !windows
32

43
package v1
54

0 commit comments

Comments
 (0)