-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathreleases.go
More file actions
91 lines (69 loc) · 1.72 KB
/
releases.go
File metadata and controls
91 lines (69 loc) · 1.72 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
87
88
89
90
91
package cmd
import (
"fmt"
"os"
"text/tabwriter"
"github.com/deis/workflow/client/controller/models/releases"
)
// ReleasesList lists an app's releases.
func ReleasesList(appID string, results int) error {
c, appID, err := load(appID)
if err != nil {
return err
}
if results == defaultLimit {
results = c.ResponseLimit
}
releases, count, err := releases.List(c, appID, results)
fmt.Printf("=== %s Releases%s", appID, limitCount(len(releases), count))
w := new(tabwriter.Writer)
w.Init(os.Stdout, 0, 8, 1, '\t', 0)
for _, r := range releases {
fmt.Fprintf(w, "v%d\t%s\t%s\n", r.Version, r.Created, r.Summary)
}
w.Flush()
return nil
}
// ReleasesInfo prints info about a specific release.
func ReleasesInfo(appID string, version int) error {
c, appID, err := load(appID)
if err != nil {
return err
}
r, err := releases.Get(c, appID, version)
if err != nil {
return err
}
fmt.Printf("=== %s Release v%d\n", appID, version)
if r.Build != "" {
fmt.Println("build: ", r.Build)
}
fmt.Println("config: ", r.Config)
fmt.Println("owner: ", r.Owner)
fmt.Println("created: ", r.Created)
fmt.Println("summary: ", r.Summary)
fmt.Println("updated: ", r.Updated)
fmt.Println("uuid: ", r.UUID)
return nil
}
// ReleasesRollback rolls an app back to a previous release.
func ReleasesRollback(appID string, version int) error {
c, appID, err := load(appID)
if err != nil {
return err
}
if version == -1 {
fmt.Print("Rolling back one release... ")
} else {
fmt.Printf("Rolling back to v%d... ", version)
}
quit := progress()
newVersion, err := releases.Rollback(c, appID, version)
quit <- true
<-quit
if err != nil {
return err
}
fmt.Printf("done, v%d\n", newVersion)
return nil
}