mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 08:23:15 +01:00
fix: add green fixes before pr fixes
Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
This commit is contained in:
parent
1a8562554a
commit
bfe63bb006
@ -178,13 +178,14 @@ func calculateTotalSize(layers []source.LayerMetadata) int64 {
|
||||
func deriveIDFromArtifact(cfg Config) artifact.ID {
|
||||
var info string
|
||||
|
||||
if !cfg.Alias.IsEmpty() {
|
||||
switch {
|
||||
case !cfg.Alias.IsEmpty():
|
||||
// Use alias for stable artifact ID
|
||||
info = fmt.Sprintf("%s@%s", cfg.Alias.Name, cfg.Alias.Version)
|
||||
} else if cfg.Metadata.ManifestDigest != "" {
|
||||
case cfg.Metadata.ManifestDigest != "":
|
||||
// Use manifest digest
|
||||
info = cfg.Metadata.ManifestDigest
|
||||
} else {
|
||||
default:
|
||||
// Fall back to reference
|
||||
log.Warn("no explicit name/version or manifest digest, deriving artifact ID from reference")
|
||||
info = cfg.Reference
|
||||
@ -255,6 +256,6 @@ func (s *ociModelSource) Close() error {
|
||||
}
|
||||
|
||||
// removeFile removes a file and logs any errors.
|
||||
func removeFile(path string) error {
|
||||
func removeFile(_ string) error {
|
||||
return nil // Placeholder for now
|
||||
}
|
||||
|
||||
@ -32,10 +32,7 @@ type RegistryClient struct {
|
||||
|
||||
// NewRegistryClient creates a new registry client with authentication from RegistryOptions.
|
||||
func NewRegistryClient(registryOpts *image.RegistryOptions) (*RegistryClient, error) {
|
||||
opts, err := buildRemoteOptions(registryOpts)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to build remote options: %w", err)
|
||||
}
|
||||
opts := buildRemoteOptions(registryOpts)
|
||||
|
||||
return &RegistryClient{
|
||||
options: opts,
|
||||
@ -43,11 +40,11 @@ func NewRegistryClient(registryOpts *image.RegistryOptions) (*RegistryClient, er
|
||||
}
|
||||
|
||||
// buildRemoteOptions converts stereoscope RegistryOptions to go-containerregistry remote.Options.
|
||||
func buildRemoteOptions(registryOpts *image.RegistryOptions) ([]remote.Option, error) {
|
||||
func buildRemoteOptions(registryOpts *image.RegistryOptions) []remote.Option {
|
||||
var opts []remote.Option
|
||||
|
||||
if registryOpts == nil {
|
||||
return opts, nil
|
||||
return opts
|
||||
}
|
||||
|
||||
// Build authenticator
|
||||
@ -66,7 +63,7 @@ func buildRemoteOptions(registryOpts *image.RegistryOptions) ([]remote.Option, e
|
||||
opts = append(opts, remote.WithTransport(http.DefaultTransport))
|
||||
}
|
||||
|
||||
return opts, nil
|
||||
return opts
|
||||
}
|
||||
|
||||
// buildAuthenticator creates an authn.Authenticator from RegistryOptions.
|
||||
@ -104,7 +101,7 @@ type ModelArtifact struct {
|
||||
}
|
||||
|
||||
// FetchModelArtifact fetches and parses an OCI model artifact from the registry.
|
||||
func (c *RegistryClient) FetchModelArtifact(ctx context.Context, refStr string) (*ModelArtifact, error) {
|
||||
func (c *RegistryClient) FetchModelArtifact(_ context.Context, refStr string) (*ModelArtifact, error) {
|
||||
// Parse reference
|
||||
ref, err := name.ParseReference(refStr)
|
||||
if err != nil {
|
||||
@ -176,7 +173,7 @@ func extractGGUFLayers(manifest *v1.Manifest) []v1.Descriptor {
|
||||
|
||||
// FetchBlobRange fetches a byte range from a blob in the registry.
|
||||
// This is used to fetch only the GGUF header without downloading the entire multi-GB file.
|
||||
func (c *RegistryClient) FetchBlobRange(ctx context.Context, ref name.Reference, digest v1.Hash, maxBytes int64) ([]byte, error) {
|
||||
func (c *RegistryClient) FetchBlobRange(_ context.Context, ref name.Reference, digest v1.Hash, maxBytes int64) ([]byte, error) {
|
||||
// Use the remote package's Layer fetching with our options
|
||||
// Then read only the first maxBytes
|
||||
repo := ref.Context()
|
||||
@ -207,7 +204,7 @@ func (c *RegistryClient) FetchBlobRange(ctx context.Context, ref name.Reference,
|
||||
|
||||
// IsModelArtifactReference checks if a reference points to a model artifact.
|
||||
// This is a lightweight check that only fetches the manifest.
|
||||
func (c *RegistryClient) IsModelArtifactReference(ctx context.Context, refStr string) (bool, error) {
|
||||
func (c *RegistryClient) IsModelArtifactReference(_ context.Context, refStr string) (bool, error) {
|
||||
ref, err := name.ParseReference(refStr)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("failed to parse reference %q: %w", refStr, err)
|
||||
|
||||
@ -127,14 +127,14 @@ func (r *ociModelResolver) FilesByGlob(patterns ...string) ([]file.Location, err
|
||||
|
||||
// FilesByMIMEType returns locations for files with the given MIME types.
|
||||
// This is not implemented for OCI model artifacts as we don't have MIME type detection.
|
||||
func (r *ociModelResolver) FilesByMIMEType(types ...string) ([]file.Location, error) {
|
||||
func (r *ociModelResolver) FilesByMIMEType(_ ...string) ([]file.Location, error) {
|
||||
// Not implemented - OCI model artifacts don't have MIME type detection
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// RelativeFileByPath returns a file at the given path relative to the reference location.
|
||||
// This is not applicable for OCI model artifacts.
|
||||
func (r *ociModelResolver) RelativeFileByPath(_ file.Location, path string) *file.Location {
|
||||
func (r *ociModelResolver) RelativeFileByPath(_ file.Location, _ string) *file.Location {
|
||||
// Not implemented - no layer hierarchy in OCI model artifacts
|
||||
return nil
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user