display creation warnings from the engine

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
This commit is contained in:
Guillaume Lours 2022-11-15 17:55:48 +01:00
parent c53539e1cc
commit a077e8a24b
1 changed files with 10 additions and 3 deletions

View File

@ -403,7 +403,7 @@ func (s *composeService) createContainer(ctx context.Context, project *types.Pro
w := progress.ContextWriter(ctx)
eventName := "Container " + name
w.Event(progress.CreatingEvent(eventName))
container, err = s.createMobyContainer(ctx, project, service, name, number, nil, autoRemove, useNetworkAliases, attachStdin)
container, err = s.createMobyContainer(ctx, project, service, name, number, nil, autoRemove, useNetworkAliases, attachStdin, w)
if err != nil {
return
}
@ -437,7 +437,7 @@ func (s *composeService) recreateContainer(ctx context.Context, project *types.P
inherited = &replaced
}
name = getContainerName(project.Name, service, number)
created, err = s.createMobyContainer(ctx, project, service, name, number, inherited, false, true, false)
created, err = s.createMobyContainer(ctx, project, service, name, number, inherited, false, true, false, w)
if err != nil {
return created, err
}
@ -475,7 +475,7 @@ func (s *composeService) startContainer(ctx context.Context, container moby.Cont
}
func (s *composeService) createMobyContainer(ctx context.Context, project *types.Project, service types.ServiceConfig,
name string, number int, inherit *moby.Container, autoRemove bool, useNetworkAliases bool, attachStdin bool) (moby.Container, error) {
name string, number int, inherit *moby.Container, autoRemove bool, useNetworkAliases bool, attachStdin bool, w progress.Writer) (moby.Container, error) {
var created moby.Container
containerConfig, hostConfig, networkingConfig, err := s.getCreateOptions(ctx, project, service, number, inherit, autoRemove, attachStdin)
if err != nil {
@ -494,6 +494,13 @@ func (s *composeService) createMobyContainer(ctx context.Context, project *types
if err != nil {
return created, err
}
for _, warning := range response.Warnings {
w.Event(progress.Event{
ID: service.Name,
Status: progress.Warning,
Text: warning,
})
}
inspectedContainer, err := s.apiClient().ContainerInspect(ctx, response.ID)
if err != nil {
return created, err