@@ -55,11 +55,7 @@ func (s *composeService) runPlugin(ctx context.Context, project *types.Project,
5555 return err
5656 }
5757
58- if err := s .checkPluginEnabledInDD (ctx , plugin ); err != nil {
59- return err
60- }
61-
62- cmd := s .setupPluginCommand (ctx , project , service , plugin .Path , command )
58+ cmd := s .setupPluginCommand (ctx , project , service , plugin , command )
6359
6460 variables , err := s .executePlugin (ctx , cmd , command , service )
6561 if err != nil {
@@ -148,9 +144,18 @@ func (s *composeService) executePlugin(ctx context.Context, cmd *exec.Cmd, comma
148144 return variables , nil
149145}
150146
151- func (s * composeService ) getPluginBinaryPath (providerType string ) (* manager.Plugin , error ) {
152- // Only support Docker CLI plugins for first iteration. Could support any binary from PATH
153- return manager .GetPlugin (providerType , s .dockerCli , & cobra.Command {})
147+ func (s * composeService ) getPluginBinaryPath (provider string ) (path string , err error ) {
148+ if provider == "compose" {
149+ return "" , errors .New ("'compose' is not a valid provider type" )
150+ }
151+ plugin , err := manager .GetPlugin (provider , s .dockerCli , & cobra.Command {})
152+ if err == nil {
153+ path = plugin .Path
154+ }
155+ if manager .IsNotFound (err ) {
156+ path , err = exec .LookPath (provider )
157+ }
158+ return path , err
154159}
155160
156161func (s * composeService ) setupPluginCommand (ctx context.Context , project * types.Project , service types.ServiceConfig , path , command string ) * exec.Cmd {
@@ -182,24 +187,3 @@ func (s *composeService) setupPluginCommand(ctx context.Context, project *types.
182187 cmd .Env = append (cmd .Env , types .Mapping (carrier ).Values ()... )
183188 return cmd
184189}
185-
186- func (s * composeService ) checkPluginEnabledInDD (ctx context.Context , plugin * manager.Plugin ) error {
187- if integrationEnabled := s .isDesktopIntegrationActive (); ! integrationEnabled {
188- return fmt .Errorf ("you should enable Docker Desktop integration to use %q provider services" , plugin .Name )
189- }
190-
191- // Until we support more use cases, check explicitly status of model runner
192- if plugin .Name == "model" {
193- cmd := exec .CommandContext (ctx , "docker" , "model" , "status" )
194- _ , err := cmd .CombinedOutput ()
195- if err != nil {
196- var exitErr * exec.ExitError
197- if errors .As (err , & exitErr ) && exitErr .ExitCode () == 1 {
198- return fmt .Errorf ("you should enable model runner to use %q provider services: %s" , plugin .Name , err .Error ())
199- }
200- }
201- } else {
202- return fmt .Errorf ("unsupported provider %q" , plugin .Name )
203- }
204- return nil
205- }
0 commit comments