Use fs.FS
when explicitly given
#5312
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed changes
This updates
DiskCatalog
to usefs.FS
when explicitly given by a user viaNewFSCatalog
.The existing code half-used
fs.FS
, but there are a lot of issues with the existing implementation and what needs to be done. After doing a whole lot of testing (and concerns with golang/go#44279), I believe that the best possible implementation is a 2-track one: we support legacyos
operations by default, but if someone gives us anfs.FS
instance, then we'll use that exactly as they intended it.Long-term, I hope that the
fs.FS
semantics are fixed by Go (or at least that a meaningful package gets built that provides full backward compatibility with theos
operations).In my particular case, I have two use cases that both work with these changes:
NewCatalog
.NewFSCatalog
with github.com/quay/claircore/pkg/tarfs to provide thefs.FS
interface.Checklist