Skip to content

Commit

Permalink
exclusions does not need to be variadic (#711)
Browse files Browse the repository at this point in the history
  • Loading branch information
kzantow authored Dec 21, 2021
1 parent cc20a8f commit b7979db
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cmd/packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ func packagesExecWorker(userInput string) <-chan error {

checkForApplicationUpdate()

src, cleanup, err := source.New(userInput, appConfig.Registry.ToOptions(), appConfig.Exclusions...)
src, cleanup, err := source.New(userInput, appConfig.Registry.ToOptions(), appConfig.Exclusions)
if err != nil {
errs <- fmt.Errorf("failed to determine image source: %w", err)
return
Expand Down
2 changes: 1 addition & 1 deletion cmd/power_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func powerUserExecWorker(userInput string) <-chan error {

checkForApplicationUpdate()

src, cleanup, err := source.New(userInput, appConfig.Registry.ToOptions(), appConfig.Exclusions...)
src, cleanup, err := source.New(userInput, appConfig.Registry.ToOptions(), appConfig.Exclusions)
if err != nil {
errs <- err
return
Expand Down
2 changes: 1 addition & 1 deletion syft/source/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type Source struct {
type sourceDetector func(string) (image.Source, string, error)

// New produces a Source based on userInput like dir: or image:tag
func New(userInput string, registryOptions *image.RegistryOptions, exclusions ...string) (*Source, func(), error) {
func New(userInput string, registryOptions *image.RegistryOptions, exclusions []string) (*Source, func(), error) {
fs := afero.NewOsFs()
parsedScheme, imageSource, location, err := detectScheme(fs, image.DetectSource, userInput)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions syft/source/source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ func TestDirectoryExclusions(t *testing.T) {
registryOpts := &image.RegistryOptions{}
for _, test := range testCases {
t.Run(test.desc, func(t *testing.T) {
src, fn, err := New("dir:"+test.input, registryOpts, test.exclusions...)
src, fn, err := New("dir:"+test.input, registryOpts, test.exclusions)
defer fn()

if test.err {
Expand Down Expand Up @@ -512,7 +512,7 @@ func TestImageExclusions(t *testing.T) {
for _, test := range testCases {
t.Run(test.desc, func(t *testing.T) {
archiveLocation := imagetest.PrepareFixtureImage(t, "docker-archive", test.input)
src, fn, err := New(archiveLocation, registryOpts, test.exclusions...)
src, fn, err := New(archiveLocation, registryOpts, test.exclusions)
defer fn()

if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/catalog_packages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func BenchmarkImagePackageCatalogers(b *testing.B) {
var pc *pkg.Catalog
for _, c := range cataloger.ImageCatalogers() {
// in case of future alteration where state is persisted, assume no dependency is safe to reuse
theSource, cleanupSource, err := source.New("docker-archive:"+tarPath, nil)
theSource, cleanupSource, err := source.New("docker-archive:"+tarPath, nil, nil)
b.Cleanup(cleanupSource)
if err != nil {
b.Fatalf("unable to get source: %+v", err)
Expand Down
4 changes: 2 additions & 2 deletions test/integration/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func catalogFixtureImage(t *testing.T, fixtureImageName string) (sbom.SBOM, *sou
imagetest.GetFixtureImage(t, "docker-archive", fixtureImageName)
tarPath := imagetest.GetFixtureImageTarPath(t, fixtureImageName)

theSource, cleanupSource, err := source.New("docker-archive:"+tarPath, nil)
theSource, cleanupSource, err := source.New("docker-archive:"+tarPath, nil, nil)
t.Cleanup(cleanupSource)
if err != nil {
t.Fatalf("unable to get source: %+v", err)
Expand Down Expand Up @@ -45,7 +45,7 @@ func catalogFixtureImage(t *testing.T, fixtureImageName string) (sbom.SBOM, *sou
}

func catalogDirectory(t *testing.T, dir string) (sbom.SBOM, *source.Source) {
theSource, cleanupSource, err := source.New("dir:"+dir, nil)
theSource, cleanupSource, err := source.New("dir:"+dir, nil, nil)
t.Cleanup(cleanupSource)
if err != nil {
t.Fatalf("unable to get source: %+v", err)
Expand Down

0 comments on commit b7979db

Please sign in to comment.