Skip to content

Commit 9fd77f2

Browse files
committed
fix: check tag or digest before remove the manifest
Signed-off-by: chlins <[email protected]>
1 parent b639231 commit 9fd77f2

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

pkg/backend/rm.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ func (b *backend) Remove(ctx context.Context, target string) (string, error) {
3636
reference = ref.Digest()
3737
}
3838

39+
if reference == "" {
40+
return "", fmt.Errorf("invalid reference, tag or digest must be provided")
41+
}
42+
3943
if err := b.store.DeleteManifest(ctx, repo, reference); err != nil {
4044
return "", fmt.Errorf("failed to delete manifest %s: %w", reference, err)
4145
}

pkg/storage/distribution/distribution.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
sha256 "github.com/minio/sha256-simd"
3131
godigest "github.com/opencontainers/go-digest"
3232
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
33+
"github.com/sirupsen/logrus"
3334
)
3435

3536
func init() {
@@ -55,6 +56,9 @@ type storage struct {
5556
}
5657

5758
func NewStorage(rootDir string) (*storage, error) {
59+
// Mute the logging from distribution.
60+
logrus.SetOutput(io.Discard)
61+
5862
fsDriver := filesystem.New(filesystem.DriverParameters{
5963
RootDirectory: rootDir,
6064
MaxThreads: defaultMaxThreads,

0 commit comments

Comments
 (0)