INNER CODE UNIT · Go
updateVAPManifest
kubernetes-sigs/gateway-api · tools/generator/main.go:223
func updateVAPManifest(manifest, channel, bundleVersion string) (string, error) {
versionMatch := regexp.MustCompile(`^v(\d+)\.(\d+)`).FindStringSubmatch(bundleVersion)
if versionMatch == nil {
return "", fmt.Errorf("bundle version %q is not of the form vMAJOR.MINOR", bundleVersion)
}
minor, err := strconv.Atoi(versionMatch[2])
if err != nil {
return "", fmt.Errorf("invalid minor version in bundle version %q: %w", bundleVersion, err)
}
if minor < 1 {
// Skip if this runs on main or with the `v0.0.0-dev` bundle version
return manifest, nil
}
// Only match annotation lines; the annotation key also appears inside CEL
// expressions, where it is never at the start of a line.
re := regexp.MustCompile(`(?m)^(\s*` + regexp.QuoteMeta(consts.BundleVersionAnnotation) + `:\s*).*$`)
manifest = re.ReplaceAllString(manifest, "${1}"+bundleVersion)