Rename crypto package to certmanager to resolve golangci-lint naming conflict

- Renamed pkg/service/crypto to pkg/service/certmanager
- Updated package declaration from 'crypto' to 'certmanager'
- Fixed all import statements across the codebase
- Updated type references from *crypto.CertificateManager to *certmanager.CertificateManager
- Renamed files for consistency: crypto.go -> certmanager.go, crypto_test.go -> certmanager_test.go
- Resolves golangci-lint var-naming issue about conflicting with Go standard library package names
- All tests pass and linter reports 0 issues
This commit is contained in:
Tobias Gesellchen
2026-02-13 22:36:36 +01:00
parent c9f648096e
commit 1a39c14b35
6 changed files with 18 additions and 18 deletions
+3 -3
View File
@@ -14,7 +14,7 @@ import (
"strings"
"time"
"github.com/gesellix/bose-soundtouch/pkg/service/crypto"
"github.com/gesellix/bose-soundtouch/pkg/service/certmanager"
"github.com/gesellix/bose-soundtouch/pkg/service/datastore"
"github.com/gesellix/bose-soundtouch/pkg/service/handlers"
"github.com/gesellix/bose-soundtouch/pkg/service/proxy"
@@ -173,8 +173,8 @@ func initDataStore(dataDir string) *datastore.DataStore {
return ds
}
func initCertificateManager(dataDir string) *crypto.CertificateManager {
cm := crypto.NewCertificateManager(filepath.Join(dataDir, "certs"))
func initCertificateManager(dataDir string) *certmanager.CertificateManager {
cm := certmanager.NewCertificateManager(filepath.Join(dataDir, "certs"))
if err := cm.EnsureCA(); err != nil {
log.Printf("Warning: Failed to ensure CA: %v", err)
}
@@ -1,5 +1,5 @@
// Package crypto provides tools for managing Root CAs and generating SSL certificates.
package crypto
// Package certmanager provides tools for managing Root CAs and generating SSL certificates.
package certmanager
import (
"crypto/rand"
@@ -1,4 +1,4 @@
package crypto
package certmanager
import (
"crypto/x509"
+2 -2
View File
@@ -9,7 +9,7 @@ import (
"path/filepath"
"testing"
"github.com/gesellix/bose-soundtouch/pkg/service/crypto"
"github.com/gesellix/bose-soundtouch/pkg/service/certmanager"
"github.com/gesellix/bose-soundtouch/pkg/service/datastore"
"github.com/gesellix/bose-soundtouch/pkg/service/setup"
)
@@ -97,7 +97,7 @@ func TestMigrationAndCA(t *testing.T) {
ds := datastore.NewDataStore(tempDir)
_ = ds.Initialize()
cm := crypto.NewCertificateManager(filepath.Join(tempDir, "certs"))
cm := certmanager.NewCertificateManager(filepath.Join(tempDir, "certs"))
_ = cm.EnsureCA()
sm := setup.NewManager("http://localhost:8000", ds, cm)
+3 -3
View File
@@ -10,7 +10,7 @@ import (
"os"
"strings"
"github.com/gesellix/bose-soundtouch/pkg/service/crypto"
"github.com/gesellix/bose-soundtouch/pkg/service/certmanager"
"github.com/gesellix/bose-soundtouch/pkg/service/datastore"
"github.com/gesellix/bose-soundtouch/pkg/service/ssh"
)
@@ -70,12 +70,12 @@ type SSHClient interface {
type Manager struct {
ServerURL string
DataStore *datastore.DataStore
Crypto *crypto.CertificateManager
Crypto *certmanager.CertificateManager
NewSSH func(host string) SSHClient
}
// NewManager creates a new Manager with the given base server URL.
func NewManager(serverURL string, ds *datastore.DataStore, cm *crypto.CertificateManager) *Manager {
func NewManager(serverURL string, ds *datastore.DataStore, cm *certmanager.CertificateManager) *Manager {
return &Manager{
ServerURL: serverURL,
DataStore: ds,
+7 -7
View File
@@ -9,7 +9,7 @@ import (
"strings"
"testing"
"github.com/gesellix/bose-soundtouch/pkg/service/crypto"
"github.com/gesellix/bose-soundtouch/pkg/service/certmanager"
)
type mockSSH struct {
@@ -38,7 +38,7 @@ func TestMigrateViaHosts(t *testing.T) {
}
defer os.RemoveAll(tempDir)
cm := crypto.NewCertificateManager(filepath.Join(tempDir, "certs"))
cm := certmanager.NewCertificateManager(filepath.Join(tempDir, "certs"))
if err := cm.EnsureCA(); err != nil {
t.Fatalf("Failed to ensure CA: %v", err)
}
@@ -223,7 +223,7 @@ func TestCheckCACertTrusted(t *testing.T) {
}
defer os.RemoveAll(tempDir)
cm := crypto.NewCertificateManager(filepath.Join(tempDir, "certs"))
cm := certmanager.NewCertificateManager(filepath.Join(tempDir, "certs"))
if err := cm.EnsureCA(); err != nil {
t.Fatalf("Failed to ensure CA: %v", err)
}
@@ -296,7 +296,7 @@ func TestTestConnection(t *testing.T) {
}
defer os.RemoveAll(tempDir)
cm := crypto.NewCertificateManager(filepath.Join(tempDir, "certs"))
cm := certmanager.NewCertificateManager(filepath.Join(tempDir, "certs"))
if err := cm.EnsureCA(); err != nil {
t.Fatalf("Failed to ensure CA: %v", err)
}
@@ -383,7 +383,7 @@ func TestTestHostsRedirection(t *testing.T) {
}
defer os.RemoveAll(tempDir)
cm := crypto.NewCertificateManager(filepath.Join(tempDir, "certs"))
cm := certmanager.NewCertificateManager(filepath.Join(tempDir, "certs"))
if err := cm.EnsureCA(); err != nil {
t.Fatalf("Failed to ensure CA: %v", err)
}
@@ -530,7 +530,7 @@ func TestMigrateViaHosts_SkipCAIfTrusted(t *testing.T) {
}
defer os.RemoveAll(tempDir)
cm := crypto.NewCertificateManager(filepath.Join(tempDir, "certs"))
cm := certmanager.NewCertificateManager(filepath.Join(tempDir, "certs"))
if err := cm.EnsureCA(); err != nil {
t.Fatalf("Failed to ensure CA: %v", err)
}
@@ -579,7 +579,7 @@ func TestTrustCACert(t *testing.T) {
}
defer os.RemoveAll(tempDir)
cm := crypto.NewCertificateManager(filepath.Join(tempDir, "certs"))
cm := certmanager.NewCertificateManager(filepath.Join(tempDir, "certs"))
if err := cm.EnsureCA(); err != nil {
t.Fatalf("Failed to ensure CA: %v", err)
}