Skip to content

Commit c4e15c6

Browse files
committed
Emit events for building images
Signed-off-by: Felix Fontein <[email protected]>
1 parent 1505932 commit c4e15c6

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

Diff for: pkg/compose/build.go

+7
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,16 @@ func (s *composeService) build(ctx context.Context, project *types.Project, opti
158158
}
159159
service := serviceToBuild.service
160160

161+
cw := progress.ContextWriter(ctx)
162+
serviceName := fmt.Sprintf("Service %s", name)
163+
161164
if !buildkitEnabled {
165+
cw.Event(progress.BuildingEvent(serviceName))
162166
id, err := s.doBuildClassic(ctx, project, service, options)
163167
if err != nil {
164168
return err
165169
}
170+
cw.Event(progress.BuiltEvent(serviceName))
166171
builtDigests[getServiceIndex(name)] = id
167172

168173
if options.Push {
@@ -180,10 +185,12 @@ func (s *composeService) build(ctx context.Context, project *types.Project, opti
180185
return err
181186
}
182187

188+
cw.Event(progress.BuildingEvent(serviceName))
183189
digest, err := s.doBuildBuildkit(ctx, name, buildOptions, w, nodes)
184190
if err != nil {
185191
return err
186192
}
193+
cw.Event(progress.BuiltEvent(serviceName))
187194
builtDigests[getServiceIndex(name)] = digest
188195

189196
return nil

Diff for: pkg/compose/build_buildkit.go

-5
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,6 @@ func (s composeService) dryRunBuildResponse(ctx context.Context, name string, op
7070
w := progress.ContextWriter(ctx)
7171
buildResponse := map[string]*client.SolveResponse{}
7272
dryRunUUID := fmt.Sprintf("dryRun-%x", sha1.Sum([]byte(name)))
73-
w.Event(progress.Event{
74-
ID: " ",
75-
Status: progress.Done,
76-
Text: fmt.Sprintf("build service %s", name),
77-
})
7873
w.Event(progress.Event{
7974
ID: "==>",
8075
Status: progress.Done,

Diff for: pkg/progress/event.go

+10
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,16 @@ func RemovedEvent(id string) Event {
153153
return NewEvent(id, Done, "Removed")
154154
}
155155

156+
// BuildingEvent creates a new Building in progress Event
157+
func BuildingEvent(id string) Event {
158+
return NewEvent(id, Working, "Building")
159+
}
160+
161+
// BuiltEvent creates a new built (done) Event
162+
func BuiltEvent(id string) Event {
163+
return NewEvent(id, Done, "Built")
164+
}
165+
156166
// SkippedEvent creates a new Skipped Event
157167
func SkippedEvent(id string, reason string) Event {
158168
return Event{

0 commit comments

Comments
 (0)