-
Notifications
You must be signed in to change notification settings - Fork 63
Open
Description
In the model-spec, org.cncf.model.filepath annotation is supposed to be used as a file path when mounting.
However libartifact can only use org.opencontainers.image.title as a file path.
container-libs/common/pkg/libartifact/store/store.go
Lines 440 to 495 in c780818
| // BlobMountPaths allows the caller to access the file names from the store and how they should be mounted. | |
| func (as ArtifactStore) BlobMountPaths(ctx context.Context, nameOrDigest string, options *libartTypes.BlobMountPathOptions) ([]libartTypes.BlobMountPath, error) { | |
| arty, imgSrc, err := getArtifactAndImageSource(ctx, as, nameOrDigest, &options.FilterBlobOptions) | |
| if err != nil { | |
| return nil, err | |
| } | |
| defer imgSrc.Close() | |
| if len(options.Digest) > 0 || len(options.Title) > 0 { | |
| digest, err := findDigest(arty, &options.FilterBlobOptions) | |
| if err != nil { | |
| return nil, err | |
| } | |
| // In case the digest is set we always use it as target name | |
| // so we do not have to get the actual title annotation form the blob. | |
| // Passing options.Title is enough because we know it is empty when digest | |
| // is set as we only allow either one. | |
| filename, err := generateArtifactBlobName(options.Title, digest) | |
| if err != nil { | |
| return nil, err | |
| } | |
| path, err := layout.GetLocalBlobPath(ctx, imgSrc, digest) | |
| if err != nil { | |
| return nil, err | |
| } | |
| return []libartTypes.BlobMountPath{{ | |
| SourcePath: path, | |
| Name: filename, | |
| }}, nil | |
| } | |
| mountPaths := make([]libartTypes.BlobMountPath, 0, len(arty.Manifest.Layers)) | |
| for _, l := range arty.Manifest.Layers { | |
| title := l.Annotations[specV1.AnnotationTitle] | |
| for _, mp := range mountPaths { | |
| if title == mp.Name { | |
| return nil, fmt.Errorf("annotation %q:%q is used in multiple different layers within artifact", specV1.AnnotationTitle, title) | |
| } | |
| } | |
| filename, err := generateArtifactBlobName(title, l.Digest) | |
| if err != nil { | |
| return nil, err | |
| } | |
| path, err := layout.GetLocalBlobPath(ctx, imgSrc, l.Digest) | |
| if err != nil { | |
| return nil, err | |
| } | |
| mountPaths = append(mountPaths, libartTypes.BlobMountPath{ | |
| SourcePath: path, | |
| Name: filename, | |
| }) | |
| } | |
| return mountPaths, nil | |
| } |
I'm not sure what is the best way though.
Off the top of my head, BlobMountPaths could accept file path annotation as an argument, or we could introduce a new option for filepath.
Do you have any plan to use org.cncf.model.filepath as a file path?
The past discussion regarding the file path annotation: modelpack/model-spec#58
Metadata
Metadata
Assignees
Labels
No labels