Skip to content

Commit 066acec

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

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

pkg/compose/build.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,16 @@ func (s *composeService) build(ctx context.Context, project *types.Project, opti
156156
}
157157
service := serviceToBuild.service
158158

159+
cw := progress.ContextWriter(ctx)
160+
serviceName := fmt.Sprintf("Service %s", name)
161+
159162
if !buildkitEnabled {
163+
cw.Event(progress.BuildingEvent(serviceName))
160164
id, err := s.doBuildClassic(ctx, project, service, options)
161165
if err != nil {
162166
return err
163167
}
168+
cw.Event(progress.BuiltEvent(serviceName))
164169
builtDigests[getServiceIndex(name)] = id
165170

166171
if options.Push {
@@ -178,10 +183,12 @@ func (s *composeService) build(ctx context.Context, project *types.Project, opti
178183
return err
179184
}
180185

186+
cw.Event(progress.BuildingEvent(serviceName))
181187
digest, err := s.doBuildBuildkit(ctx, name, buildOptions, w, nodes)
182188
if err != nil {
183189
return err
184190
}
191+
cw.Event(progress.BuiltEvent(serviceName))
185192
builtDigests[getServiceIndex(name)] = digest
186193

187194
return nil

pkg/compose/build_buildkit.go

Lines changed: 0 additions & 5 deletions
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,

pkg/progress/event.go

Lines changed: 10 additions & 0 deletions
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)