-
Notifications
You must be signed in to change notification settings - Fork 1
/
software.go
52 lines (45 loc) · 1.37 KB
/
software.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
package software
import (
"fmt"
)
type SoftwaresToUpdate struct {
Softwares []Software
}
type CalculatorType string
const (
// Augmented Semver: for softwares where minor versions are considered major versions (ex: kubernetes 1.21 -> 1.22)
AugmentedSemverCalculator CalculatorType = "augmented-semver"
CandidateCountCalculator CalculatorType = "candidate-count"
MetaCalculator CalculatorType = "meta"
ReleaseDateCalculator CalculatorType = "release-date"
SemverCalculator CalculatorType = "semver"
SkipCalculator CalculatorType = "skip"
)
type SoftwareType string
type Software struct {
Calculator CalculatorType
CalculatedScore int
Dependencies []*Software
Name string
Type SoftwareType
Version Version
VersionCandidates []Version
}
func ToCalculator(name string) (CalculatorType, error) {
switch name {
case string(SkipCalculator):
return SkipCalculator, nil
case string(AugmentedSemverCalculator):
return AugmentedSemverCalculator, nil
case string(CandidateCountCalculator):
return CandidateCountCalculator, nil
case string(MetaCalculator):
return MetaCalculator, nil
case string(ReleaseDateCalculator):
return ReleaseDateCalculator, nil
case string(SemverCalculator):
return SemverCalculator, nil
default:
return "", fmt.Errorf("Unknown calculator %s", name)
}
}