-
Notifications
You must be signed in to change notification settings - Fork 674
Add ability to scan snaps (as a source) #3929
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
Conversation
8c085cf
to
f96fce4
Compare
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
a9e940d
to
c83be08
Compare
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
I'm seeing this a lot:
Yet:
|
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
@popey pointed out that there are region locked snaps that fail with obtuse errors:
We should probably use the search API to resolve an exact name match then extract the download link from there (search with
|
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
e12ee6f
to
8e106cc
Compare
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
r.mu.Lock() | ||
defer r.mu.Unlock() | ||
|
||
currentPos, err := r.Seek(0, io.SeekCurrent) |
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 should probably be tracked when the reader is created -- I don't think getting current position here will always be the right thing to do. I think this existing seekable reader behavior is close, albeit it's not ReaderAt but ReadSeeker:
func SeekableReader(reader io.Reader) (io.ReadSeeker, error) { |
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 is attempting to adapt the seeking ability (stateful) with a reader-at like experience (stateless), but doing so affects the pointer into the file, which would affect subsequent reads and seeks, so the first step is to keep the original position in order to restore it later in this call.
I think there is a problem in the sense that we are only locking for ReadAt, which in hindsight doesn't make sense because we're not locking for other operations.
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.
Let's say I have this reader, and I call .Read(bytes)
and then I call .ReadAt(0,...)
, it will not have the correct starting position of the reader. I think, if we track the starting position when this custom reader is created, it should be reasonably assumed to be the "start of the stream". Happy to chat on this further, I was just pointing out it's a similar problem to the other reader I mentioned above
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.
The definition of ReaderAt is that the offset is absolute, not relative to any other read calls --we're only preserving the pointer state for other read/seek calls. That is, it could be that the file pointer is specifically there to subset a selection of the file, in which case the underlying reader should be wrapped with io.SectionReader or similar, where subsetting is explicit (and you can get the underlying non-section reader with .Outer()
). However, us creating this wrapper around a io.ReadSeeker should not implicitly mean that we are intending to act like a io.SectionReader.
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.
tangent, I did update this to account for locking for other read/seek calls
} | ||
|
||
func deriveID(path, name, version string) artifact.ID { | ||
info := fmt.Sprintf("%s:%s@%s", digestOfFileContents(path), name, version) |
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.
seems like path.Base(path)
might be a useful default here somewhere? and usually config aliases aren't set so name and version will be empty. e.g. <name | filename>@<version | hash>
or something? this may not make a bit of difference, I didn't quite understand what the id
is used for
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.
the goal is to get a stable ID for the source when making relationships between other elements (packages / files) and the source.
Ideally this is content addressable -- regardless of the name of the file or any aliases used, we will get the same ID for the same file every time. However, we've found that for other kinds of sources that if there is a different logical name or version then we should have separate IDs.
This is mimicking the ID derivation from the file source.
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.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 adds support for cataloging single snap files, cataloging all contents. This can scan a local snap file:
or grab the snap from snapcraft:
Note: if
--platform
is given an OS then the source will error out and not continue (as this is not a valid form).Type of change
Checklist
TODO
snap/manifest.yaml
and surrounding data ontosource.Metadata
install
cataloger set is being used for this new source