-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathwhitelist.go
More file actions
72 lines (55 loc) · 1.44 KB
/
whitelist.go
File metadata and controls
72 lines (55 loc) · 1.44 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
package cmd
import (
"strings"
"github.com/deis/controller-sdk-go/whitelist"
)
// WhitelistList lists the addresses whitelisted for app
func (d *DeisCmd) WhitelistList(appID string) error {
s, appID, err := load(d.ConfigFile, appID)
if err != nil {
return err
}
whitelist, err := whitelist.List(s.Client, appID)
if d.checkAPICompatibility(s.Client, err) != nil {
return err
}
d.Printf("=== %s Whitelisted Addresses\n", appID)
for _, ip := range whitelist.Addresses {
d.Println(ip)
}
return nil
}
// WhitelistAdd adds the addresses to the app's Whitelist.
func (d *DeisCmd) WhitelistAdd(appID, IPs string) error {
s, appID, err := load(d.ConfigFile, appID)
if err != nil {
return err
}
d.Printf("Adding %s to %s whitelist...\n", IPs, appID)
quit := progress(d.WOut)
_, err = whitelist.Add(s.Client, appID, strings.Split(IPs, ","))
quit <- true
<-quit
if d.checkAPICompatibility(s.Client, err) != nil {
return err
}
d.Println("done")
return nil
}
// WhitelistRemove deletes the addresses from the app's Whitelist.
func (d *DeisCmd) WhitelistRemove(appID, IPs string) error {
s, appID, err := load(d.ConfigFile, appID)
if err != nil {
return err
}
d.Printf("Removing %s from %s whitelist...\n", IPs, appID)
quit := progress(d.WOut)
err = whitelist.Delete(s.Client, appID, strings.Split(IPs, ","))
quit <- true
<-quit
if d.checkAPICompatibility(s.Client, err) != nil {
return err
}
d.Println("done")
return nil
}