Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: improving error log for oras push and oras attach when the annotation file is invalid #1026

Merged
merged 13 commits into from
Jul 27, 2023
8 changes: 7 additions & 1 deletion cmd/oras/internal/option/packer.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,13 @@ func (opts *Packer) LoadManifestAnnotations() (annotations map[string]map[string
}
if opts.AnnotationFilePath != "" {
if err = decodeJSON(opts.AnnotationFilePath, &annotations); err != nil {
return nil, err
errStr := err.Error()
docLink := " Please refer to the document at https://oras.land/docs/how_to_guides/manifest_annotations."
if !strings.HasSuffix(errStr, ".") {
docLink = "."+docLink
}
return nil, fmt.Errorf("failed to load annotations from %s: %w" +
docLink, opts.AnnotationFilePath, err)
}
}
if len(opts.ManifestAnnotations) != 0 {
Expand Down