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
@@ -12,7 +12,7 @@ import (
"strings"
"time"
"github.com/mitchellh/mapstructure"
"github.com/go-viper/mapstructure/v2"
"github.com/vbatts/go-mtree"
"github.com/anchore/syft/internal"
+1 -1
View File
@@ -11,7 +11,7 @@ import (
"strings"
"github.com/dustin/go-humanize"
"github.com/mitchellh/mapstructure"
"github.com/go-viper/mapstructure/v2"
"github.com/anchore/syft/internal"
"github.com/anchore/syft/internal/log"
+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()
})
}
@@ -9,7 +9,7 @@ import (
"path/filepath"
"strings"
"github.com/mitchellh/go-homedir"
"github.com/anchore/go-homedir"
"github.com/anchore/syft/internal"
"github.com/anchore/syft/internal/log"
@@ -5,7 +5,7 @@ import (
"path/filepath"
"testing"
"github.com/mitchellh/go-homedir"
"github.com/anchore/go-homedir"
"github.com/stretchr/testify/require"
"github.com/anchore/syft/internal"
+1 -1
View File
@@ -9,7 +9,7 @@ import (
"sort"
"strings"
"github.com/mitchellh/mapstructure"
"github.com/go-viper/mapstructure/v2"
"github.com/anchore/packageurl-go"
stereoFile "github.com/anchore/stereoscope/pkg/file"
@@ -6,7 +6,7 @@ import (
"io"
"strings"
"github.com/mitchellh/mapstructure"
"github.com/go-viper/mapstructure/v2"
"github.com/anchore/syft/syft/pkg"
)
@@ -8,7 +8,7 @@ import (
"io"
"regexp"
"github.com/mitchellh/mapstructure"
"github.com/go-viper/mapstructure/v2"
"github.com/anchore/syft/internal"
"github.com/anchore/syft/syft/artifact"
@@ -9,7 +9,7 @@ import (
"unicode"
pep440 "github.com/aquasecurity/go-pep440-version"
"github.com/mitchellh/mapstructure"
"github.com/go-viper/mapstructure/v2"
"github.com/anchore/syft/internal"
"github.com/anchore/syft/internal/log"
@@ -6,7 +6,7 @@ import (
"path/filepath"
"strings"
"github.com/mitchellh/mapstructure"
"github.com/go-viper/mapstructure/v2"
intFile "github.com/anchore/syft/internal/file"
"github.com/anchore/syft/internal/log"
+1 -1
View File
@@ -8,7 +8,7 @@ import (
"regexp"
"strings"
"github.com/mitchellh/mapstructure"
"github.com/go-viper/mapstructure/v2"
"github.com/anchore/syft/internal"
"github.com/anchore/syft/syft/artifact"