fix: add green fixes before pr fixes

Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
This commit is contained in:
Christopher Phillips 2025-11-13 01:59:46 -05:00
parent 1a8562554a
commit bfe63bb006
No known key found for this signature in database
3 changed files with 14 additions and 16 deletions

View File

@ -178,13 +178,14 @@ func calculateTotalSize(layers []source.LayerMetadata) int64 {
func deriveIDFromArtifact(cfg Config) artifact.ID { func deriveIDFromArtifact(cfg Config) artifact.ID {
var info string var info string
if !cfg.Alias.IsEmpty() { switch {
case !cfg.Alias.IsEmpty():
// Use alias for stable artifact ID // Use alias for stable artifact ID
info = fmt.Sprintf("%s@%s", cfg.Alias.Name, cfg.Alias.Version) info = fmt.Sprintf("%s@%s", cfg.Alias.Name, cfg.Alias.Version)
} else if cfg.Metadata.ManifestDigest != "" { case cfg.Metadata.ManifestDigest != "":
// Use manifest digest // Use manifest digest
info = cfg.Metadata.ManifestDigest info = cfg.Metadata.ManifestDigest
} else { default:
// Fall back to reference // Fall back to reference
log.Warn("no explicit name/version or manifest digest, deriving artifact ID from reference") log.Warn("no explicit name/version or manifest digest, deriving artifact ID from reference")
info = cfg.Reference info = cfg.Reference
@ -255,6 +256,6 @@ func (s *ociModelSource) Close() error {
} }
// removeFile removes a file and logs any errors. // removeFile removes a file and logs any errors.
func removeFile(path string) error { func removeFile(_ string) error {
return nil // Placeholder for now return nil // Placeholder for now
} }

View File

@ -32,10 +32,7 @@ type RegistryClient struct {
// NewRegistryClient creates a new registry client with authentication from RegistryOptions. // NewRegistryClient creates a new registry client with authentication from RegistryOptions.
func NewRegistryClient(registryOpts *image.RegistryOptions) (*RegistryClient, error) { func NewRegistryClient(registryOpts *image.RegistryOptions) (*RegistryClient, error) {
opts, err := buildRemoteOptions(registryOpts) opts := buildRemoteOptions(registryOpts)
if err != nil {
return nil, fmt.Errorf("failed to build remote options: %w", err)
}
return &RegistryClient{ return &RegistryClient{
options: opts, options: opts,
@ -43,11 +40,11 @@ func NewRegistryClient(registryOpts *image.RegistryOptions) (*RegistryClient, er
} }
// buildRemoteOptions converts stereoscope RegistryOptions to go-containerregistry remote.Options. // 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 var opts []remote.Option
if registryOpts == nil { if registryOpts == nil {
return opts, nil return opts
} }
// Build authenticator // Build authenticator
@ -66,7 +63,7 @@ func buildRemoteOptions(registryOpts *image.RegistryOptions) ([]remote.Option, e
opts = append(opts, remote.WithTransport(http.DefaultTransport)) opts = append(opts, remote.WithTransport(http.DefaultTransport))
} }
return opts, nil return opts
} }
// buildAuthenticator creates an authn.Authenticator from RegistryOptions. // 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. // 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 // Parse reference
ref, err := name.ParseReference(refStr) ref, err := name.ParseReference(refStr)
if err != nil { 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. // 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. // 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 // Use the remote package's Layer fetching with our options
// Then read only the first maxBytes // Then read only the first maxBytes
repo := ref.Context() 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. // IsModelArtifactReference checks if a reference points to a model artifact.
// This is a lightweight check that only fetches the manifest. // 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) ref, err := name.ParseReference(refStr)
if err != nil { if err != nil {
return false, fmt.Errorf("failed to parse reference %q: %w", refStr, err) return false, fmt.Errorf("failed to parse reference %q: %w", refStr, err)

View File

@ -127,14 +127,14 @@ func (r *ociModelResolver) FilesByGlob(patterns ...string) ([]file.Location, err
// FilesByMIMEType returns locations for files with the given MIME types. // 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. // 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 // Not implemented - OCI model artifacts don't have MIME type detection
return nil, nil return nil, nil
} }
// RelativeFileByPath returns a file at the given path relative to the reference location. // RelativeFileByPath returns a file at the given path relative to the reference location.
// This is not applicable for OCI model artifacts. // 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 // Not implemented - no layer hierarchy in OCI model artifacts
return nil return nil
} }