mirror of
https://github.com/containers/podman.git
synced 2025-06-25 20:26:51 +08:00
Merge pull request #7202 from baude/buildevent
add event for image build
This commit is contained in:
@ -101,6 +101,8 @@ const (
|
|||||||
Attach Status = "attach"
|
Attach Status = "attach"
|
||||||
// AutoUpdate ...
|
// AutoUpdate ...
|
||||||
AutoUpdate Status = "auto-update"
|
AutoUpdate Status = "auto-update"
|
||||||
|
// Build ...
|
||||||
|
Build Status = "build"
|
||||||
// Checkpoint ...
|
// Checkpoint ...
|
||||||
Checkpoint Status = "checkpoint"
|
Checkpoint Status = "checkpoint"
|
||||||
// Cleanup ...
|
// Cleanup ...
|
||||||
|
@ -127,6 +127,8 @@ func StringToStatus(name string) (Status, error) {
|
|||||||
switch name {
|
switch name {
|
||||||
case Attach.String():
|
case Attach.String():
|
||||||
return Attach, nil
|
return Attach, nil
|
||||||
|
case Build.String():
|
||||||
|
return Build, nil
|
||||||
case Checkpoint.String():
|
case Checkpoint.String():
|
||||||
return Checkpoint, nil
|
return Checkpoint, nil
|
||||||
case Cleanup.String():
|
case Cleanup.String():
|
||||||
|
@ -17,6 +17,7 @@ import (
|
|||||||
"github.com/containers/image/v5/oci/layout"
|
"github.com/containers/image/v5/oci/layout"
|
||||||
"github.com/containers/image/v5/types"
|
"github.com/containers/image/v5/types"
|
||||||
"github.com/containers/podman/v2/libpod/define"
|
"github.com/containers/podman/v2/libpod/define"
|
||||||
|
"github.com/containers/podman/v2/libpod/events"
|
||||||
"github.com/containers/podman/v2/libpod/image"
|
"github.com/containers/podman/v2/libpod/image"
|
||||||
"github.com/containers/podman/v2/pkg/util"
|
"github.com/containers/podman/v2/pkg/util"
|
||||||
"github.com/containers/storage"
|
"github.com/containers/storage"
|
||||||
@ -150,9 +151,21 @@ func removeStorageContainers(ctrIDs []string, store storage.Store) error {
|
|||||||
return nil
|
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
|
// Build adds the runtime to the imagebuildah call
|
||||||
func (r *Runtime) Build(ctx context.Context, options imagebuildah.BuildOptions, dockerfiles ...string) (string, reference.Canonical, error) {
|
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...)
|
id, ref, err := imagebuildah.BuildDockerfiles(ctx, r.store, options, dockerfiles...)
|
||||||
|
// Write event for build completion
|
||||||
|
r.newImageBuildCompleteEvent(id)
|
||||||
return id, ref, err
|
return id, ref, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user