@@ -28,20 +28,20 @@ const (
28
28
CurrentVersion = "0.8.0"
29
29
30
30
// vCurrent is the current version as a semver-comparable type
31
- vCurrent Version = "v" + CurrentVersion
31
+ vCurrent version = "v" + CurrentVersion
32
32
33
33
// These represent the released versions of the CDI specification
34
- v010 Version = "v0.1.0"
35
- v020 Version = "v0.2.0"
36
- v030 Version = "v0.3.0"
37
- v040 Version = "v0.4.0"
38
- v050 Version = "v0.5.0"
39
- v060 Version = "v0.6.0"
40
- v070 Version = "v0.7.0"
41
- v080 Version = "v0.8.0"
34
+ v010 version = "v0.1.0"
35
+ v020 version = "v0.2.0"
36
+ v030 version = "v0.3.0"
37
+ v040 version = "v0.4.0"
38
+ v050 version = "v0.5.0"
39
+ v060 version = "v0.6.0"
40
+ v070 version = "v0.7.0"
41
+ v080 version = "v0.8.0"
42
42
43
43
// vEarliest is the earliest supported version of the CDI specification
44
- vEarliest Version = v030
44
+ vEarliest version = v030
45
45
)
46
46
47
47
// validSpecVersions stores a map of spec versions to functions to check the required versions.
@@ -72,44 +72,44 @@ func MinimumRequiredVersion(spec *Spec) (string, error) {
72
72
return minVersion .String (), nil
73
73
}
74
74
75
- // Version represents a semantic version string
76
- type Version string
75
+ // version represents a semantic version string
76
+ type version string
77
77
78
- // NewVersion creates a version that can be used for semantic version comparisons.
79
- func NewVersion (v string ) Version {
80
- return Version ("v" + strings .TrimPrefix (v , "v" ))
78
+ // newVersion creates a version that can be used for semantic version comparisons.
79
+ func newVersion (v string ) version {
80
+ return version ("v" + strings .TrimPrefix (v , "v" ))
81
81
}
82
82
83
83
// String returns the string representation of the version.
84
84
// This trims a leading v if present.
85
- func (v Version ) String () string {
85
+ func (v version ) String () string {
86
86
return strings .TrimPrefix (string (v ), "v" )
87
87
}
88
88
89
89
// IsGreaterThan checks with a version is greater than the specified version.
90
- func (v Version ) IsGreaterThan (o Version ) bool {
90
+ func (v version ) IsGreaterThan (o version ) bool {
91
91
return semver .Compare (string (v ), string (o )) > 0
92
92
}
93
93
94
94
// IsLatest checks whether the version is the latest supported version
95
- func (v Version ) IsLatest () bool {
95
+ func (v version ) IsLatest () bool {
96
96
return v == vCurrent
97
97
}
98
98
99
99
type requiredFunc func (* Spec ) bool
100
100
101
- type requiredVersionMap map [Version ]requiredFunc
101
+ type requiredVersionMap map [version ]requiredFunc
102
102
103
103
// isValidVersion checks whether the specified version is valid.
104
104
// A version is valid if it is contained in the required version map.
105
105
func (r requiredVersionMap ) isValidVersion (specVersion string ) bool {
106
- _ , ok := validSpecVersions [NewVersion (specVersion )]
106
+ _ , ok := validSpecVersions [newVersion (specVersion )]
107
107
108
108
return ok
109
109
}
110
110
111
111
// requiredVersion returns the minimum version required for the given spec
112
- func (r requiredVersionMap ) requiredVersion (spec * Spec ) Version {
112
+ func (r requiredVersionMap ) requiredVersion (spec * Spec ) version {
113
113
minVersion := vEarliest
114
114
115
115
for v , isRequired := range validSpecVersions {
0 commit comments