github.com/makyo/juju@v0.0.0-20160425123129-2608902037e9/worker/proxyupdater/manifold.go (about) 1 // Copyright 2016 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package proxyupdater 5 6 import ( 7 "github.com/juju/errors" 8 "github.com/juju/names" 9 10 "github.com/juju/juju/agent" 11 "github.com/juju/juju/api/base" 12 "github.com/juju/juju/api/proxyupdater" 13 "github.com/juju/juju/cmd/jujud/agent/util" 14 "github.com/juju/juju/worker" 15 "github.com/juju/juju/worker/dependency" 16 ) 17 18 // ManifoldConfig defines the names of the manifolds on which a Manifold will depend. 19 type ManifoldConfig util.AgentApiManifoldConfig 20 21 // Manifold returns a dependency manifold that runs a proxy updater worker, 22 // using the api connection resource named in the supplied config. 23 func Manifold(config ManifoldConfig) dependency.Manifold { 24 typedConfig := util.AgentApiManifoldConfig(config) 25 return util.AgentApiManifold(typedConfig, newWorker) 26 } 27 28 // newWorker is not currently tested; it should eventually replace New as the 29 // package's exposed factory func, and then all tests should pass through it. 30 func newWorker(a agent.Agent, apiCaller base.APICaller) (worker.Worker, error) { 31 agentConfig := a.CurrentConfig() 32 switch tag := agentConfig.Tag().(type) { 33 case names.MachineTag, names.UnitTag: 34 default: 35 return nil, errors.Errorf("unknown agent type: %T", tag) 36 } 37 38 proxyAPI, err := proxyupdater.NewAPI(apiCaller, agentConfig.Tag()) 39 if err != nil { 40 return nil, err 41 } 42 return NewWorker(Config{ 43 Directory: "/home/ubuntu", 44 RegistryPath: `HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings`, 45 Filename: ".juju-proxy", 46 API: proxyAPI, 47 }) 48 }