diff options
author | Brent Baude <bbaude@redhat.com> | 2020-08-03 12:53:33 -0500 |
---|---|---|
committer | Matthew Heon <matthew.heon@pm.me> | 2020-08-20 12:16:52 -0400 |
commit | c22ea20bf6f12ccf289a48cc185d5159ce7fdaf4 (patch) | |
tree | 7ad44996925cf5e6095d749f7a9510dfb3f1ec13 /libpod/runtime_img.go | |
parent | c14b6c366288c875155d8bbb33c322843b438741 (diff) | |
download | podman-c22ea20bf6f12ccf289a48cc185d5159ce7fdaf4.tar.gz podman-c22ea20bf6f12ccf289a48cc185d5159ce7fdaf4.tar.bz2 podman-c22ea20bf6f12ccf289a48cc185d5159ce7fdaf4.zip |
add event for image build
upon image build completion, a new image type event is written for "build". more intricate details, like pulling an image, that might be done by build must be implemented in different vendored packages only after libpod is split from podman.
Fixes: #7022
Signed-off-by: Brent Baude <bbaude@redhat.com>
<MH: Fixed imports during cherry-pick>
Signed-off-by: Matt Heon <matthew.heon@pm.me>
Diffstat (limited to 'libpod/runtime_img.go')
-rw-r--r-- | libpod/runtime_img.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/libpod/runtime_img.go b/libpod/runtime_img.go index 7c75dbf98..1a82cdc07 100644 --- a/libpod/runtime_img.go +++ b/libpod/runtime_img.go @@ -11,7 +11,11 @@ import ( "github.com/containers/buildah/imagebuildah" "github.com/containers/image/v5/docker/reference" + ociarchive "github.com/containers/image/v5/oci/archive" + "github.com/containers/image/v5/oci/layout" + "github.com/containers/image/v5/types" "github.com/containers/libpod/v2/libpod/define" + "github.com/containers/libpod/v2/libpod/events" "github.com/containers/libpod/v2/libpod/image" "github.com/containers/libpod/v2/pkg/util" "github.com/containers/storage" @@ -147,9 +151,21 @@ func removeStorageContainers(ctrIDs []string, store storage.Store) error { return nil } +// newBuildEvent creates a new event based on completion of a built image +func (r *Runtime) newImageBuildCompleteEvent(idOrName string) { + e := events.NewEvent(events.Build) + e.Type = events.Image + e.Name = idOrName + if err := r.eventer.Write(e); err != nil { + logrus.Errorf("unable to write build event: %q", err) + } +} + // Build adds the runtime to the imagebuildah call func (r *Runtime) Build(ctx context.Context, options imagebuildah.BuildOptions, dockerfiles ...string) (string, reference.Canonical, error) { id, ref, err := imagebuildah.BuildDockerfiles(ctx, r.store, options, dockerfiles...) + // Write event for build completion + r.newImageBuildCompleteEvent(id) return id, ref, err } |