-
Notifications
You must be signed in to change notification settings - Fork 0
/
wd_version.go
39 lines (31 loc) · 1.42 KB
/
wd_version.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
package wd_info
import (
"fmt"
"github.com/woodpecker-kit/woodpecker-tools/wd_flag"
)
const WoodpeckerInfoSupportVersion = "2.3.0"
// CiSystemVersionMinimumSupport
// this function is used to check the ci system version by wd_info.WoodpeckerInfoSupportVersion
//
// if the ci system version is empty, return error
// if the ci system version is not supported, return error
// if version is less than wd_info.WoodpeckerInfoSupportVersion, return error
// if the ci system version is supported, return nil
func CiSystemVersionMinimumSupport(info WoodpeckerInfo) error {
if info.CiSystemInfo.CiSystemVersion == "" {
return fmt.Errorf("woodpeacker ci system version is empty, please set env %s", wd_flag.EnvKeyCiSystemVersion)
}
return SemverVersionMinimumSupport(info.CiSystemInfo.CiSystemVersion, WoodpeckerInfoSupportVersion)
}
// CiSystemVersionConstraint
// this function is used to check the ci system version by constraint
//
// if the ci system version is empty, return error
// if the ci system version is not pass, return error
// if the ci system version is pass, return nil
func CiSystemVersionConstraint(info WoodpeckerInfo, minimumVersion, maximumVersion string) error {
if info.CiSystemInfo.CiSystemVersion == "" {
return fmt.Errorf("woodpeacker ci system version is empty, please set env %s", wd_flag.EnvKeyCiSystemVersion)
}
return SemverVersionConstraint(info.CiSystemInfo.CiSystemVersion, minimumVersion, maximumVersion)
}