-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathservices.go
More file actions
77 lines (60 loc) · 1.65 KB
/
services.go
File metadata and controls
77 lines (60 loc) · 1.65 KB
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
package cmd
import (
"fmt"
"github.com/drycc/pkg/prettyprint"
"github.com/drycc/controller-sdk-go/services"
)
// ServicesList lists extra services for the app
func (d *DryccCmd) ServicesList(appID string) error {
s, appID, err := load(d.ConfigFile, appID)
if err != nil {
return err
}
services, err := services.List(s.Client, appID)
if d.checkAPICompatibility(s.Client, err) != nil {
return err
}
d.Printf("=== %s Services\n", appID)
servicesMap := make(map[string]string)
if len(services) > 0 {
for _, service := range services {
servicesMap[service.ProcfileType] = fmt.Sprintf("%v", service.PathPattern)
}
d.Print(prettyprint.PrettyTabs(servicesMap, 5))
}
return nil
}
// ServicesAdd adds a service to an app.
func (d *DryccCmd) ServicesAdd(appID, procfileType string, pathPattern string) error {
s, appID, err := load(d.ConfigFile, appID)
if err != nil {
return err
}
d.Printf("Adding %s (%s) to %s... ", procfileType, pathPattern, appID)
quit := progress(d.WOut)
_, err = services.New(s.Client, appID, procfileType, pathPattern)
quit <- true
<-quit
if d.checkAPICompatibility(s.Client, err) != nil {
return err
}
d.Println("done")
return nil
}
// ServicesRemove removes a service for procfileType registered with an app.
func (d *DryccCmd) ServicesRemove(appID, procfileType string) error {
s, appID, err := load(d.ConfigFile, appID)
if err != nil {
return err
}
d.Printf("Removing %s from %s... ", procfileType, appID)
quit := progress(d.WOut)
err = services.Delete(s.Client, appID, procfileType)
quit <- true
<-quit
if d.checkAPICompatibility(s.Client, err) != nil {
return err
}
d.Println("done")
return nil
}