github.com/rakutentech/cli@v6.12.5-0.20151006231303-24468b65536e+incompatible/cf/actors/plugin_installer/plugin_installer.go (about) 1 package plugin_installer 2 3 import ( 4 "github.com/cloudfoundry/cli/cf/actors/plugin_repo" 5 "github.com/cloudfoundry/cli/cf/models" 6 "github.com/cloudfoundry/cli/cf/terminal" 7 "github.com/cloudfoundry/cli/fileutils" 8 "github.com/cloudfoundry/cli/utils" 9 ) 10 11 type PluginInstaller interface { 12 Install(inputSourceFilepath string) string 13 } 14 15 type PluginInstallerContext struct { 16 Checksummer utils.Sha1Checksum 17 FileDownloader fileutils.Downloader 18 GetPluginRepos pluginReposFetcher 19 PluginRepo plugin_repo.PluginRepo 20 RepoName string 21 Ui terminal.UI 22 } 23 24 type pluginReposFetcher func() []models.PluginRepo 25 26 func NewPluginInstaller(context *PluginInstallerContext) (installer PluginInstaller) { 27 pluginDownloader := &PluginDownloader{Ui: context.Ui, FileDownloader: context.FileDownloader} 28 if context.RepoName == "" { 29 installer = &PluginInstallerWithoutRepo{ 30 Ui: context.Ui, 31 PluginDownloader: pluginDownloader, 32 RepoName: context.RepoName, 33 } 34 } else { 35 installer = &PluginInstallerWithRepo{ 36 Ui: context.Ui, 37 PluginDownloader: pluginDownloader, 38 RepoName: context.RepoName, 39 Checksummer: context.Checksummer, 40 PluginRepo: context.PluginRepo, 41 GetPluginRepos: context.GetPluginRepos, 42 } 43 } 44 return installer 45 }