/
interface.go
62 lines (52 loc) · 1.79 KB
/
interface.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
// Copyright 2019 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package modelgeneration
import (
"github.com/juju/charm/v12"
"github.com/juju/names/v5"
"github.com/juju/juju/core/cache"
"github.com/juju/juju/core/settings"
)
//go:generate go run go.uber.org/mock/mockgen -package mocks -destination mocks/package_mock.go github.com/juju/juju/apiserver/facades/client/modelgeneration State,Model,Generation,Application,ModelCache
// State represents the state of a model required by the model generation API.
type State interface {
ControllerTag() names.ControllerTag
Model() (Model, error)
Application(string) (Application, error)
}
// Model describes model state used by the model generation API.
type Model interface {
ModelTag() names.ModelTag
AddBranch(string, string) error
Branch(string) (Generation, error)
Branches() ([]Generation, error)
Generation(int) (Generation, error)
Generations() ([]Generation, error)
}
// ModelCache describes a cached model used by the model generation API.
type ModelCache interface {
Branch(string) (cache.Branch, error)
}
// Generation defines the methods used by a generation.
type Generation interface {
BranchName() string
Created() int64
CreatedBy() string
Completed() int64
CompletedBy() string
AssignAllUnits(string) error
AssignUnits(string, int) error
AssignUnit(string) error
AssignedUnits() map[string][]string
Commit(string) (int, error)
Abort(string) error
Config() map[string]settings.ItemChanges
GenerationId() int
}
// Application describes application state used by the model generation API.
type Application interface {
UnitNames() ([]string, error)
// DefaultCharmConfig is the only abstraction in these shims.
// It saves us having to shim out Charm as well.
DefaultCharmConfig() (charm.Settings, error)
}