github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/util/configv3/plugin_repository.go (about) 1 package configv3 2 3 import ( 4 "sort" 5 "strings" 6 ) 7 8 const ( 9 // DefaultPluginRepoName is the name of the preinstalled plugin repository. 10 DefaultPluginRepoName = "CF-Community" 11 12 // DefaultPluginRepoURL is the URL of the preinstalled plugin repository. 13 DefaultPluginRepoURL = "https://plugins.cloudfoundry.org" 14 ) 15 16 // PluginRepository is a saved plugin repository 17 type PluginRepository struct { 18 Name string `json:"Name"` 19 URL string `json:"URL"` 20 } 21 22 // PluginRepositories returns the currently configured plugin repositories from the 23 // .cf/config.json 24 func (config *Config) PluginRepositories() []PluginRepository { 25 repos := config.ConfigFile.PluginRepositories 26 sort.Slice(repos, func(i, j int) bool { 27 return strings.ToLower(repos[i].Name) < strings.ToLower(repos[j].Name) 28 }) 29 return repos 30 } 31 32 // does not add duplicates to the config 33 func (config *Config) AddPluginRepository(name string, url string) { 34 config.ConfigFile.PluginRepositories = append(config.ConfigFile.PluginRepositories, 35 PluginRepository{Name: name, URL: url}) 36 }