feat(report): display EOL information to scan summary (#1120)

* feat(report): display EOL information to scan summary

* detect Amazon linux EOL
This commit is contained in:
Kota Kanbe
2021-01-09 07:58:55 +09:00
committed by GitHub
parent 69d32d4511
commit 6eff6a9329
11 changed files with 648 additions and 108 deletions

View File

@@ -163,3 +163,17 @@ func Distinct(ss []string) (distincted []string) {
}
return
}
func Major(version string) string {
if version == "" {
return ""
}
ss := strings.SplitN(version, ":", 2)
ver := ""
if len(ss) == 1 {
ver = ss[0]
} else {
ver = ss[1]
}
return ver[0:strings.Index(ver, ".")]
}

View File

@@ -154,3 +154,29 @@ func TestTruncate(t *testing.T) {
}
}
}
func Test_major(t *testing.T) {
var tests = []struct {
in string
expected string
}{
{
in: "",
expected: "",
},
{
in: "4.1",
expected: "4",
},
{
in: "0:4.1",
expected: "4",
},
}
for i, tt := range tests {
a := Major(tt.in)
if tt.expected != a {
t.Errorf("[%d]\nexpected: %s\n actual: %s\n", i, tt.expected, a)
}
}
}