/
client.go
88 lines (76 loc) · 2.34 KB
/
client.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// Copyright 2017 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package caasoperator
import (
"github.com/juju/charm/v12"
"github.com/juju/version/v2"
caasoperatorapi "github.com/juju/juju/api/agent/caasoperator"
"github.com/juju/juju/core/life"
"github.com/juju/juju/core/model"
"github.com/juju/juju/core/status"
"github.com/juju/juju/core/watcher"
)
// Client provides an interface for interacting
// with the CAASOperator API. Subsets of this
// should be passed to the CAASOperator worker.
type Client interface {
CharmGetter
UnitGetter
UnitRemover
ApplicationWatcher
ContainerStartWatcher
StatusSetter
VersionSetter
Model() (*model.Model, error)
}
// CharmGetter provides an interface for getting
// the URL and SHA256 hash of the charm currently
// assigned to the application.
type CharmGetter interface {
Charm(application string) (*caasoperatorapi.CharmInfo, error)
}
// UnitGetter provides an interface for watching for
// the lifecycle state changes (including addition)
// of a specified application's units, and fetching
// their details.
type UnitGetter interface {
WatchUnits(string) (watcher.StringsWatcher, error)
Life(string) (life.Value, error)
}
// UnitRemover provides an interface for
// removing a unit.
type UnitRemover interface {
RemoveUnit(string) error
}
// ApplicationWatcher provides an interface watching
// for application changes.
type ApplicationWatcher interface {
Watch(string) (watcher.NotifyWatcher, error)
}
// ContainerStartWatcher provides an interface for watching
// for unit starts.
type ContainerStartWatcher interface {
WatchContainerStart(string, string) (watcher.StringsWatcher, error)
}
// StatusSetter provides an interface for setting
// the status of a CAAS application.
type StatusSetter interface {
// SetStatus sets the status of an application.
SetStatus(
application string,
status status.Status,
info string,
data map[string]interface{},
) error
}
// CharmConfigGetter provides an interface for
// watching and getting the application's charm config settings.
type CharmConfigGetter interface {
CharmConfig(string) (charm.Settings, error)
WatchCharmConfig(string) (watcher.NotifyWatcher, error)
}
// VersionSetter provides an interface for setting
// the operator agent version.
type VersionSetter interface {
SetVersion(appName string, v version.Binary) error
}