1
// Copyright 2016 Canonical Ltd.
2
// Licensed under the AGPLv3, see LICENCE file for details.
7
"github.com/juju/juju/agent"
8
"github.com/juju/juju/api/base"
9
"github.com/juju/juju/worker"
10
"github.com/juju/juju/worker/dependency"
13
// Many manifolds completely depend on an agent and an API connection; this
14
// type configures them.
15
type AgentApiManifoldConfig struct {
20
// AgentApiStartFunc encapsulates the behaviour that varies among AgentApiManifolds.
21
type AgentApiStartFunc func(agent.Agent, base.APICaller) (worker.Worker, error)
23
// AgentApiManifold returns a dependency.Manifold that calls the supplied start
24
// func with the API and agent resources defined in the config (once those
25
// resources are present).
26
func AgentApiManifold(config AgentApiManifoldConfig, start AgentApiStartFunc) dependency.Manifold {
27
return dependency.Manifold{
32
Start: func(context dependency.Context) (worker.Worker, error) {
34
if err := context.Get(config.AgentName, &agent); err != nil {
37
var apiCaller base.APICaller
38
if err := context.Get(config.APICallerName, &apiCaller); err != nil {
41
return start(agent, apiCaller)