mirror of
https://github.com/docker/compose.git
synced 2025-07-22 05:04:27 +02:00
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>
This commit is contained in:
parent
60ee6adcd2
commit
c626befee1
@ -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"`
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user