-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
triggers.go
79 lines (63 loc) · 1.81 KB
/
triggers.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
package common
import (
"fmt"
)
// TriggerAppList outputs each app name to stdout on a newline
func TriggerAppList(filtered bool) error {
var apps []string
if filtered {
apps, _ = DokkuApps()
} else {
apps, _ = UnfilteredDokkuApps()
}
for _, app := range apps {
Log(app)
}
return nil
}
// TriggerCorePostDeploy associates the container with a specified network
func TriggerCorePostDeploy(appName string) error {
return EnvWrap(func() error {
CommandPropertySet("common", appName, "deployed", "true", DefaultProperties, GlobalProperties)
return nil
}, map[string]string{"DOKKU_QUIET_OUTPUT": "1"})
}
// TriggerInstall runs the install step for the common plugin
func TriggerInstall() error {
if err := PropertySetup("common"); err != nil {
return fmt.Errorf("Unable to install the common plugin: %s", err.Error())
}
apps, err := UnfilteredDokkuApps()
if err != nil {
return nil
}
// migrate all is-deployed values from trigger to property
for _, appName := range apps {
IsDeployed(appName)
}
return nil
}
// TriggerPostAppCloneSetup copies common files
func TriggerPostAppCloneSetup(oldAppName string, newAppName string) error {
if err := PropertyClone("common", oldAppName, newAppName); err != nil {
return err
}
if err := PropertyDelete("common", oldAppName, "deployed"); err != nil {
return err
}
return nil
}
// TriggerPostAppRenameSetup renames common files
func TriggerPostAppRenameSetup(oldAppName string, newAppName string) error {
if err := PropertyClone("common", oldAppName, newAppName); err != nil {
return err
}
if err := PropertyDestroy("common", oldAppName); err != nil {
return err
}
return nil
}
// TriggerPostDelete destroys the common property for a given app container
func TriggerPostDelete(appName string) error {
return PropertyDestroy("common", appName)
}