Skip to content

Commit dc58865

Browse files
committed
fix
Signed-off-by: Smyslov Maxim <maksim.smyslov@flant.com>
1 parent b2bd887 commit dc58865

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

cmd/plugins/plugins.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,16 @@ func (pc *PluginsCommand) getInstalledPluginVersion(pluginName string) (*semver.
839839

840840
output, err := cmd.Output()
841841
if err != nil {
842-
return nil, fmt.Errorf("failed to call plugin: %w", err)
842+
pc.logger.Warn("failed to call plugin with '--version'", slog.String("plugin", pluginName), slog.String("error", err.Error()))
843+
844+
// try to call plugin with "version" command
845+
// this is for compatibility with plugins that don't support "--version"
846+
cmd = exec.Command(pluginBinaryPath, "version")
847+
848+
output, err = cmd.Output()
849+
if err != nil {
850+
return nil, fmt.Errorf("failed to call plugin: %w", err)
851+
}
843852
}
844853

845854
version, err := semver.NewVersion(strings.TrimSpace(string(output)))
@@ -894,7 +903,7 @@ func (pc *PluginsCommand) validatePluginRequirement(plugin *internal.Plugin) err
894903
}
895904

896905
if !constraint.Check(installedVersion) {
897-
return fmt.Errorf("plugin %s version %s does not satisfy constraint %s", pluginRequirement.Name, plugin.Version, pluginRequirement.Constraint)
906+
return fmt.Errorf("plugin %s version %s does not satisfy constraint %s", pluginRequirement.Name, installedVersion.Original(), pluginRequirement.Constraint)
898907
}
899908
}
900909
}

0 commit comments

Comments
 (0)