Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit events for building images #11498

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions pkg/compose/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,16 @@ func (s *composeService) build(ctx context.Context, project *types.Project, opti
}
service := serviceToBuild.service

cw := progress.ContextWriter(ctx)
serviceName := fmt.Sprintf("Service %s", name)

if !buildkitEnabled {
cw.Event(progress.BuildingEvent(serviceName))
id, err := s.doBuildClassic(ctx, project, service, options)
if err != nil {
return err
}
cw.Event(progress.BuiltEvent(serviceName))
builtDigests[getServiceIndex(name)] = id

if options.Push {
Expand All @@ -181,10 +186,12 @@ func (s *composeService) build(ctx context.Context, project *types.Project, opti
return err
}

cw.Event(progress.BuildingEvent(serviceName))
digest, err := s.doBuildBuildkit(ctx, name, buildOptions, w, nodes)
if err != nil {
return err
}
cw.Event(progress.BuiltEvent(serviceName))
builtDigests[getServiceIndex(name)] = digest

return nil
Expand Down
5 changes: 0 additions & 5 deletions pkg/compose/build_buildkit.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@ func (s composeService) dryRunBuildResponse(ctx context.Context, name string, op
w := progress.ContextWriter(ctx)
buildResponse := map[string]*client.SolveResponse{}
dryRunUUID := fmt.Sprintf("dryRun-%x", sha1.Sum([]byte(name)))
w.Event(progress.Event{
ID: " ",
Status: progress.Done,
Text: fmt.Sprintf("build service %s", name),
})
w.Event(progress.Event{
ID: "==>",
Status: progress.Done,
Expand Down
10 changes: 10 additions & 0 deletions pkg/progress/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,16 @@ func RemovedEvent(id string) Event {
return NewEvent(id, Done, "Removed")
}

// BuildingEvent creates a new Building in progress Event
func BuildingEvent(id string) Event {
return NewEvent(id, Working, "Building")
}

// BuiltEvent creates a new built (done) Event
func BuiltEvent(id string) Event {
return NewEvent(id, Done, "Built")
}

// SkippedEvent creates a new Skipped Event
func SkippedEvent(id string, reason string) Event {
return Event{
Expand Down