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
|
// Extract virtual path from annotations
|
||||||
virtualPath := extractVirtualPath(idx, extractAnnotations(layer.Annotations))
|
virtualPath := extractVirtualPath(idx)
|
||||||
|
|
||||||
// Create temp file
|
// Create temp file
|
||||||
tempPath, err := createTempFileFromData(headerData, virtualPath)
|
tempPath, err := createTempFileFromData(headerData, virtualPath)
|
||||||
|
|||||||
@ -14,13 +14,7 @@ func TestExtractVirtualPath(t *testing.T) {
|
|||||||
expected string
|
expected string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "with title annotation",
|
name: "use index as model layer virtual path",
|
||||||
layerIndex: 0,
|
|
||||||
annotations: map[string]string{"org.opencontainers.image.title": "model.gguf"},
|
|
||||||
expected: "/model.gguf",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "without title annotation",
|
|
||||||
layerIndex: 1,
|
layerIndex: 1,
|
||||||
annotations: map[string]string{},
|
annotations: map[string]string{},
|
||||||
expected: "/model-layer-1.gguf",
|
expected: "/model-layer-1.gguf",
|
||||||
@ -29,7 +23,7 @@ func TestExtractVirtualPath(t *testing.T) {
|
|||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
result := extractVirtualPath(tt.layerIndex, tt.annotations)
|
result := extractVirtualPath(tt.layerIndex)
|
||||||
assert.Equal(t, tt.expected, result)
|
assert.Equal(t, tt.expected, result)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,9 +8,9 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
stereofile "github.com/anchore/stereoscope/pkg/file"
|
|
||||||
"github.com/bmatcuk/doublestar/v4"
|
"github.com/bmatcuk/doublestar/v4"
|
||||||
|
|
||||||
|
stereofile "github.com/anchore/stereoscope/pkg/file"
|
||||||
"github.com/anchore/syft/syft/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.
|
// extractVirtualPath generates a virtual path for a GGUF layer.
|
||||||
// This simulates where the file would be in the artifact.
|
// This simulates where the file would be in the artifact.
|
||||||
func extractVirtualPath(layerIndex int, annotations map[string]string) string {
|
func extractVirtualPath(layerIndex int) 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
|
|
||||||
return fmt.Sprintf("/model-layer-%d.gguf", layerIndex)
|
return fmt.Sprintf("/model-layer-%d.gguf", layerIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user