Skip to content

Commit 7fe1796

Browse files
authored
chore: minor changes (#2108)
1 parent b9b0412 commit 7fe1796

File tree

11 files changed

+25
-36
lines changed

11 files changed

+25
-36
lines changed

.golangci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ linters-settings:
77
check-shadowing: true
88
gocyclo:
99
min-complexity: 12
10-
maligned:
11-
suggest-new: true
1210
goconst:
1311
min-len: 3
1412
min-occurrences: 3

certcrypto/crypto_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ func TestGenerateCSR(t *testing.T) {
3939
expected expected
4040
}{
4141
{
42-
desc: "without SAN",
42+
desc: "without SAN (nil)",
4343
privateKey: privateKey,
4444
domain: "lego.acme",
4545
mustStaple: true,
4646
expected: expected{len: 245},
4747
},
4848
{
49-
desc: "without SAN",
49+
desc: "without SAN (empty)",
5050
privateKey: privateKey,
5151
domain: "lego.acme",
5252
san: []string{},

certificate/authorization.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const (
1212
// limited on the "new-reg", "new-authz" and "new-cert" endpoints.
1313
// From the documentation the limitation is 20 requests per second,
1414
// but using 20 as value doesn't work but 18 do.
15+
// https://letsencrypt.org/docs/rate-limits/
1516
overallRequestLimit = 18
1617
)
1718

challenge/dns01/nameserver.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"net"
77
"os"
8+
"slices"
89
"strconv"
910
"strings"
1011
"sync"
@@ -216,12 +217,10 @@ func fetchSoaByFqdn(fqdn string, nameservers []string) (*soaCacheEntry, error) {
216217

217218
// dnsMsgContainsCNAME checks for a CNAME answer in msg.
218219
func dnsMsgContainsCNAME(msg *dns.Msg) bool {
219-
for _, ans := range msg.Answer {
220-
if _, ok := ans.(*dns.CNAME); ok {
221-
return true
222-
}
223-
}
224-
return false
220+
return slices.ContainsFunc(msg.Answer, func(rr dns.RR) bool {
221+
_, ok := rr.(*dns.CNAME)
222+
return ok
223+
})
225224
}
226225

227226
func dnsQuery(fqdn string, rtype uint16, nameservers []string, recursive bool) (*dns.Msg, error) {

docs/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.PHONY: default clean hugo hugo-build
22

3-
default: hugo
3+
default: clean hugo
44

55
clean:
66
rm -rf public/

platform/tester/env.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package tester
33
import (
44
"fmt"
55
"os"
6+
"slices"
67
)
78

89
// EnvTest Environment variables manager for tests.
@@ -143,10 +144,5 @@ func (e *EnvTest) Apply(envVars map[string]string) {
143144
}
144145

145146
func (e *EnvTest) isManagedKey(varName string) bool {
146-
for _, key := range e.keys {
147-
if key == varName {
148-
return true
149-
}
150-
}
151-
return false
147+
return slices.Contains(e.keys, varName)
152148
}

providers/dns/cloudxns/internal/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func (c *Client) GetDomainInformation(ctx context.Context, fqdn string) (*Data,
6060

6161
authZone, err := dns01.FindZoneByFqdn(fqdn)
6262
if err != nil {
63-
return nil, fmt.Errorf("cloudflare: could not find zone for FQDN %q: %w", fqdn, err)
63+
return nil, fmt.Errorf("could not find zone for FQDN %q: %w", fqdn, err)
6464
}
6565

6666
var domains []Data

providers/dns/constellix/constellix.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"errors"
77
"fmt"
88
"net/http"
9+
"slices"
910
"strconv"
1011
"time"
1112

@@ -272,13 +273,11 @@ func containsValue(record *internal.Record, value string) bool {
272273
return false
273274
}
274275

275-
for _, val := range record.Value {
276-
if val.Value == fmt.Sprintf(`%q`, value) {
277-
return true
278-
}
279-
}
276+
qValue := fmt.Sprintf(`%q`, value)
280277

281-
return false
278+
return slices.ContainsFunc(record.Value, func(val internal.RecordValue) bool {
279+
return val.Value == qValue
280+
})
282281
}
283282

284283
func backoff(min, max time.Duration, attemptNum int, resp *http.Response) time.Duration {

providers/dns/edgedns/edgedns.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package edgedns
44
import (
55
"errors"
66
"fmt"
7+
"slices"
78
"strings"
89
"time"
910

@@ -224,13 +225,9 @@ func getZone(domain string) (string, error) {
224225
}
225226

226227
func containsValue(values []string, value string) bool {
227-
for _, val := range values {
228-
if strings.Trim(val, `"`) == value {
229-
return true
230-
}
231-
}
232-
233-
return false
228+
return slices.ContainsFunc(values, func(val string) bool {
229+
return strings.Trim(val, `"`) == value
230+
})
234231
}
235232

236233
func isNotFound(err error) bool {

providers/dns/oraclecloud/configprovider.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func (p *configProvider) PrivateRSAKey() (*rsa.PrivateKey, error) {
2828
return nil, err
2929
}
3030

31-
return common.PrivateKeyFromBytes(privateKey, common.String(p.privateKeyPassphrase))
31+
return common.PrivateKeyFromBytesWithPassword(privateKey, []byte(p.privateKeyPassphrase))
3232
}
3333

3434
func (p *configProvider) KeyID() (string, error) {

0 commit comments

Comments
 (0)