From 0d5b465739ee8bea8ff034bb6c04dc68492c13ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Tue, 12 Nov 2024 17:50:57 +0100 Subject: [PATCH] Move JSONFormatToInvalidSignatureError to an unconditionally-included file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit otherwise: > % go build -tags ' containers_image_fulcio_stub containers_image_rekor_stub' ./... > # github.com/containers/image/v5/signature/internal > signature/internal/sigstore_payload.go:83:9: undefined: JSONFormatToInvalidSignatureError Signed-off-by: Miloslav Trmač --- signature/internal/errors.go | 9 +++++++++ signature/internal/rekor_set.go | 9 --------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/signature/internal/errors.go b/signature/internal/errors.go index 7872f0f43c..d21e8544d4 100644 --- a/signature/internal/errors.go +++ b/signature/internal/errors.go @@ -13,3 +13,12 @@ func (err InvalidSignatureError) Error() string { func NewInvalidSignatureError(msg string) InvalidSignatureError { return InvalidSignatureError{msg: msg} } + +// JSONFormatToInvalidSignatureError converts JSONFormatError to InvalidSignatureError. +// All other errors are returned as is. +func JSONFormatToInvalidSignatureError(err error) error { + if formatErr, ok := err.(JSONFormatError); ok { + err = NewInvalidSignatureError(formatErr.Error()) + } + return err +} diff --git a/signature/internal/rekor_set.go b/signature/internal/rekor_set.go index bddaca690b..2b024af652 100644 --- a/signature/internal/rekor_set.go +++ b/signature/internal/rekor_set.go @@ -40,15 +40,6 @@ type UntrustedRekorPayload struct { // A compile-time check that UntrustedRekorSET implements json.Unmarshaler var _ json.Unmarshaler = (*UntrustedRekorSET)(nil) -// JSONFormatToInvalidSignatureError converts JSONFormatError to InvalidSignatureError. -// All other errors are returned as is. -func JSONFormatToInvalidSignatureError(err error) error { - if formatErr, ok := err.(JSONFormatError); ok { - err = NewInvalidSignatureError(formatErr.Error()) - } - return err -} - // UnmarshalJSON implements the json.Unmarshaler interface func (s *UntrustedRekorSET) UnmarshalJSON(data []byte) error { return JSONFormatToInvalidSignatureError(s.strictUnmarshalJSON(data))