github.com/jasonkeene/cli@v6.14.1-0.20160816203908-ca5715166dfb+incompatible/cf/actors/plugininstaller/plugin_installer.go (about) 1 package plugininstaller 2 3 import ( 4 "github.com/cloudfoundry/cli/cf/actors/pluginrepo" 5 "github.com/cloudfoundry/cli/cf/models" 6 "github.com/cloudfoundry/cli/cf/terminal" 7 "github.com/cloudfoundry/cli/utils" 8 "github.com/cloudfoundry/cli/utils/downloader" 9 ) 10 11 //go:generate counterfeiter . PluginInstaller 12 13 type PluginInstaller interface { 14 Install(inputSourceFilepath string) string 15 } 16 17 type Context struct { 18 Checksummer utils.Sha1Checksum 19 FileDownloader downloader.Downloader 20 GetPluginRepos pluginReposFetcher 21 PluginRepo pluginrepo.PluginRepo 22 RepoName string 23 UI terminal.UI 24 } 25 26 type pluginReposFetcher func() []models.PluginRepo 27 28 func NewPluginInstaller(context *Context) PluginInstaller { 29 var installer PluginInstaller 30 31 pluginDownloader := &PluginDownloader{UI: context.UI, FileDownloader: context.FileDownloader} 32 if context.RepoName == "" { 33 installer = &pluginInstallerWithoutRepo{ 34 UI: context.UI, 35 PluginDownloader: pluginDownloader, 36 RepoName: context.RepoName, 37 } 38 } else { 39 installer = &pluginInstallerWithRepo{ 40 UI: context.UI, 41 PluginDownloader: pluginDownloader, 42 RepoName: context.RepoName, 43 Checksummer: context.Checksummer, 44 PluginRepo: context.PluginRepo, 45 GetPluginRepos: context.GetPluginRepos, 46 } 47 } 48 return installer 49 }