Skip to content

Commit 4dcaf94

Browse files
committed
add support of 'debug' messages in the communication between Compose and provider binaries
Signed-off-by: Guillaume Lours <[email protected]>
1 parent 07e7619 commit 4dcaf94

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

docs/extension.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ JSON messages MUST include a `type` and a `message` attribute.
5454

5555
`type` can be either:
5656
- `info`: Reports status updates to the user. Compose will render message as the service state in the progress UI
57-
- `error`: Lest the user know something went wrong with details about the error. Compose will render the message as the reason for the service failure.
57+
- `error`: Let's the user know something went wrong with details about the error. Compose will render the message as the reason for the service failure.
5858
- `setenv`: Let's the plugin tell Compose how dependent services can access the created resource. See next section for further details.
59+
- `debug`: Those messages could help debugging the provider, but are not rendered to the user by default. They are rendered when Compose is started with `--verbose` flag.
5960

6061
```mermaid
6162
sequenceDiagram

pkg/compose/plugins.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"github.com/docker/cli/cli-plugins/manager"
3131
"github.com/docker/cli/cli-plugins/socket"
3232
"github.com/docker/compose/v2/pkg/progress"
33+
"github.com/sirupsen/logrus"
3334
"github.com/spf13/cobra"
3435
"go.opentelemetry.io/otel"
3536
"go.opentelemetry.io/otel/propagation"
@@ -44,6 +45,7 @@ const (
4445
ErrorType = "error"
4546
InfoType = "info"
4647
SetEnvType = "setenv"
48+
DebugType = "debug"
4749
)
4850

4951
func (s *composeService) runPlugin(ctx context.Context, project *types.Project, service types.ServiceConfig, command string) error {
@@ -123,6 +125,8 @@ func (s *composeService) executePlugin(ctx context.Context, cmd *exec.Cmd, comma
123125
return nil, fmt.Errorf("invalid response from plugin: %s", msg.Message)
124126
}
125127
variables[key] = val
128+
case DebugType:
129+
logrus.Debugf("%s: %s", service.Name, msg.Message)
126130
default:
127131
return nil, fmt.Errorf("invalid response from plugin: %s", msg.Type)
128132
}

0 commit comments

Comments
 (0)