Skip to content

Commit

Permalink
Merge pull request #95 from dtrudg/issue-94
Browse files Browse the repository at this point in the history
fix: export no match / multiple match errors
  • Loading branch information
dtrudg authored Oct 7, 2024
2 parents aa3f634 + 3b0bc23 commit f29715a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
8 changes: 4 additions & 4 deletions pkg/sif/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ type image struct {
}

var (
errNoMatchingImage = errors.New("no image found matching criteria")
errMultipleMatchingImages = errors.New("multiple images match criteria")
ErrNoMatch = errors.New("no match found")
ErrMultipleMatches = errors.New("multiple matches found")
)

// Image returns a single Image stored in f, that is selected by the provided
Expand All @@ -42,10 +42,10 @@ func (f *OCIFileImage) Image(m match.Matcher, _ ...Option) (v1.Image, error) {
return nil, err
}
if len(matches) > 1 {
return nil, errMultipleMatchingImages
return nil, ErrMultipleMatches
}
if len(matches) == 0 {
return nil, errNoMatchingImage
return nil, ErrNoMatch
}

d, err := matches[0].Digest()
Expand Down
9 changes: 2 additions & 7 deletions pkg/sif/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,6 @@ func (f *OCIFileImage) RootIndex() (v1.ImageIndex, error) {
}, nil
}

var (
errNoMatchingIndex = errors.New("no index found matching criteria")
errMultipleMatchingIndices = errors.New("multiple indices match criteria")
)

// Index returns a single ImageIndex stored in f, that is selected by the provided
// Matcher. If more than one index matches, or no index matches, an error is
// returned.
Expand All @@ -86,10 +81,10 @@ func (f *OCIFileImage) Index(m match.Matcher, _ ...Option) (v1.ImageIndex, error
return nil, err
}
if len(matches) > 1 {
return nil, errMultipleMatchingIndices
return nil, ErrMultipleMatches
}
if len(matches) == 0 {
return nil, errNoMatchingIndex
return nil, ErrNoMatch
}

d, err := matches[0].Digest()
Expand Down

0 comments on commit f29715a

Please sign in to comment.