forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
minimum_api_version_not_met_error.go
33 lines (30 loc) · 1.08 KB
/
minimum_api_version_not_met_error.go
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
package translatableerror
type MinimumAPIVersionNotMetError struct {
Command string
CurrentVersion string
MinimumVersion string
}
func (e MinimumAPIVersionNotMetError) Error() string {
switch {
case e.Command != "" && e.CurrentVersion != "":
return "{{.Command}} requires CF API version {{.MinimumVersion}} or higher. Your target is {{.CurrentVersion}}."
case e.Command != "" && e.CurrentVersion == "":
return "{{.Command}} requires CF API version {{.MinimumVersion}} or higher."
case e.Command == "" && e.CurrentVersion != "":
return "This command requires CF API version {{.MinimumVersion}} or higher. Your target is {{.CurrentVersion}}."
default:
return "This command requires CF API version {{.MinimumVersion}} or higher."
}
}
func (e MinimumAPIVersionNotMetError) Translate(translate func(string, ...interface{}) string) string {
vars := map[string]interface{}{
"MinimumVersion": e.MinimumVersion,
}
if e.CurrentVersion != "" {
vars["CurrentVersion"] = e.CurrentVersion
}
if e.Command != "" {
vars["Command"] = e.Command
}
return translate(e.Error(), vars)
}