forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminimum_version_check.go
53 lines (44 loc) · 1.35 KB
/
minimum_version_check.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package command
import (
"code.cloudfoundry.org/cli/command/translatableerror"
log "github.com/sirupsen/logrus"
)
func MinimumCCAPIVersionCheck(current string, minimum string, customCommand ...string) error {
log.WithFields(log.Fields{"current": current, "minimum": minimum}).Debug("minimum api version")
var command string
if len(customCommand) > 0 {
command = customCommand[0]
}
isOutdated, err := CheckVersionOutdated(current, minimum)
if err != nil {
return err
}
if isOutdated {
log.WithFields(log.Fields{"current": current, "minimum": minimum}).Error("minimum not met")
return translatableerror.MinimumCFAPIVersionNotMetError{
Command: command,
CurrentVersion: current,
MinimumVersion: minimum,
}
}
return nil
}
func MinimumUAAAPIVersionCheck(current string, minimum string, customCommand ...string) error {
log.WithFields(log.Fields{"current": current, "minimum": minimum}).Debug("minimum api version")
var command string
if len(customCommand) > 0 {
command = customCommand[0]
}
isOutdated, err := CheckVersionOutdated(current, minimum)
if err != nil {
return err
}
if isOutdated {
log.WithFields(log.Fields{"current": current, "minimum": minimum}).Error("minimum not met")
return translatableerror.MinimumUAAAPIVersionNotMetError{
Command: command,
MinimumVersion: minimum,
}
}
return nil
}