in linter/main.go [149:174]
func PresubmitMakeTargetCheck(jc *JobConstants) presubmitCheck {
return presubmitCheck(func(presubmitConfig config.Presubmit, fileContentsString string) (bool, int, string) {
if strings.Contains(presubmitConfig.JobBase.Name, "lint") {
return true, 0, ""
}
jobMakeTargetMatches := regexp.MustCompile(`make (\w+[-\w]+?) .*`).FindStringSubmatch(strings.Join(presubmitConfig.JobBase.Spec.Containers[0].Command, " "))
jobMakeTarget := jobMakeTargetMatches[len(jobMakeTargetMatches)-1]
makeCommandLineNo := findLineNumber(fileContentsString, "make")
if strings.Contains(presubmitConfig.JobBase.Name, "helm-chart") {
if jobMakeTarget != jc.HelmMakeTarget {
return false, makeCommandLineNo, fmt.Sprintf(`Invalid make target, please use the "%s" target`, jc.HelmMakeTarget)
}
} else if strings.Contains(presubmitConfig.JobBase.Name, "release-tooling") {
if jobMakeTarget != jc.ReleaseToolingMakeTarget {
return false, makeCommandLineNo, fmt.Sprintf(`Invalid make target, please use the "%s" target`, jc.ReleaseToolingMakeTarget)
}
} else if strings.Contains(presubmitConfig.JobBase.Name, "test") {
if jobMakeTarget != jc.TestsMakeTarget {
return false, makeCommandLineNo, fmt.Sprintf(`Invalid make target, please use the "%s" target`, jc.TestsMakeTarget)
}
} else if jobMakeTarget != jc.DefaultMakeTarget {
return false, makeCommandLineNo, fmt.Sprintf(`Invalid make target, please use the "%s" target`, jc.DefaultMakeTarget)
}
return true, 0, ""
})
}