Răsfoiți Sursa

prompt default implementation to prevent a panic

Signed-off-by: Nicolas De Loof <[email protected]>
Nicolas De Loof 2 luni în urmă
părinte
comite
3ce52883cb
1 a modificat fișierele cu 8 adăugiri și 0 ștergeri
  1. 8 0
      pkg/compose/compose.go

+ 8 - 0
pkg/compose/compose.go

@@ -37,6 +37,7 @@ import (
 	"github.com/docker/docker/api/types/volume"
 	"github.com/docker/docker/api/types/volume"
 	"github.com/docker/docker/client"
 	"github.com/docker/docker/client"
 	"github.com/jonboulle/clockwork"
 	"github.com/jonboulle/clockwork"
+	"github.com/sirupsen/logrus"
 
 
 	"github.com/docker/compose/v2/pkg/api"
 	"github.com/docker/compose/v2/pkg/api"
 )
 )
@@ -63,6 +64,13 @@ func NewComposeService(dockerCli command.Cli, options ...Option) api.Compose {
 	for _, option := range options {
 	for _, option := range options {
 		option(s)
 		option(s)
 	}
 	}
+	if s.prompt == nil {
+		s.prompt = func(message string, defaultValue bool) (bool, error) {
+			fmt.Println(message)
+			logrus.Warning("Compose is running without a 'prompt' component to interact with user")
+			return defaultValue, nil
+		}
+	}
 	return s
 	return s
 }
 }