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