Skip to content

Commit 8b5b78f

Browse files
committed
can't watch a service without a build section
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent d3e49fe commit 8b5b78f

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

pkg/compose/watch.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,22 @@ func (s *composeService) Watch(ctx context.Context, project *types.Project, serv
103103
if err != nil {
104104
return err
105105
}
106+
107+
if config != nil && len(config.Watch) > 0 && service.Build == nil {
108+
// service configured with watchers but no build section
109+
return fmt.Errorf("can't watch service %q without a build context", service.Name)
110+
}
111+
112+
if len(services) > 0 && service.Build == nil {
113+
// service explicitly selected for watch has no build section
114+
return fmt.Errorf("can't watch service %q without a build context", service.Name)
115+
}
116+
117+
if len(services) == 0 && service.Build == nil {
118+
continue
119+
}
120+
106121
if config == nil {
107-
if service.Build == nil {
108-
continue
109-
}
110122
config = &DevelopmentConfig{
111123
Watch: []Trigger{
112124
{
@@ -116,6 +128,7 @@ func (s *composeService) Watch(ctx context.Context, project *types.Project, serv
116128
},
117129
}
118130
}
131+
119132
name := service.Name
120133
bc := service.Build.Context
121134

0 commit comments

Comments
 (0)