-
Notifications
You must be signed in to change notification settings - Fork 0
/
shim.go
34 lines (29 loc) · 995 Bytes
/
shim.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 2016 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package singular
import (
"github.com/juju/errors"
"gopkg.in/juju/names.v2"
"gopkg.in/juju/worker.v1"
"github.com/juju/juju/api/base"
"github.com/juju/juju/api/singular"
)
// NewFacade creates a Facade from an APICaller and an entity for which
// administrative control will be claimed. It's a suitable default value
// for ManifoldConfig.NewFacade.
func NewFacade(apiCaller base.APICaller, claimant names.MachineTag, entity names.Tag) (Facade, error) {
facade, err := singular.NewAPI(apiCaller, claimant, entity)
if err != nil {
return nil, errors.Trace(err)
}
return facade, nil
}
// NewWorker calls NewFlagWorker but returns a more convenient type. It's
// a suitable default value for ManifoldConfig.NewWorker.
func NewWorker(config FlagConfig) (worker.Worker, error) {
worker, err := NewFlagWorker(config)
if err != nil {
return nil, errors.Trace(err)
}
return worker, nil
}