-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdomains.go
More file actions
86 lines (70 loc) · 1.77 KB
/
domains.go
File metadata and controls
86 lines (70 loc) · 1.77 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
78
79
80
81
82
83
84
85
86
package cmd
import (
"fmt"
"github.com/drycc/controller-sdk-go/domains"
)
// DomainsList lists domains registered with an app.
func (d *DryccCmd) DomainsList(appID string, results int) error {
s, appID, err := load(d.ConfigFile, appID)
if err != nil {
return err
}
if results == defaultLimit {
results = s.Limit
}
domains, count, err := domains.List(s.Client, appID, results)
if d.checkAPICompatibility(s.Client, err) != nil {
return err
}
if count > 0 {
table := d.getDefaultFormatTable([]string{"APP", "OWNER", "PTYPE", "CREATED", "UPDATED", "DOMAIN"})
for _, domain := range domains {
table.Append([]string{
domain.App,
domain.Owner,
domain.ProcfileType,
d.formatTime(domain.Created),
d.formatTime(domain.Updated),
domain.Domain,
})
}
table.Render()
} else {
d.Println(fmt.Sprintf("No domains found in %s app.", appID))
}
return nil
}
// DomainsAdd adds a domain to an app.
func (d *DryccCmd) DomainsAdd(appID, domain, procfileType string) error {
s, appID, err := load(d.ConfigFile, appID)
if err != nil {
return err
}
d.Printf("Adding %s to %s... ", domain, appID)
quit := progress(d.WOut)
_, err = domains.New(s.Client, appID, domain, procfileType)
quit <- true
<-quit
if d.checkAPICompatibility(s.Client, err) != nil {
return err
}
d.Println("done")
return nil
}
// DomainsRemove removes a domain registered with an app.
func (d *DryccCmd) DomainsRemove(appID, domain string) error {
s, appID, err := load(d.ConfigFile, appID)
if err != nil {
return err
}
d.Printf("Removing %s from %s... ", domain, appID)
quit := progress(d.WOut)
err = domains.Delete(s.Client, appID, domain)
quit <- true
<-quit
if d.checkAPICompatibility(s.Client, err) != nil {
return err
}
d.Println("done")
return nil
}