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