github.com/cloud-green/juju@v0.0.0-20151002100041-a00291338d3d/provider/local/utils.go (about) 1 // Copyright 2013 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package local 5 6 import ( 7 "github.com/juju/utils/packaging/manager" 8 "github.com/juju/utils/proxy" 9 "github.com/juju/utils/series" 10 ) 11 12 // isPackageInstalled is a helper function which instantiates a new 13 // PackageManager for the current system and checks whether the given package is 14 // installed. 15 var isPackageInstalled = func(pack string) bool { 16 // We know that there exists a package manager for this OS as the agent has 17 // been bootstrapped. 18 pacman, _ := manager.NewPackageManager(series.HostSeries()) 19 return pacman.IsInstalled(pack) 20 } 21 22 // detectPackageProxies is a helper function which instantiates a new 23 // PackageManager for the current system and checks for package manager proxy 24 // settings. 25 var detectPackageProxies = func() (proxy.Settings, error) { 26 pacman, err := manager.NewPackageManager(series.HostSeries()) 27 if err != nil { 28 return proxy.Settings{}, err 29 } 30 return pacman.GetProxySettings() 31 }