-
Notifications
You must be signed in to change notification settings - Fork 24
/
repo.go
44 lines (37 loc) · 977 Bytes
/
repo.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
package main
import "log"
func RepoIndexEnvironments() []*Environment {
e, derr := config.Persistence.GetAllEnvironments()
if derr != nil {
log.Fatal(derr)
}
return e
}
func RepoFindEnvironment(id int) *Environment {
e, derr := config.Persistence.GetEnvironment(id)
if derr != nil {
log.Fatal(derr)
}
return e
}
//RepoCreateEnvironment - this is bad, I don't think it passes race condtions
func RepoCreateEnvironment(e Environment) Environment {
derr := config.Persistence.PutEnvironment(&e)
if derr != nil {
log.Fatal(derr)
}
return e
}
func RepoHookHandler(c Change) Change {
derr := c.handleHook(config.Persistence)
if derr != nil {
log.Fatal(derr)
}
return c
}
func RepoTerraformAction(action Action) error {
safeEnvironment := GetSingletonSafeEnvironment(action.ID)
// TODO: Consider similar approach to http://nesv.github.io/golang/2014/02/25/worker-queues-in-go.html
go safeEnvironment.Execute(nil, action.SetExitCodes())
return nil
}