Bladeren bron

Revert "Stop the resource timer after last expected event"

This reverts commit a4ddbcb6b2caf12826926d164d47319ac01fa6d4.

Signed-off-by: Nicolas De Loof <[email protected]>
Nicolas De Loof 1 jaar geleden
bovenliggende
commit
d8ee474e09

+ 2 - 19
pkg/compose/convergence.go

@@ -757,7 +757,7 @@ func (s *composeService) isServiceCompleted(ctx context.Context, containers Cont
 	return false, 0, nil
 }
 
-func (s *composeService) startService(ctx context.Context, project *types.Project, service types.ServiceConfig, containers Containers, wait bool) error {
+func (s *composeService) startService(ctx context.Context, project *types.Project, service types.ServiceConfig, containers Containers) error {
 	if service.Deploy != nil && service.Deploy.Replicas != nil && *service.Deploy.Replicas == 0 {
 		return nil
 	}
@@ -785,28 +785,11 @@ func (s *composeService) startService(ctx context.Context, project *types.Projec
 		if err != nil {
 			return err
 		}
-		status := progress.Done
-		if wait || dependencyWaiting(project, service.Name) {
-			status = progress.Working
-		}
-		w.Event(progress.NewEvent(eventName, status, "Started"))
+		w.Event(progress.StartedEvent(eventName))
 	}
 	return nil
 }
 
-func dependencyWaiting(project *types.Project, name string) bool {
-	for _, service := range project.Services {
-		depends, ok := service.DependsOn[name]
-		if !ok {
-			continue
-		}
-		if depends.Condition == types.ServiceConditionHealthy {
-			return true
-		}
-	}
-	return false
-}
-
 func mergeLabels(ls ...types.Labels) types.Labels {
 	merged := types.Labels{}
 	for _, l := range ls {

+ 1 - 1
pkg/compose/start.go

@@ -129,7 +129,7 @@ func (s *composeService) start(ctx context.Context, projectName string, options
 			return err
 		}
 
-		return s.startService(ctx, project, service, containers, options.Wait)
+		return s.startService(ctx, project, service, containers)
 	})
 	if err != nil {
 		return err

+ 0 - 1
pkg/compose/up.go

@@ -43,7 +43,6 @@ func (s *composeService) Up(ctx context.Context, project *types.Project, options
 			return err
 		}
 		if options.Start.Attach == nil {
-			w.HasMore(false)
 			return s.start(ctx, project.Name, options.Start, nil)
 		}
 		return nil

+ 1 - 1
pkg/progress/event.go

@@ -191,6 +191,6 @@ func (e *Event) Spinner() any {
 	case Error:
 		return ErrorColor(spinnerError)
 	default:
-		return CountColor(e.spinner.String())
+		return e.spinner.String()
 	}
 }

+ 0 - 3
pkg/progress/noop.go

@@ -38,6 +38,3 @@ func (p *noopWriter) TailMsgf(_ string, _ ...interface{}) {
 
 func (p *noopWriter) Stop() {
 }
-
-func (p *noopWriter) HasMore(bool) {
-}

+ 0 - 3
pkg/progress/plain.go

@@ -64,6 +64,3 @@ func (p *plainWriter) TailMsgf(msg string, args ...interface{}) {
 func (p *plainWriter) Stop() {
 	p.done <- true
 }
-
-func (p *plainWriter) HasMore(bool) {
-}

+ 0 - 3
pkg/progress/quiet.go

@@ -35,6 +35,3 @@ func (q quiet) Events(_ []Event) {
 
 func (q quiet) TailMsgf(_ string, _ ...interface{}) {
 }
-
-func (q quiet) HasMore(bool) {
-}

+ 11 - 19
pkg/progress/tty.go

@@ -33,18 +33,17 @@ import (
 )
 
 type ttyWriter struct {
-	out               io.Writer
-	events            map[string]Event
-	eventIDs          []string
-	repeated          bool
-	numLines          int
-	done              chan bool
-	mtx               *sync.Mutex
-	tailEvents        []string
-	dryRun            bool
-	skipChildEvents   bool
-	progressTitle     string
-	hasFollowupAction bool
+	out             io.Writer
+	events          map[string]Event
+	eventIDs        []string
+	repeated        bool
+	numLines        int
+	done            chan bool
+	mtx             *sync.Mutex
+	tailEvents      []string
+	dryRun          bool
+	skipChildEvents bool
+	progressTitle   string
 }
 
 func (w *ttyWriter) Start(ctx context.Context) error {
@@ -71,10 +70,6 @@ func (w *ttyWriter) Stop() {
 	w.done <- true
 }
 
-func (w *ttyWriter) HasMore(b bool) {
-	w.hasFollowupAction = b
-}
-
 func (w *ttyWriter) Event(e Event) {
 	w.mtx.Lock()
 	defer w.mtx.Unlock()
@@ -87,9 +82,6 @@ func (w *ttyWriter) event(e Event) {
 	}
 	if _, ok := w.events[e.ID]; ok {
 		last := w.events[e.ID]
-		if e.Status == Done && w.hasFollowupAction {
-			e.Status = Working
-		}
 		switch e.Status {
 		case Done, Error, Warning:
 			if last.endTime.IsZero() {

+ 1 - 1
pkg/progress/tty_test.go

@@ -42,7 +42,7 @@ func TestLineText(t *testing.T) {
 	lineWidth := len(fmt.Sprintf("%s %s", ev.ID, ev.Text))
 
 	out := tty().lineText(ev, "", 50, lineWidth, false)
-	assert.Equal(t, out, " \x1b[33m.\x1b[0m id Text Status                            \x1b[34m0.0s \x1b[0m\n")
+	assert.Equal(t, out, " . id Text Status                            \x1b[34m0.0s \x1b[0m\n")
 
 	ev.Status = Done
 	out = tty().lineText(ev, "", 50, lineWidth, false)

+ 0 - 1
pkg/progress/writer.go

@@ -36,7 +36,6 @@ type Writer interface {
 	Event(Event)
 	Events([]Event)
 	TailMsgf(string, ...interface{})
-	HasMore(more bool)
 }
 
 type writerKey struct{}