mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 08:23:15 +01:00
fix: update after rebase
Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
This commit is contained in:
parent
ec978f01c5
commit
1a8562554a
@ -53,7 +53,7 @@ func NewFromArtifact(artifact *ModelArtifact, client *RegistryClient, alias sour
|
||||
}
|
||||
|
||||
// Extract virtual path from annotations
|
||||
virtualPath := extractVirtualPath(idx, extractAnnotations(layer.Annotations))
|
||||
virtualPath := extractVirtualPath(idx)
|
||||
|
||||
// Create temp file
|
||||
tempPath, err := createTempFileFromData(headerData, virtualPath)
|
||||
|
||||
@ -14,13 +14,7 @@ func TestExtractVirtualPath(t *testing.T) {
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
name: "with title annotation",
|
||||
layerIndex: 0,
|
||||
annotations: map[string]string{"org.opencontainers.image.title": "model.gguf"},
|
||||
expected: "/model.gguf",
|
||||
},
|
||||
{
|
||||
name: "without title annotation",
|
||||
name: "use index as model layer virtual path",
|
||||
layerIndex: 1,
|
||||
annotations: map[string]string{},
|
||||
expected: "/model-layer-1.gguf",
|
||||
@ -29,7 +23,7 @@ func TestExtractVirtualPath(t *testing.T) {
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
result := extractVirtualPath(tt.layerIndex, tt.annotations)
|
||||
result := extractVirtualPath(tt.layerIndex)
|
||||
assert.Equal(t, tt.expected, result)
|
||||
})
|
||||
}
|
||||
|
||||
@ -8,9 +8,9 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
stereofile "github.com/anchore/stereoscope/pkg/file"
|
||||
"github.com/bmatcuk/doublestar/v4"
|
||||
|
||||
stereofile "github.com/anchore/stereoscope/pkg/file"
|
||||
"github.com/anchore/syft/syft/file"
|
||||
)
|
||||
|
||||
@ -177,16 +177,7 @@ func (r *ociModelResolver) cleanup() error {
|
||||
|
||||
// extractVirtualPath generates a virtual path for a GGUF layer.
|
||||
// This simulates where the file would be in the artifact.
|
||||
func extractVirtualPath(layerIndex int, annotations map[string]string) string {
|
||||
// Check if there's a title annotation that specifies the filename
|
||||
if title, ok := annotations["org.opencontainers.image.title"]; ok && title != "" {
|
||||
// Ensure it starts with /
|
||||
if !strings.HasPrefix(title, "/") {
|
||||
return "/" + title
|
||||
}
|
||||
return title
|
||||
}
|
||||
// Fall back to default naming
|
||||
func extractVirtualPath(layerIndex int) string {
|
||||
return fmt.Sprintf("/model-layer-%d.gguf", layerIndex)
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user