INNER CODE UNIT · Go

updateFiles

projectcontour/contour · hack/actions/bump-envoy-version/main.go:127

func updateFiles(version string) {
	envoyImageRe := regexp.MustCompile(`docker\.io/envoyproxy/envoy:(distroless-)?v[0-9]+\.[0-9]+\.[0-9]+`)

	for _, file := range filesToPatch {
		content, err := os.ReadFile(file)
		if err != nil {
			log.WithError(err).WithField("file", file).Fatal("Failed to read file")
		}

		updated := envoyImageRe.ReplaceAllString(string(content), "docker.io/envoyproxy/envoy:"+version)

		if updated != string(content) {
			if err := os.WriteFile(file, []byte(updated), 0o600); err != nil { //nolint:gosec // G703: Path traversal via taint analysis
				log.WithError(err).WithField("file", file).Fatal("Failed to write file")
			}
			log.Infof("Updated file: %s", file)
		}
	}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…