소스 검색

Merge pull request #46405 from rumpl/image-events

Djordje Lukic 1 년 전
부모
커밋
2c95ddf4f3
3개의 변경된 파일10개의 추가작업 그리고 0개의 파일을 삭제
  1. 2 0
      daemon/containerd/image_exporter.go
  2. 4 0
      daemon/containerd/image_pull.go
  3. 4 0
      daemon/containerd/image_push.go

+ 2 - 0
daemon/containerd/image_exporter.go

@@ -113,6 +113,8 @@ func (i *ImageService) ExportImage(ctx context.Context, names []string, outStrea
 				"target": target,
 			}).Debug("export image without name")
 		}
+
+		i.LogImageEvent(target.Digest.String(), target.Digest.String(), events.ActionSave)
 	}
 
 	return i.client.Export(ctx, outStream, opts...)

+ 4 - 0
daemon/containerd/image_pull.go

@@ -11,6 +11,7 @@ import (
 	"github.com/containerd/containerd/pkg/snapshotters"
 	"github.com/containerd/containerd/platforms"
 	"github.com/distribution/reference"
+	"github.com/docker/docker/api/types/events"
 	"github.com/docker/docker/api/types/registry"
 	"github.com/docker/docker/errdefs"
 	"github.com/docker/docker/pkg/streamformatter"
@@ -88,5 +89,8 @@ func (i *ImageService) PullImage(ctx context.Context, image, tagOrDigest string,
 		// error to not mark the pull as failed.
 		logger.WithError(err).Warn("unexpected error while removing outdated dangling image reference")
 	}
+
+	i.LogImageEvent(reference.FamiliarString(ref), reference.FamiliarName(ref), events.ActionPull)
+
 	return nil
 }

+ 4 - 0
daemon/containerd/image_push.go

@@ -16,6 +16,7 @@ import (
 	"github.com/containerd/containerd/remotes"
 	"github.com/containerd/containerd/remotes/docker"
 	"github.com/distribution/reference"
+	"github.com/docker/docker/api/types/events"
 	"github.com/docker/docker/api/types/registry"
 	"github.com/docker/docker/errdefs"
 	"github.com/docker/docker/pkg/progress"
@@ -147,6 +148,9 @@ func (i *ImageService) PushImage(ctx context.Context, targetRef reference.Named,
 		}
 	}
 
+	if err == nil {
+		i.LogImageEvent(reference.FamiliarString(targetRef), reference.FamiliarName(targetRef), events.ActionPush)
+	}
 	return err
 }