mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 00:13: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
@ -6,20 +6,20 @@ import "github.com/anchore/syft/syft/source"
|
||||
// This is similar to ImageMetadata but includes model-specific fields and OCI artifact annotations.
|
||||
type OCIModelMetadata struct {
|
||||
// Core OCI artifact metadata (mirrors ImageMetadata)
|
||||
UserInput string `json:"userInput"`
|
||||
ID string `json:"artifactID"`
|
||||
ManifestDigest string `json:"manifestDigest"`
|
||||
MediaType string `json:"mediaType"`
|
||||
Tags []string `json:"tags"`
|
||||
Size int64 `json:"artifactSize"`
|
||||
Layers []source.LayerMetadata `json:"layers"`
|
||||
RawManifest []byte `json:"manifest"`
|
||||
RawConfig []byte `json:"config"`
|
||||
RepoDigests []string `json:"repoDigests"`
|
||||
Architecture string `json:"architecture"`
|
||||
Variant string `json:"architectureVariant,omitempty"`
|
||||
OS string `json:"os"`
|
||||
Labels map[string]string `json:"labels,omitempty"`
|
||||
UserInput string `json:"userInput"`
|
||||
ID string `json:"artifactID"`
|
||||
ManifestDigest string `json:"manifestDigest"`
|
||||
MediaType string `json:"mediaType"`
|
||||
Tags []string `json:"tags"`
|
||||
Size int64 `json:"artifactSize"`
|
||||
Layers []source.LayerMetadata `json:"layers"`
|
||||
RawManifest []byte `json:"manifest"`
|
||||
RawConfig []byte `json:"config"`
|
||||
RepoDigests []string `json:"repoDigests"`
|
||||
Architecture string `json:"architecture"`
|
||||
Variant string `json:"architectureVariant,omitempty"`
|
||||
OS string `json:"os"`
|
||||
Labels map[string]string `json:"labels,omitempty"`
|
||||
|
||||
// OCI-specific metadata
|
||||
Annotations map[string]string `json:"annotations,omitempty"`
|
||||
@ -32,8 +32,8 @@ type OCIModelMetadata struct {
|
||||
// GGUFLayerInfo represents metadata about a GGUF layer in the OCI artifact.
|
||||
type GGUFLayerInfo struct {
|
||||
Digest string `json:"digest"`
|
||||
Size int64 `json:"size"` // Full blob size in registry
|
||||
MediaType string `json:"mediaType"` // Should be "application/vnd.docker.ai.gguf.v3"
|
||||
Size int64 `json:"size"` // Full blob size in registry
|
||||
MediaType string `json:"mediaType"` // Should be "application/vnd.docker.ai.gguf.v3"
|
||||
Annotations map[string]string `json:"annotations,omitempty"`
|
||||
FetchedBytes int64 `json:"fetchedBytes"` // How many bytes we actually fetched via range-GET
|
||||
}
|
||||
|
||||
@ -18,12 +18,12 @@ var _ source.Source = (*ociModelSource)(nil)
|
||||
|
||||
// Config holds the configuration for an OCI model artifact source.
|
||||
type Config struct {
|
||||
Reference string
|
||||
Platform string
|
||||
Alias source.Alias
|
||||
Client *RegistryClient
|
||||
Metadata *OCIModelMetadata
|
||||
TempFiles map[string]string // Virtual path -> temp file path
|
||||
Reference string
|
||||
Platform string
|
||||
Alias source.Alias
|
||||
Client *RegistryClient
|
||||
Metadata *OCIModelMetadata
|
||||
TempFiles map[string]string // Virtual path -> temp file path
|
||||
}
|
||||
|
||||
// ociModelSource implements the source.Source interface for OCI model artifacts.
|
||||
@ -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)
|
||||
}
|
||||
|
||||
|
||||
@ -13,11 +13,11 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
FileTag = stereoscope.FileTag
|
||||
DirTag = stereoscope.DirTag
|
||||
PullTag = stereoscope.PullTag
|
||||
SnapTag = "snap"
|
||||
OCIModelTag = "oci-model"
|
||||
FileTag = stereoscope.FileTag
|
||||
DirTag = stereoscope.DirTag
|
||||
PullTag = stereoscope.PullTag
|
||||
SnapTag = "snap"
|
||||
OCIModelTag = "oci-model"
|
||||
)
|
||||
|
||||
// All returns all the configured source providers known to syft
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user