-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlatestpatchdjango.go
58 lines (50 loc) · 1.53 KB
/
latestpatchdjango.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
53
54
55
56
57
58
package main
import (
"cuddly-eureka-/conf/initialize"
"cuddly-eureka-/github"
"cuddly-eureka-/http"
"cuddly-eureka-/types"
"cuddly-eureka-/util"
"fmt"
)
type LatestPatchDjango struct {
}
func checkVersionFromRequirementsTxt(g *github.GitHub, repoName, gitHubOwner string) (*string, bool) {
requirements, err := g.GetRequirementsTxt(repoName, gitHubOwner)
if err != nil {
fmt.Printf("Warning: Failed to read requirement.txt for %s\n", repoName)
return nil, false
}
version := util.GetVersionFromRequirementsTxt(*requirements, "django")
if version != nil {
return version, true
}
return nil, false
}
func (lpd LatestPatchDjango) Check(repoName string, opts ...*string) types.MaturityCheck {
app := initialize.GetAppConstants()
g := &github.GitHub{}
g = g.Init(app.GitHubToken)
eolDetails, eolErr := http.EOLProvider(http.EOLDjango)
if eolErr != nil {
panic("Failed to find EOL details for " + http.EOLDjango + " ")
}
var existingVersion *string
// 1 - Check requirements.txt
versionFromRequirements, versionFoundFromRequirements := checkVersionFromRequirementsTxt(g, repoName, app.GitHubOwner)
if versionFoundFromRequirements {
existingVersion = versionFromRequirements
}
if existingVersion != nil {
mValue := util.IsUsingLatestPatchVersion(*existingVersion, eolDetails)
return mValue
}
return types.MaturityValue0
}
func (lpd LatestPatchDjango) Meta() types.MaturityMeta {
return types.MaturityMeta{
Type: types.MaturityTypeDependency,
Name: "Uses latest patch version: Django",
}
}
var Check LatestPatchDjango