Description
The logic to extract filepath from layer annotations is duplicated in 3+ files:
pkg/backend/fetch.go
pkg/backend/fetch_by_d7y.go
pkg/backend/pull_by_d7y.go
var annoFilepath string
if desc.Annotations != nil {
if desc.Annotations[modelspec.AnnotationFilepath] != "" {
annoFilepath = desc.Annotations[modelspec.AnnotationFilepath]
} else {
annoFilepath = desc.Annotations[legacymodelspec.AnnotationFilepath]
}
}
Suggested Fix
Extract into a shared helper in the backend package:
func getAnnotationFilepath(annotations map[string]string) string {
if annotations == nil {
return ""
}
if path := annotations[modelspec.AnnotationFilepath]; path != "" {
return path
}
return annotations[legacymodelspec.AnnotationFilepath]
}
Context
Found during code review of #468. This is a pre-existing pattern, not introduced by that PR.
Description
The logic to extract filepath from layer annotations is duplicated in 3+ files:
pkg/backend/fetch.gopkg/backend/fetch_by_d7y.gopkg/backend/pull_by_d7y.goSuggested Fix
Extract into a shared helper in the
backendpackage:Context
Found during code review of #468. This is a pre-existing pattern, not introduced by that PR.