mirror of
https://github.com/project-zot/zot.git
synced 2026-06-16 20:38:08 +08:00
feat(routes): better error message in case of missing annotations (#1150)
putting this info into error detail would be ideal, but skopeo doesn't print them, so overwrite the error message. Signed-off-by: Petu Eusebiu <peusebiu@cisco.com>
This commit is contained in:
@@ -5,10 +5,13 @@ package lint
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
godigest "github.com/opencontainers/go-digest"
|
||||
ispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
zerr "zotregistry.io/zot/errors"
|
||||
"zotregistry.io/zot/pkg/extensions/config"
|
||||
"zotregistry.io/zot/pkg/log"
|
||||
"zotregistry.io/zot/pkg/storage"
|
||||
@@ -98,10 +101,11 @@ func (linter *Linter) CheckMandatoryAnnotations(repo string, manifestDigest godi
|
||||
|
||||
missingAnnotations = getMissingAnnotations(mandatoryAnnotationsMap)
|
||||
if len(missingAnnotations) > 0 {
|
||||
linter.log.Error().Msgf("linter: manifest %s / config %s are missing annotations: %s",
|
||||
msg := fmt.Sprintf("\nlinter: manifest %s\nor config %s\nis missing the next annotations: %s",
|
||||
string(manifestDigest), string(configDigest), missingAnnotations)
|
||||
linter.log.Error().Msg(msg)
|
||||
|
||||
return false, nil
|
||||
return false, errors.WithMessage(zerr.ErrImageLintAnnotations, msg)
|
||||
}
|
||||
|
||||
return true, nil
|
||||
|
||||
@@ -636,7 +636,7 @@ func TestVerifyMandatoryAnnotationsFunction(t *testing.T) {
|
||||
log.NewLogger("debug", ""), monitoring.NewMetricsServer(false, log.NewLogger("debug", "")), linter, nil)
|
||||
|
||||
pass, err := linter.CheckMandatoryAnnotations("zot-test", digest, imgStore)
|
||||
So(err, ShouldBeNil)
|
||||
So(err, ShouldNotBeNil)
|
||||
So(pass, ShouldBeFalse)
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user