-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathutils.go
More file actions
94 lines (77 loc) · 1.83 KB
/
utils.go
File metadata and controls
94 lines (77 loc) · 1.83 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
92
93
94
package cmd
import (
"fmt"
"io"
"os"
"strings"
"time"
deis "github.com/deis/controller-sdk-go"
"github.com/deis/workflow-cli/pkg/git"
"github.com/deis/workflow-cli/settings"
)
var defaultLimit = -1
func progress(wOut io.Writer) chan bool {
frames := []string{"...", "o..", ".o.", "..o"}
backspaces := strings.Repeat("\b", 3)
tick := time.Tick(400 * time.Millisecond)
quit := make(chan bool)
go func() {
for {
for _, frame := range frames {
fmt.Fprint(wOut, frame)
select {
case <-quit:
fmt.Fprint(wOut, backspaces)
close(quit)
return
case <-tick:
fmt.Fprint(wOut, backspaces)
}
}
}
}()
return quit
}
// load loads settings file and looks up the app name
func load(cf string, appID string) (*settings.Settings, string, error) {
s, err := settings.Load(cf)
if err != nil {
return nil, "", err
}
if appID == "" {
appID, err = git.DetectAppName(git.DefaultCmd, s.Client.ControllerURL.Host)
if err != nil {
return nil, "", err
}
}
return s, appID, nil
}
func drinkOfChoice() string {
drink := os.Getenv("DEIS_DRINK_OF_CHOICE")
if drink == "" {
drink = "coffee"
}
return drink
}
func limitCount(objs, total int) string {
if objs == total {
return "\n"
}
return fmt.Sprintf(" (%d of %d)\n", objs, total)
}
// checkAPICompatibility handles specific behavior for certain errors,
// such as printing an warning for the API mismatch error
func (d *DeisCmd) checkAPICompatibility(c *deis.Client, err error) error {
if err == deis.ErrAPIMismatch {
if !d.Warned {
d.PrintErrf(`! WARNING: Client and server API versions do not match. Please consider upgrading.
! Client version: %s
! Server version: %s
`, deis.APIVersion, c.ControllerAPIVersion)
d.Warned = true
}
// API mismatch isn't fatal, so after warning continue on.
return nil
}
return err
}