mirror of
https://github.com/containers/podman.git
synced 2025-10-13 09:15:20 +08:00
Merge pull request #27142 from nothiaki/feat-artifact-rm-ignore
Feat artifact rm ignore
This commit is contained in:
@ -96,6 +96,8 @@ type ArtifactRemoveOptions struct {
|
||||
All bool
|
||||
// Artifacts is a list of Artifact IDs or names to remove
|
||||
Artifacts []string
|
||||
// Ignore if a specified artifact does not exist and do not throw any error.
|
||||
Ignore bool
|
||||
}
|
||||
|
||||
type ArtifactRemoveReport = entitiesTypes.ArtifactRemoveReport
|
||||
|
@ -4,6 +4,7 @@ package abi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
@ -12,6 +13,7 @@ import (
|
||||
"github.com/containers/podman/v5/pkg/domain/entities"
|
||||
"github.com/containers/podman/v5/pkg/libartifact/types"
|
||||
"github.com/opencontainers/go-digest"
|
||||
"github.com/sirupsen/logrus"
|
||||
"go.podman.io/common/libimage"
|
||||
)
|
||||
|
||||
@ -124,6 +126,10 @@ func (ir *ImageEngine) ArtifactRm(ctx context.Context, opts entities.ArtifactRem
|
||||
for _, namesOrDigest := range namesOrDigests {
|
||||
artifactDigest, err := artStore.Remove(ctx, namesOrDigest)
|
||||
if err != nil {
|
||||
if opts.Ignore && errors.Is(err, types.ErrArtifactNotExist) {
|
||||
logrus.Debugf("Artifact with name or digest %q does not exist, ignoring error as request", namesOrDigest)
|
||||
continue
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
artifactDigests = append(artifactDigests, artifactDigest)
|
||||
|
@ -57,6 +57,7 @@ func (ir *ImageEngine) ArtifactRm(_ context.Context, opts entities.ArtifactRemov
|
||||
removeOptions := artifacts.RemoveOptions{
|
||||
All: &opts.All,
|
||||
Artifacts: opts.Artifacts,
|
||||
Ignore: &opts.Ignore,
|
||||
}
|
||||
|
||||
return artifacts.Remove(ir.ClientCtx, "", &removeOptions)
|
||||
|
Reference in New Issue
Block a user