-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstate.go
54 lines (44 loc) · 1.22 KB
/
state.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
// Copyright 2020 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package space
import (
"github.com/juju/errors"
"github.com/juju/juju/core/network"
"github.com/juju/juju/state"
)
type spaceStateShim struct {
*state.State
}
// NewState creates a space state shim.
func NewState(st *state.State) *spaceStateShim {
return &spaceStateShim{st}
}
func (s *spaceStateShim) AllSpaces() ([]Space, error) {
spaces, err := s.State.AllSpaces()
if err != nil {
return nil, errors.Trace(err)
}
results := make([]Space, len(spaces))
for i, space := range spaces {
results[i] = space
}
return results, nil
}
func (s *spaceStateShim) AddSpace(name string, providerID network.Id, subnetIds []string, public bool) (Space, error) {
result, err := s.State.AddSpace(name, providerID, subnetIds, public)
if err != nil {
return nil, errors.Trace(err)
}
return result, nil
}
func (s *spaceStateShim) ConstraintsBySpaceName(name string) ([]Constraints, error) {
constraints, err := s.State.ConstraintsBySpaceName(name)
if err != nil {
return nil, errors.Trace(err)
}
results := make([]Constraints, len(constraints))
for i, constraint := range constraints {
results[i] = constraint
}
return results, nil
}