github.com/deis/deis@v1.13.5-0.20170519182049-1d9e59fbdbfc/client/cmd/domains.go (about) 1 package cmd 2 3 import ( 4 "fmt" 5 "sort" 6 7 "github.com/deis/deis/client/controller/models/domains" 8 ) 9 10 // DomainsList lists domains registered with an app. 11 func DomainsList(appID string, results int) error { 12 c, appID, err := load(appID) 13 14 if err != nil { 15 return err 16 } 17 18 if results == defaultLimit { 19 results = c.ResponseLimit 20 } 21 22 domains, count, err := domains.List(c, appID, results) 23 24 if err != nil { 25 return err 26 } 27 28 fmt.Printf("=== %s Domains%s", appID, limitCount(len(domains), count)) 29 30 sort.Sort(domains) 31 32 for _, domain := range domains { 33 fmt.Println(domain.Domain) 34 } 35 return nil 36 } 37 38 // DomainsAdd adds a domain to an app. 39 func DomainsAdd(appID, domain string) error { 40 c, appID, err := load(appID) 41 42 if err != nil { 43 return err 44 } 45 46 fmt.Printf("Adding %s to %s... ", domain, appID) 47 48 quit := progress() 49 _, err = domains.New(c, appID, domain) 50 quit <- true 51 <-quit 52 53 if err != nil { 54 return err 55 } 56 57 fmt.Println("done") 58 return nil 59 } 60 61 // DomainsRemove removes a domain registered with an app. 62 func DomainsRemove(appID, domain string) error { 63 c, appID, err := load(appID) 64 65 if err != nil { 66 return err 67 } 68 69 fmt.Printf("Removing %s from %s... ", domain, appID) 70 71 quit := progress() 72 err = domains.Delete(c, appID, domain) 73 quit <- true 74 <-quit 75 76 if err != nil { 77 return err 78 } 79 80 fmt.Println("done") 81 return nil 82 }