Remove mitchellh dependencies (#3748)

* remove mitchellh dependencies

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* fix failing unit tests

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

---------

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
Alex Goodman
2025-03-20 10:19:19 -04:00
committed by GitHub
parent 35d666b27d
commit e9b24a29d7
30 changed files with 132 additions and 119 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ import (
"path/filepath"
"strings"
"github.com/mitchellh/go-homedir"
"github.com/anchore/go-homedir"
"github.com/anchore/syft/internal/log"
)
+14 -6
View File
@@ -4,7 +4,7 @@ import (
"path/filepath"
"testing"
"github.com/mitchellh/go-homedir"
"github.com/anchore/go-homedir"
"github.com/stretchr/testify/assert"
)
@@ -18,11 +18,8 @@ func Test_Config(t *testing.T) {
noProxy string
}
homedirCacheDisabled := homedir.DisableCache
homedir.DisableCache = true
t.Cleanup(func() {
homedir.DisableCache = homedirCacheDisabled
})
restoreCache(t)
homedir.SetCacheEnable(false)
allEnv := map[string]string{
"HOME": "/usr/home",
@@ -111,3 +108,14 @@ func Test_Config(t *testing.T) {
})
}
}
// restoreCache ensures cache settings are restored after test
func restoreCache(t testing.TB) {
t.Helper()
origEnabled := homedir.CacheEnabled()
t.Cleanup(func() {
homedir.SetCacheEnable(origEnabled)
homedir.Reset()
})
}