-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Description
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.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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels