-
Notifications
You must be signed in to change notification settings - Fork 22
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
DirectoryTree download support #358
Conversation
With the following component:
I find that I have to use memfs := memoryfs.New()
_, _, err = dirtree.New().Download(common.NewPrinter(io.Discard), res, "", memfs)
if err != nil {
log.Fatal(err)
}
vfs.Walk(memfs, "", func(path string, info fs.FileInfo, err error) error {
fmt.Println(info.Name(), info.IsDir())
return nil
}} From reading the PR I believe it should be possible to simply execute |
@phoban01 If you use If you use So, if you want to use an own resource type (directly expressing the dedicated new meaning of a general filesystem content), for example
If, for example Another possible scenario, where you might want to use the explicit |
Thanks for the explanation @mandelsoft. My assumption was that handlers for built-in OCM types would be registered by default but it seems that I need to explicitly register handlers which is fine. |
Yes, for builtin types they should already be registered. So far for dirtree-like types, this is only @phoban01: What about |
I don't personally ever use this type |
@phoban01 , may be you could approve this PR, It just added the explanation to the docu of the |
* oci image dirtree downloader * cleanup reader handling for artifactset * archive downloader for dirtree * adapt localization to dirtree downloader * get rid of os package when working with vfs * add dirtree downloader docu
What this PR does / why we need it:
The standard configuration now provides a downloader for resources of type
directoryTree
and the legacy typefilesystem
.It acts on the mimetypes for an artifact set (
application/vnd.oci.image.manifest.v1+tar+gzip
) and a tar/tgz archive (application/x-tar
,application/x-tar+gzip
,application/x-tgz
). The default configuration extracts the content to afilesystem folder. If the blob format is an artifact set, for example provided by the access method
ociArtifact
,the default configuration accepts the image config mimetype (
application/vnd.oci.image.config.v1+json
).In this case the final filesystem content provided by the image is download by evaluating the layered image file system.
The default behaviour can just be used with
If the resource access describes an appropriate artifact, the new handler is automatically selected.
As usual, the target is always a virtual filesystem.
Like all download handlers. the dirtree download handler can also explicitly be used with
In this mode, the behaviour can be influenced by specifying any list of accepted OCI artifact config mime types.
With
New(mimetypes ...string).SetArchiveMode(true)
it is possible to enable the archive target mode. The content is downloaded to an archive instead of extracted filesystem content.The handler checks the mimetypes, only, but the default registration is done exclusively for the directory content resource types.
A context can be extended for other resource types with
The handler also provides additional methods, which can be used to execute more specific tasks, for example
methods for an optimized content access providing an internal virtual filesystem or an archive byte stream trying to avoid unnecessary conversions depending on the actual input format,
The localization package has been adapted, accordingly. The
localize.Instantiate
method now prefers to use thedownload handlers to get to the filesystem content to be configured, instead of expecting an archive resource.
Therefore, any (potentially own) resource type with any format can be used, as long as there is an appropriate downloader configured for the used OCM context. An optional additional parameter can be used to restrict the accepted resource types
to an explicitly given set of types.
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Release Notes: