-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ruby: support gemspec #836
Conversation
996ffe6
to
6f21125
Compare
I can make more tests in a bit, but I wanted to open this up for review anyway |
afd694f
to
5d52017
Compare
ruby/testdata/rails.tar
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand this is pretty large, but I'm not sure a better way to do this. I think we should have a Quay repo we can use for test images
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could try making use of the fetch.Layer()
functionality as we do here: https://github.com/quay/claircore/blob/main/rpm/packagescanner_test.go#L1616. We already have https://quay.io/repository/projectquay/clair-fixtures I can skopeo cp as needed and/give you access to push (if you don't have it).
ruby/packagescanner.go
Outdated
func gems(ctx context.Context, sys fs.FS) (out []string, err error) { | ||
return out, fs.WalkDir(sys, ".", func(p string, d fs.DirEntry, err error) error { | ||
ev := zlog.Debug(ctx). | ||
Str("file", p) | ||
switch { | ||
case err != nil: | ||
ev.Discard().Send() | ||
return err | ||
case !d.Type().IsRegular(): | ||
ev.Discard().Send() | ||
// Should we chase symlinks with the correct name? | ||
return nil | ||
case strings.HasPrefix(filepath.Base(p), ".wh."): | ||
ev.Discard().Send() | ||
return nil | ||
case gemspecPath.MatchString(p): | ||
ev = ev.Str("kind", "gem") | ||
default: | ||
ev.Discard().Send() | ||
return nil | ||
} | ||
ev.Msg("found package") | ||
out = append(out, p) | ||
return nil | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do something like this to avoid the inevitable "add a case, forget to Discard"?
func gems(ctx context.Context, sys fs.FS) (out []string, err error) {
return out, fs.WalkDir(sys, ".", func(p string, d fs.DirEntry, err error) error {
ev := zlog.Debug(ctx).
Str("file", p)
defer func() {
ev.Discard().Send()
}()
switch {
case err != nil:
return err
case !d.Type().IsRegular():
// Should we chase symlinks with the correct name?
return nil
case strings.HasPrefix(filepath.Base(p), ".wh."):
return nil
case gemspecPath.MatchString(p):
ev = ev.Str("kind", "gem")
default:
return nil
}
ev.Msg("found package")
out = append(out, p)
return nil
})
}
ruby/testdata/rails.tar
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could try making use of the fetch.Layer()
functionality as we do here: https://github.com/quay/claircore/blob/main/rpm/packagescanner_test.go#L1616. We already have https://quay.io/repository/projectquay/clair-fixtures I can skopeo cp as needed and/give you access to push (if you don't have it).
67c4940
to
9d44029
Compare
1cfca4e
to
e829d59
Compare
Signed-off-by: RTann <rtannenb@redhat.com>
Signed-off-by: RTann <rtannenb@redhat.com>
Signed-off-by: RTann <rtannenb@redhat.com>
Signed-off-by: RTann <rtannenb@redhat.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks pending a rewrite down to a single commit
not sure I follow? |
oh I misread at first. Thought you said "comment" not "commit". Is that needed? Wouldn't |
oh, I suppose it would. It does skip all the commit lints though, so make sure to keep a |
No description provided.