Skip to content

Commit afb40fb

Browse files
committed
Merge branch 'main' into reconciliation
2 parents 2e7acd0 + 9eb8966 commit afb40fb

5 files changed

Lines changed: 24 additions & 5 deletions

File tree

pkg/api/api.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,8 @@ type CreateOptions struct {
278278
Timeout *time.Duration
279279
// QuietPull makes the pulling process quiet
280280
QuietPull bool
281+
// SkipProviders skips provider services during convergence (e.g. watch rebuild)
282+
SkipProviders bool
281283
}
282284

283285
// StartOptions group options of the Start API

pkg/compose/create.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ func (s *composeService) create(ctx context.Context, project *types.Project, opt
125125
Inherit: options.Inherit,
126126
Timeout: options.Timeout,
127127
RemoveOrphans: options.RemoveOrphans,
128+
SkipProviders: options.SkipProviders,
128129
})
129130
if err != nil {
130131
return err

pkg/compose/plugins.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,10 @@ func (s *composeService) executePlugin(cmd *exec.Cmd, command string, service ty
125125
}
126126
switch msg.Type {
127127
case ErrorType:
128-
s.events.On(newEvent(service.Name, api.Error, msg.Message))
128+
s.events.On(newEvent(service.Name, api.Error, firstLine(msg.Message)))
129129
return nil, errors.New(msg.Message)
130130
case InfoType:
131-
s.events.On(newEvent(service.Name, api.Working, msg.Message))
131+
s.events.On(newEvent(service.Name, api.Working, firstLine(msg.Message)))
132132
case SetEnvType:
133133
key, val, found := strings.Cut(msg.Message, "=")
134134
if !found {
@@ -281,3 +281,12 @@ func (c CommandMetadata) CheckRequiredParameters(provider types.ServiceProviderC
281281
}
282282
return nil
283283
}
284+
285+
// firstLine returns the first line of s, stripping any trailing newlines.
286+
func firstLine(s string) string {
287+
s = strings.TrimRight(s, "\n")
288+
if i := strings.IndexByte(s, '\n'); i >= 0 {
289+
return s[:i]
290+
}
291+
return s
292+
}

pkg/compose/reconcile.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ type ReconcileOptions struct {
259259
Inherit bool
260260
Timeout *time.Duration
261261
RemoveOrphans bool
262+
SkipProviders bool // skip provider services (e.g. watch rebuild)
262263
StartContainers bool // include OpStartContainer in the plan (true for up, false for create)
263264
}
264265

@@ -357,6 +358,11 @@ func reconcileServices(
357358
}
358359

359360
if service.Provider != nil {
361+
// Skip provider services when the caller opted out (e.g. watch rebuild),
362+
// since providers were already set up during initial "up".
363+
if opts.SkipProviders {
364+
continue
365+
}
360366
id := fmt.Sprintf("run-plugin:%s", service.Name)
361367
plan.Operations[id] = &Operation{
362368
ID: id,

pkg/compose/watch.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -662,9 +662,10 @@ func (s *composeService) rebuild(ctx context.Context, project *types.Project, se
662662
options.LogTo.Log(api.WatchLogger, fmt.Sprintf("service(s) %q successfully built", services))
663663

664664
err = s.create(ctx, project, api.CreateOptions{
665-
Services: services,
666-
Inherit: true,
667-
Recreate: api.RecreateForce,
665+
Services: services,
666+
Inherit: true,
667+
Recreate: api.RecreateForce,
668+
SkipProviders: true,
668669
})
669670
if err != nil {
670671
options.LogTo.Log(api.WatchLogger, fmt.Sprintf("Failed to recreate services after update. Error: %v", err))

0 commit comments

Comments
 (0)