github.com/naphatkrit/deis@v1.12.3/client/cmd/releases.go (about) 1 package cmd 2 3 import ( 4 "fmt" 5 "os" 6 "text/tabwriter" 7 8 "github.com/deis/deis/client/controller/models/releases" 9 ) 10 11 // ReleasesList lists an app's releases. 12 func ReleasesList(appID string, results int) error { 13 c, appID, err := load(appID) 14 15 if err != nil { 16 return err 17 } 18 19 if results == defaultLimit { 20 results = c.ResponseLimit 21 } 22 23 releases, count, err := releases.List(c, appID, results) 24 25 fmt.Printf("=== %s Releases%s", appID, limitCount(len(releases), count)) 26 27 w := new(tabwriter.Writer) 28 29 w.Init(os.Stdout, 0, 8, 1, '\t', 0) 30 for _, r := range releases { 31 fmt.Fprintf(w, "v%d\t%s\t%s\n", r.Version, r.Created, r.Summary) 32 } 33 w.Flush() 34 return nil 35 } 36 37 // ReleasesInfo prints info about a specific release. 38 func ReleasesInfo(appID string, version int) error { 39 c, appID, err := load(appID) 40 41 if err != nil { 42 return err 43 } 44 45 r, err := releases.Get(c, appID, version) 46 47 if err != nil { 48 return err 49 } 50 51 fmt.Printf("=== %s Release v%d\n", appID, version) 52 if r.Build != "" { 53 fmt.Println("build: ", r.Build) 54 } 55 fmt.Println("config: ", r.Config) 56 fmt.Println("owner: ", r.Owner) 57 fmt.Println("created: ", r.Created) 58 fmt.Println("summary: ", r.Summary) 59 fmt.Println("updated: ", r.Updated) 60 fmt.Println("uuid: ", r.UUID) 61 62 return nil 63 } 64 65 // ReleasesRollback rolls an app back to a previous release. 66 func ReleasesRollback(appID string, version int) error { 67 c, appID, err := load(appID) 68 69 if err != nil { 70 return err 71 } 72 73 if version == -1 { 74 fmt.Print("Rolling back one release... ") 75 } else { 76 fmt.Printf("Rolling back to v%d... ", version) 77 } 78 79 quit := progress() 80 newVersion, err := releases.Rollback(c, appID, version) 81 quit <- true 82 <-quit 83 84 if err != nil { 85 return err 86 } 87 88 fmt.Printf("done, v%d\n", newVersion) 89 90 return nil 91 }