MCPcopy Index your code
hub / github.com/cloudfoundry/cli / GetOutdatedPlugins

Method GetOutdatedPlugins

actor/pluginaction/list.go:14–48  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12}
13
14func (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
50func lessThan(version1 string, version2 string) bool {
51 v1, err := semver.Make(version1)

Callers

nothing calls this directly

Implementers 1

FakeActorcommand/v7/v7fakes/fake_actor.go

Calls 6

lessThanFunction · 0.85
PluginRepositoriesMethod · 0.65
GetPluginRepositoryMethod · 0.65
ErrorMethod · 0.65
PluginsMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected