From c626befee1596abcc74578cb10dd96ae1667f76f Mon Sep 17 00:00:00 2001 From: Guillaume Lours <705411+glours@users.noreply.github.com> Date: Thu, 3 Jul 2025 17:48:14 +0200 Subject: [PATCH] fix the way we're checking if the provider metadata are empty or not Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com> --- pkg/compose/plugins.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pkg/compose/plugins.go b/pkg/compose/plugins.go index f49c18f99..6e5224af5 100644 --- a/pkg/compose/plugins.go +++ b/pkg/compose/plugins.go @@ -170,7 +170,7 @@ func (s *composeService) getPluginBinaryPath(provider string) (path string, err } func (s *composeService) setupPluginCommand(ctx context.Context, project *types.Project, service types.ServiceConfig, path, command string) (*exec.Cmd, error) { - cmdOptionsMetadata := s.getPluginMetadata(path, service.Provider.Type) + cmdOptionsMetadata := s.getPluginMetadata(path, service.Provider.Type, project) var currentCommandMetadata CommandMetadata switch command { case "up": @@ -178,8 +178,9 @@ func (s *composeService) setupPluginCommand(ctx context.Context, project *types. case "down": currentCommandMetadata = cmdOptionsMetadata.Down } - commandMetadataIsEmpty := len(currentCommandMetadata.Parameters) == 0 + provider := *service.Provider + commandMetadataIsEmpty := cmdOptionsMetadata.IsEmpty() if err := currentCommandMetadata.CheckRequiredParameters(provider); !commandMetadataIsEmpty && err != nil { return nil, err } @@ -203,8 +204,13 @@ func (s *composeService) setupPluginCommand(ctx context.Context, project *types. return cmd, nil } -func (s *composeService) getPluginMetadata(path, command string) ProviderMetadata { +func (s *composeService) getPluginMetadata(path, command string, project *types.Project) ProviderMetadata { cmd := exec.Command(path, "compose", "metadata") + err := s.prepareShellOut(context.Background(), project, cmd) + if err != nil { + logrus.Debugf("failed to prepare plugin metadata command: %v", err) + return ProviderMetadata{} + } stdout := &bytes.Buffer{} cmd.Stdout = stdout @@ -239,6 +245,10 @@ type ProviderMetadata struct { Down CommandMetadata `json:"down"` } +func (p ProviderMetadata) IsEmpty() bool { + return p.Description == "" && p.Up.Parameters == nil && p.Down.Parameters == nil +} + type CommandMetadata struct { Parameters []ParameterMetadata `json:"parameters"` }