forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin_repository.go
37 lines (31 loc) · 1.08 KB
/
plugin_repository.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package configv3
import (
"sort"
"strings"
)
const (
// DefaultPluginRepoName is the name of the preinstalled plugin repository.
DefaultPluginRepoName = "CF-Community"
// DefaultPluginRepoURL is the URL of the preinstalled plugin repository.
DefaultPluginRepoURL = "https://plugins.cloudfoundry.org"
)
// PluginRepository is a saved plugin repository
type PluginRepository struct {
Name string `json:"Name"`
URL string `json:"URL"`
}
// AddPluginRepository adds an new repository to the plugin config. It does not
// add duplicates to the config.
func (config *Config) AddPluginRepository(name string, url string) {
config.ConfigFile.PluginRepositories = append(config.ConfigFile.PluginRepositories,
PluginRepository{Name: name, URL: url})
}
// PluginRepositories returns the currently configured plugin repositories from the
// .cf/config.json.
func (config *Config) PluginRepositories() []PluginRepository {
repos := config.ConfigFile.PluginRepositories
sort.Slice(repos, func(i, j int) bool {
return strings.ToLower(repos[i].Name) < strings.ToLower(repos[j].Name)
})
return repos
}