forked from harness/gitness
/
nodes.go
50 lines (37 loc) · 1.12 KB
/
nodes.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
package store
import (
"github.com/CiscoCloud/drone/model"
"golang.org/x/net/context"
)
type NodeStore interface {
// Get gets a user by unique ID.
Get(int64) (*model.Node, error)
// GetList gets a list of all nodes in the system.
GetList() ([]*model.Node, error)
// Count gets a count of all nodes in the system.
Count() (int, error)
// Create creates a node.
Create(*model.Node) error
// Update updates a node.
Update(*model.Node) error
// Delete deletes a node.
Delete(*model.Node) error
}
func GetNode(c context.Context, id int64) (*model.Node, error) {
return FromContext(c).Nodes().Get(id)
}
func GetNodeList(c context.Context) ([]*model.Node, error) {
return FromContext(c).Nodes().GetList()
}
func CountNodes(c context.Context) (int, error) {
return FromContext(c).Nodes().Count()
}
func CreateNode(c context.Context, node *model.Node) error {
return FromContext(c).Nodes().Create(node)
}
func UpdateNode(c context.Context, node *model.Node) error {
return FromContext(c).Nodes().Update(node)
}
func DeleteNode(c context.Context, node *model.Node) error {
return FromContext(c).Nodes().Delete(node)
}