diff --git a/go.mod b/go.mod index cd7f8feee75..b4dda9cc4c1 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/anchore/bubbly v0.0.0-20231115134915-def0aba654a9 github.com/anchore/clio v0.0.0-20250319180342-2cfe4b0cb716 github.com/anchore/fangs v0.0.0-20250319222917-446a1e748ec2 - github.com/anchore/go-collections v0.0.0-20240216171411-9321230ce537 + github.com/anchore/go-collections v0.0.0-20251016125210-a3c352120e8c github.com/anchore/go-homedir v0.0.0-20250319154043-c29668562e4d github.com/anchore/go-logger v0.0.0-20250318195838-07ae343dd722 github.com/anchore/go-macholibre v0.0.0-20220308212642-53e6d0aaf6fb diff --git a/go.sum b/go.sum index 82fb633fe1c..0b94185963d 100644 --- a/go.sum +++ b/go.sum @@ -116,8 +116,8 @@ github.com/anchore/clio v0.0.0-20250319180342-2cfe4b0cb716 h1:2sIdYJlQESEnyk3Y0W github.com/anchore/clio v0.0.0-20250319180342-2cfe4b0cb716/go.mod h1:Utb9i4kwiCWvqAIxZaJeMIXFO9uOgQXlvH2BfbfO/zI= github.com/anchore/fangs v0.0.0-20250319222917-446a1e748ec2 h1:GC2QaO0YsmjpsZ4rtVKv9DnproIxqqn+qkskpc+i8MA= github.com/anchore/fangs v0.0.0-20250319222917-446a1e748ec2/go.mod h1:XUbUECwVKuD3qYRUj+QZIOHjyyXua2gFmVjKA40iHXA= -github.com/anchore/go-collections v0.0.0-20240216171411-9321230ce537 h1:GjNGuwK5jWjJMyVppBjYS54eOiiSNv4Ba869k4wh72Q= -github.com/anchore/go-collections v0.0.0-20240216171411-9321230ce537/go.mod h1:1aiktV46ATCkuVg0O573ZrH56BUawTECPETbZyBcqT8= +github.com/anchore/go-collections v0.0.0-20251016125210-a3c352120e8c h1:eoJXyC0n7DZ4YvySG/ETdYkTar2Due7eH+UmLK6FbrA= +github.com/anchore/go-collections v0.0.0-20251016125210-a3c352120e8c/go.mod h1:1aiktV46ATCkuVg0O573ZrH56BUawTECPETbZyBcqT8= github.com/anchore/go-homedir v0.0.0-20250319154043-c29668562e4d h1:gT69osH9AsdpOfqxbRwtxcNnSZ1zg4aKy2BevO3ZBdc= github.com/anchore/go-homedir v0.0.0-20250319154043-c29668562e4d/go.mod h1:PhSnuFYknwPZkOWKB1jXBNToChBA+l0FjwOxtViIc50= github.com/anchore/go-logger v0.0.0-20250318195838-07ae343dd722 h1:2SqmFgE7h+Ql4VyBzhjLkRF/3gDrcpUBj8LjvvO6OOM= diff --git a/syft/get_source_config_test.go b/syft/get_source_config_test.go new file mode 100644 index 00000000000..9d0ad877472 --- /dev/null +++ b/syft/get_source_config_test.go @@ -0,0 +1,37 @@ +package syft + +import ( + "testing" + + "github.com/anchore/stereoscope" + "github.com/anchore/syft/syft/source/sourceproviders" +) + +func TestGetProviders_DefaultImagePullSource(t *testing.T) { + userInput := "" + cfg := &GetSourceConfig{DefaultImagePullSource: stereoscope.RegistryTag} + allSourceProviders := sourceproviders.All(userInput, cfg.SourceProviderConfig) + + providers, err := cfg.getProviders(userInput) + if err != nil { + t.Errorf("Expected no error for DefaultImagePullSource parameter, got: %v", err) + } + + if len(providers) != len(allSourceProviders) { + t.Errorf("Expected %d providers, got %d", len(allSourceProviders), len(providers)) + } +} + +func TestGetProviders_Sources(t *testing.T) { + userInput := "" + cfg := &GetSourceConfig{Sources: []string{stereoscope.RegistryTag}} + + providers, err := cfg.getProviders(userInput) + if err != nil { + t.Errorf("Expected no error for Sources parameter, got: %v", err) + } + + if len(providers) != 1 { + t.Errorf("Expected 1 providers, got %d", len(providers)) + } +}