Update osrelease and redhatrelease detectors to detect Oracle Linux as well.
This commit is contained in:
parent
8e1fe0d01f
commit
5eb57fee37
@ -85,5 +85,5 @@ func (detector *OsReleaseNamespaceDetector) GetRequiredFiles() []string {
|
||||
|
||||
// getExcludeFiles returns the list of files that are ought to exclude this detector from Detect()
|
||||
func (detector *OsReleaseNamespaceDetector) getExcludeFiles() []string {
|
||||
return []string{"etc/redhat-release", "usr/lib/centos-release"}
|
||||
return []string{"etc/oracle-release", "etc/redhat-release", "usr/lib/centos-release"}
|
||||
}
|
||||
|
@ -26,17 +26,19 @@ import (
|
||||
var (
|
||||
log = capnslog.NewPackageLogger("github.com/coreos/clair", "worker/detectors/namespace/redhatrelease")
|
||||
|
||||
oracleReleaseRegexp = regexp.MustCompile(`(?P<os>[^\s]*) (Linux Server release) (?P<version>[\d]+)`)
|
||||
centosReleaseRegexp = regexp.MustCompile(`(?P<os>[^\s]*) (Linux release|release) (?P<version>[\d]+)`)
|
||||
redhatReleaseRegexp = regexp.MustCompile(`(?P<os>Red Hat Enterprise Linux) (Client release|Server release|Workstation release) (?P<version>[\d]+)`)
|
||||
)
|
||||
|
||||
// RedhatReleaseNamespaceDetector implements NamespaceDetector and detects the OS from the
|
||||
// /etc/centos-release, /etc/redhat-release and /etc/system-release files.
|
||||
// /etc/oracle-release, /etc/centos-release, /etc/redhat-release and /etc/system-release files.
|
||||
//
|
||||
// Typically for CentOS and Red-Hat like systems
|
||||
// eg. CentOS release 5.11 (Final)
|
||||
// eg. CentOS release 6.6 (Final)
|
||||
// eg. CentOS Linux release 7.1.1503 (Core)
|
||||
// eg. Oracle Linux Server release 7.3
|
||||
// eg. Red Hat Enterprise Linux Server release 7.2 (Maipo)
|
||||
type RedhatReleaseNamespaceDetector struct{}
|
||||
|
||||
@ -53,6 +55,12 @@ func (detector *RedhatReleaseNamespaceDetector) Detect(data map[string][]byte) *
|
||||
|
||||
var r []string
|
||||
|
||||
// try for Oracle Linux
|
||||
r = oracleReleaseRegexp.FindStringSubmatch(string(f))
|
||||
if len(r) == 4 {
|
||||
return &database.Namespace{Name: strings.ToLower(r[1]) + ":" + r[3]}
|
||||
}
|
||||
|
||||
// try for RHEL
|
||||
r = redhatReleaseRegexp.FindStringSubmatch(string(f))
|
||||
if len(r) == 4 {
|
||||
@ -73,5 +81,5 @@ func (detector *RedhatReleaseNamespaceDetector) Detect(data map[string][]byte) *
|
||||
|
||||
// GetRequiredFiles returns the list of files that are required for Detect()
|
||||
func (detector *RedhatReleaseNamespaceDetector) GetRequiredFiles() []string {
|
||||
return []string{"etc/centos-release", "etc/redhat-release", "etc/system-release"}
|
||||
return []string{"etc/oracle-release", "etc/centos-release", "etc/redhat-release", "etc/system-release"}
|
||||
}
|
||||
|
@ -23,6 +23,18 @@ import (
|
||||
|
||||
func TestRedhatReleaseNamespaceDetector(t *testing.T) {
|
||||
testData := []namespace.TestData{
|
||||
{
|
||||
ExpectedNamespace: &database.Namespace{Name: "oracle:6"},
|
||||
Data: map[string][]byte{
|
||||
"etc/oracle-release": []byte(`Oracle Linux Server release 6.8`),
|
||||
},
|
||||
},
|
||||
{
|
||||
ExpectedNamespace: &database.Namespace{Name: "oracle:7"},
|
||||
Data: map[string][]byte{
|
||||
"etc/oracle-release": []byte(`Oracle Linux Server release 7.2`),
|
||||
},
|
||||
},
|
||||
{
|
||||
ExpectedNamespace: &database.Namespace{Name: "centos:6"},
|
||||
Data: map[string][]byte{
|
||||
|
Loading…
Reference in New Issue
Block a user