exclusions does not need to be variadic (#711)

This commit is contained in:
Keith Zantow 2021-12-21 10:13:15 -05:00 committed by GitHub
parent cc20a8f341
commit b7979dbc7d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 8 additions and 8 deletions

View file

@ -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

View file

@ -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

View file

@ -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 {

View file

@ -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 {
@ -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 {

View file

@ -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)

View file

@ -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)
@ -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)