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