()
| 12 | } |
| 13 | |
| 14 | func (actor Actor) GetOutdatedPlugins() ([]OutdatedPlugin, error) { |
| 15 | var outdatedPlugins []OutdatedPlugin |
| 16 | |
| 17 | repoPlugins := map[string]string{} |
| 18 | for _, repo := range actor.config.PluginRepositories() { |
| 19 | repository, err := actor.client.GetPluginRepository(repo.URL) |
| 20 | if err != nil { |
| 21 | return nil, actionerror.GettingPluginRepositoryError{Name: repo.Name, Message: err.Error()} |
| 22 | } |
| 23 | |
| 24 | for _, plugin := range repository.Plugins { |
| 25 | existingVersion, exist := repoPlugins[plugin.Name] |
| 26 | if exist { |
| 27 | if lessThan(existingVersion, plugin.Version) { |
| 28 | repoPlugins[plugin.Name] = plugin.Version |
| 29 | } |
| 30 | } else { |
| 31 | repoPlugins[plugin.Name] = plugin.Version |
| 32 | } |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | for _, installedPlugin := range actor.config.Plugins() { |
| 37 | repoVersion, exist := repoPlugins[installedPlugin.Name] |
| 38 | if exist && lessThan(installedPlugin.Version.String(), repoVersion) { |
| 39 | outdatedPlugins = append(outdatedPlugins, OutdatedPlugin{ |
| 40 | Name: installedPlugin.Name, |
| 41 | CurrentVersion: installedPlugin.Version.String(), |
| 42 | LatestVersion: repoVersion, |
| 43 | }) |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | return outdatedPlugins, nil |
| 48 | } |
| 49 | |
| 50 | func lessThan(version1 string, version2 string) bool { |
| 51 | v1, err := semver.Make(version1) |
nothing calls this directly
no test coverage detected