Skip to content

Commit

Permalink
fix: added warning for dangling referrers index deletion (#619)
Browse files Browse the repository at this point in the history
This PR tries to resolve #615.

---------

Signed-off-by: Patrick Zheng <[email protected]>
  • Loading branch information
Two-Hearts authored Apr 13, 2023
1 parent 24a9719 commit 2841abe
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions cmd/notation/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"os"
"strings"
"time"

"github.com/notaryproject/notation-go"
Expand All @@ -22,6 +23,8 @@ const (
signatureManifestImage = "image"
)

const referrersTagSchemaDeleteError = "failed to delete dangling referrers index"

var supportedSignatureManifest = []string{signatureManifestArtifact, signatureManifestImage}

type signOpts struct {
Expand Down Expand Up @@ -112,8 +115,16 @@ func runSign(command *cobra.Command, cmdOpts *signOpts) error {
_, err = notation.Sign(ctx, signer, sigRepo, opts)
if err != nil {
var errorPushSignatureFailed notation.ErrorPushSignatureFailed
if errors.As(err, &errorPushSignatureFailed) && !ociImageManifest {
return fmt.Errorf("%v. Possible reason: target registry does not support OCI artifact manifest. Try removing the flag `--signature-manifest artifact` to store signatures using OCI image manifest", err)
if errors.As(err, &errorPushSignatureFailed) {
if !ociImageManifest {
return fmt.Errorf("%v. Possible reason: target registry does not support OCI artifact manifest. Try removing the flag `--signature-manifest artifact` to store signatures using OCI image manifest", err)
}
if strings.Contains(err.Error(), referrersTagSchemaDeleteError) {
fmt.Fprintln(os.Stderr, "Warning: Removal of outdated referrers index is not supported by the remote registry. Garbage collection may be required.")
// write out
fmt.Println("Successfully signed", ref)
return nil
}
}
return err
}
Expand Down

0 comments on commit 2841abe

Please sign in to comment.