Skip to content

Commit c626bef

Browse files
gloursndeloof
authored andcommitted
fix the way we're checking if the provider metadata are empty or not
Signed-off-by: Guillaume Lours <[email protected]>
1 parent 60ee6ad commit c626bef

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

pkg/compose/plugins.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,16 +170,17 @@ func (s *composeService) getPluginBinaryPath(provider string) (path string, err
170170
}
171171

172172
func (s *composeService) setupPluginCommand(ctx context.Context, project *types.Project, service types.ServiceConfig, path, command string) (*exec.Cmd, error) {
173-
cmdOptionsMetadata := s.getPluginMetadata(path, service.Provider.Type)
173+
cmdOptionsMetadata := s.getPluginMetadata(path, service.Provider.Type, project)
174174
var currentCommandMetadata CommandMetadata
175175
switch command {
176176
case "up":
177177
currentCommandMetadata = cmdOptionsMetadata.Up
178178
case "down":
179179
currentCommandMetadata = cmdOptionsMetadata.Down
180180
}
181-
commandMetadataIsEmpty := len(currentCommandMetadata.Parameters) == 0
181+
182182
provider := *service.Provider
183+
commandMetadataIsEmpty := cmdOptionsMetadata.IsEmpty()
183184
if err := currentCommandMetadata.CheckRequiredParameters(provider); !commandMetadataIsEmpty && err != nil {
184185
return nil, err
185186
}
@@ -203,8 +204,13 @@ func (s *composeService) setupPluginCommand(ctx context.Context, project *types.
203204
return cmd, nil
204205
}
205206

206-
func (s *composeService) getPluginMetadata(path, command string) ProviderMetadata {
207+
func (s *composeService) getPluginMetadata(path, command string, project *types.Project) ProviderMetadata {
207208
cmd := exec.Command(path, "compose", "metadata")
209+
err := s.prepareShellOut(context.Background(), project, cmd)
210+
if err != nil {
211+
logrus.Debugf("failed to prepare plugin metadata command: %v", err)
212+
return ProviderMetadata{}
213+
}
208214
stdout := &bytes.Buffer{}
209215
cmd.Stdout = stdout
210216

@@ -239,6 +245,10 @@ type ProviderMetadata struct {
239245
Down CommandMetadata `json:"down"`
240246
}
241247

248+
func (p ProviderMetadata) IsEmpty() bool {
249+
return p.Description == "" && p.Up.Parameters == nil && p.Down.Parameters == nil
250+
}
251+
242252
type CommandMetadata struct {
243253
Parameters []ParameterMetadata `json:"parameters"`
244254
}

0 commit comments

Comments
 (0)