build: update golangci-lint to v2.12.2 with org-standard v2 config
All checks were successful
check / check (push) Successful in 33s
All checks were successful
check / check (push) Successful in 33s
Pin golangci-lint to commit c0d3ddc9cf3faa61a4e378e879ece580256d76e5 (v2.12.2) in Dockerfile and script/bootstrap. Set .golangci.yml to the org-standard v2-schema config already used across the org's repos (owner-authorized; the same file is being landed as canonical via a prompts-repo PR). Lint settings live under linters.settings, so the lll, funlen, cyclop, and dupl thresholds are actually applied. The informational gomodguard deprecation warning this config can emit under v2.12 is accepted. Fix all findings surfaced by the now-active thresholds: - goconst: shared constants for repeated status, priority, and DNS fixture strings in watcher.go and the notify, state, and watcher tests - dupl: consolidate duplicated ntfy/slack HTTP-error tests and SendNotification endpoint-error tests behind shared helpers - lll: wrap long test table entries and comments; shorten one inline nolint justification
This commit is contained in:
@@ -26,6 +26,12 @@ const tlsPort = 443
|
||||
// hoursPerDay converts days to hours for duration calculations.
|
||||
const hoursPerDay = 24
|
||||
|
||||
// Status values recorded for nameserver and certificate checks.
|
||||
const (
|
||||
statusOK = "ok"
|
||||
statusError = "error"
|
||||
)
|
||||
|
||||
// Params contains dependencies for Watcher.
|
||||
type Params struct {
|
||||
fx.In
|
||||
@@ -344,7 +350,7 @@ func buildHostnameState(
|
||||
for ns, recs := range records {
|
||||
hs.RecordsByNameserver[ns] = &state.NameserverRecordState{
|
||||
Records: recs,
|
||||
Status: "ok",
|
||||
Status: statusOK,
|
||||
LastChecked: now,
|
||||
}
|
||||
}
|
||||
@@ -402,7 +408,7 @@ func (w *Watcher) detectNSDisappearances(
|
||||
current map[string]map[string][]string,
|
||||
) {
|
||||
for ns, prevNS := range prev.RecordsByNameserver {
|
||||
if _, ok := current[ns]; ok || prevNS.Status != "ok" {
|
||||
if _, ok := current[ns]; ok || prevNS.Status != statusOK {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -421,7 +427,7 @@ func (w *Watcher) detectNSDisappearances(
|
||||
|
||||
for ns := range current {
|
||||
prevNS, ok := prev.RecordsByNameserver[ns]
|
||||
if !ok || prevNS.Status != "error" {
|
||||
if !ok || prevNS.Status != statusError {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -705,7 +711,7 @@ func (w *Watcher) handleTLSError(
|
||||
now time.Time,
|
||||
err error,
|
||||
) {
|
||||
if hasPrev && !w.firstRun && prev.Status == "ok" {
|
||||
if hasPrev && !w.firstRun && prev.Status == statusOK {
|
||||
msg := fmt.Sprintf(
|
||||
"Host: %s\nIP: %s\nError: %s",
|
||||
hostname, ip, err,
|
||||
@@ -721,7 +727,7 @@ func (w *Watcher) handleTLSError(
|
||||
|
||||
w.state.SetCertificateState(
|
||||
certKey, &state.CertificateState{
|
||||
Status: "error",
|
||||
Status: statusError,
|
||||
Error: err.Error(),
|
||||
LastChecked: now,
|
||||
},
|
||||
@@ -748,7 +754,7 @@ func (w *Watcher) handleTLSSuccess(
|
||||
Issuer: cert.Issuer,
|
||||
NotAfter: cert.NotAfter,
|
||||
SubjectAlternativeNames: cert.SubjectAlternativeNames,
|
||||
Status: "ok",
|
||||
Status: statusOK,
|
||||
LastChecked: now,
|
||||
},
|
||||
)
|
||||
@@ -760,7 +766,7 @@ func (w *Watcher) detectTLSChanges(
|
||||
prev *state.CertificateState,
|
||||
cert *tlscheck.CertificateInfo,
|
||||
) {
|
||||
if prev.Status == "error" {
|
||||
if prev.Status == statusError {
|
||||
msg := fmt.Sprintf(
|
||||
"Host: %s\nIP: %s\nTLS recovered",
|
||||
hostname, ip,
|
||||
|
||||
Reference in New Issue
Block a user