can't watch a service without a build section

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2023-04-04 10:40:04 +02:00 committed by Nicolas De loof
parent d3e49fe360
commit 8b5b78fbb6
1 changed files with 16 additions and 3 deletions

View File

@ -103,10 +103,22 @@ func (s *composeService) Watch(ctx context.Context, project *types.Project, serv
if err != nil {
return err
}
if config != nil && len(config.Watch) > 0 && service.Build == nil {
// service configured with watchers but no build section
return fmt.Errorf("can't watch service %q without a build context", service.Name)
}
if len(services) > 0 && service.Build == nil {
// service explicitly selected for watch has no build section
return fmt.Errorf("can't watch service %q without a build context", service.Name)
}
if len(services) == 0 && service.Build == nil {
continue
}
if config == nil {
if service.Build == nil {
continue
}
config = &DevelopmentConfig{
Watch: []Trigger{
{
@ -116,6 +128,7 @@ func (s *composeService) Watch(ctx context.Context, project *types.Project, serv
},
}
}
name := service.Name
bc := service.Build.Context