mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Close the file after reading in verifydependencies#main
This commit is contained in:
parent
0c91af21b4
commit
a7231fc93a
@ -72,23 +72,26 @@ func main() {
|
|||||||
|
|
||||||
for _, dep := range externalDeps.Dependencies {
|
for _, dep := range externalDeps.Dependencies {
|
||||||
for _, refPath := range dep.RefPaths {
|
for _, refPath := range dep.RefPaths {
|
||||||
file, err := os.Open(refPath.Path)
|
func() {
|
||||||
if err != nil {
|
file, err := os.Open(refPath.Path)
|
||||||
log.Fatalf("error opening file %v : %v", refPath.Path, err)
|
if err != nil {
|
||||||
}
|
log.Fatalf("error opening file %v : %v", refPath.Path, err)
|
||||||
matcher := regexp.MustCompile(refPath.Match)
|
|
||||||
depFileScanner := bufio.NewScanner(file)
|
|
||||||
var found bool
|
|
||||||
for depFileScanner.Scan() {
|
|
||||||
line := depFileScanner.Text()
|
|
||||||
if matcher.MatchString(line) && strings.Contains(line, dep.Version) {
|
|
||||||
found = true
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
defer file.Close()
|
||||||
if !found {
|
matcher := regexp.MustCompile(refPath.Match)
|
||||||
pathsToUpdate = append(pathsToUpdate, refPath.Path)
|
depFileScanner := bufio.NewScanner(file)
|
||||||
}
|
var found bool
|
||||||
|
for depFileScanner.Scan() {
|
||||||
|
line := depFileScanner.Text()
|
||||||
|
if matcher.MatchString(line) && strings.Contains(line, dep.Version) {
|
||||||
|
found = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
pathsToUpdate = append(pathsToUpdate, refPath.Path)
|
||||||
|
}
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
if len(pathsToUpdate) > 0 {
|
if len(pathsToUpdate) > 0 {
|
||||||
log.Fatalf(mismatchErrorMessage, externalDepsFilePath, dep.Name, dep.Version, strings.Join(pathsToUpdate, "\n"), dep.Name, externalDepsFilePath)
|
log.Fatalf(mismatchErrorMessage, externalDepsFilePath, dep.Name, dep.Version, strings.Join(pathsToUpdate, "\n"), dep.Name, externalDepsFilePath)
|
||||||
|
Loading…
Reference in New Issue
Block a user