Skip to content

Commit

Permalink
Check fast for plugin version existence and simplify syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafa committed Dec 28, 2024
1 parent 784cb3f commit 53e8b30
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion plugin/plugin_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ func (reg *Registry) Exists(name, version, remoteURL string) bool {

for _, plugin := range reg.List() {
if plugin.Name == name && plugin.RemoteURL == remoteURL {
// If the version is the same, the plugin exists.
if version == plugin.Version {
return true
}

// Parse the supplied version and the version in the registry.
suppliedVer, err := semver.NewVersion(version)
if err != nil {
Expand All @@ -160,7 +165,7 @@ func (reg *Registry) Exists(name, version, remoteURL string) bool {
// Check if the version of the plugin is less than or equal to
// the version in the registry.
// TODO: Should we check the major version only, or as well?
if suppliedVer.LessThan(registryVer) || suppliedVer.Equal(registryVer) {
if suppliedVer.LessThanEqual(registryVer) {
return true
}

Expand Down

0 comments on commit 53e8b30

Please sign in to comment.