refactor: update golintci-lint and linter issues

* Update golangci-lint

Update golangci-lint to v2.

Signed-off-by: SuperQ <superq@gmail.com>

* Fixup various linter issues.

Signed-off-by: SuperQ <superq@gmail.com>

---------

Signed-off-by: SuperQ <superq@gmail.com>
This commit is contained in:
Ben Kochie
2025-04-13 02:55:30 +01:00
committed by GitHub
parent 951e673e0c
commit 009b0abbe9
11 changed files with 72 additions and 54 deletions

View File

@@ -49,12 +49,12 @@ func (s *CertStore) ensureStorePath() error {
s.log.Trace().Str("path", s.storePath).Msg("TLS store directory does not exist, creating directory")
err = os.MkdirAll(s.storePath, 0755)
if err != nil {
return fmt.Errorf("Failed to create TLS store path: %w", err)
return fmt.Errorf("failed to create TLS store path: %w", err)
}
return nil
}
return fmt.Errorf("Failed to check TLS store path: %w", err)
return fmt.Errorf("failed to check TLS store path: %w", err)
}
func (s *CertStore) LoadCertificates() {
@@ -115,7 +115,7 @@ func (s *CertStore) GetCertificate(hostname string) *tls.Certificate {
func (s *CertStore) ValidateAndSaveCertificate(hostname string, cert string, key string, ignoreWarning bool) (error, error) {
tlsCert, err := tls.X509KeyPair([]byte(cert), []byte(key))
if err != nil {
return fmt.Errorf("Failed to parse certificate: %w", err), nil
return fmt.Errorf("failed to parse certificate: %w", err), nil
}
// this can be skipped as current implementation supports one custom certificate only
@@ -129,7 +129,7 @@ func (s *CertStore) ValidateAndSaveCertificate(hostname string, cert string, key
if err = tlsCert.Leaf.VerifyHostname(hostname); err != nil {
if !ignoreWarning {
return nil, fmt.Errorf("Certificate does not match hostname: %w", err)
return nil, fmt.Errorf("certificate does not match hostname: %w", err)
}
s.log.Warn().Err(err).Msg("Certificate does not match hostname")
}