github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/worker/authenticationworker/manifold.go (about) 1 // Copyright 2015 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package authenticationworker 5 6 import ( 7 "github.com/juju/errors" 8 9 "github.com/juju/juju/agent" 10 "github.com/juju/juju/api/base" 11 "github.com/juju/juju/api/keyupdater" 12 "github.com/juju/juju/cmd/jujud/agent/engine" 13 "github.com/juju/juju/worker" 14 "github.com/juju/juju/worker/dependency" 15 ) 16 17 // ManifoldConfig defines the names of the manifolds on which a Manifold will depend. 18 type ManifoldConfig engine.AgentAPIManifoldConfig 19 20 // Manifold returns a dependency manifold that runs a authenticationworker worker, 21 // using the resource names defined in the supplied config. 22 func Manifold(config ManifoldConfig) dependency.Manifold { 23 typedConfig := engine.AgentAPIManifoldConfig(config) 24 25 return engine.AgentAPIManifold(typedConfig, newWorker) 26 } 27 28 func newWorker(a agent.Agent, apiCaller base.APICaller) (worker.Worker, error) { 29 w, err := NewWorker(keyupdater.NewState(apiCaller), a.CurrentConfig()) 30 if err != nil { 31 return nil, errors.Annotate(err, "cannot start ssh auth-keys updater worker") 32 } 33 return w, nil 34 }