Disable user snippets per default (#10393)
* Disable user snippets per default * Enable snippet on tests
This commit is contained in:
parent
2d03da6334
commit
cf889c6c47
35 changed files with 494 additions and 288 deletions
|
|
@ -22,39 +22,45 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
"text/template"
|
||||
"time"
|
||||
|
||||
"github.com/google/go-github/v48/github"
|
||||
"github.com/magefile/mage/mg"
|
||||
"github.com/magefile/mage/sh"
|
||||
"golang.org/x/oauth2"
|
||||
"gopkg.in/yaml.v3"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"text/template"
|
||||
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Release mg.Namespace
|
||||
|
||||
var INGRESS_ORG = "kubernetes" // the owner so we can test from forks
|
||||
var INGRESS_REPO = "ingress-nginx" // the repo to pull from
|
||||
var RELEASE_BRANCH = "main" //we only release from main
|
||||
var GITHUB_TOKEN string // the Google/gogithub lib needs an PAT to access the GitHub API
|
||||
var K8S_IO_ORG = "kubernetes" //the owner or organization for the k8s.io repo
|
||||
var K8S_IO_REPO = "k8s.io" //the repo that holds the images yaml for production promotion
|
||||
var INGRESS_REGISTRY = "registry.k8s.io" //Container registry for storage Ingress-nginx images
|
||||
var KUSTOMIZE_INSTALL_VERSION = "sigs.k8s.io/kustomize/kustomize/v4@v4.5.4" //static deploys needs kustomize to generate the template
|
||||
var (
|
||||
INGRESS_ORG = "kubernetes" // the owner so we can test from forks
|
||||
INGRESS_REPO = "ingress-nginx" // the repo to pull from
|
||||
RELEASE_BRANCH = "main" // we only release from main
|
||||
GITHUB_TOKEN string // the Google/gogithub lib needs an PAT to access the GitHub API
|
||||
K8S_IO_ORG = "kubernetes" // the owner or organization for the k8s.io repo
|
||||
K8S_IO_REPO = "k8s.io" // the repo that holds the images yaml for production promotion
|
||||
INGRESS_REGISTRY = "registry.k8s.io" // Container registry for storage Ingress-nginx images
|
||||
KUSTOMIZE_INSTALL_VERSION = "sigs.k8s.io/kustomize/kustomize/v4@v4.5.4" // static deploys needs kustomize to generate the template
|
||||
)
|
||||
|
||||
// ingress-nginx releases start with a TAG then a cloudbuild, then a promotion through a PR, this the location of that PR
|
||||
var IMAGES_YAML = "https://raw.githubusercontent.com/kubernetes/k8s.io/main/registry.k8s.io/images/k8s-staging-ingress-nginx/images.yaml"
|
||||
var ctx = context.Background() // Context used for GitHub Client
|
||||
var (
|
||||
IMAGES_YAML = "https://raw.githubusercontent.com/kubernetes/k8s.io/main/registry.k8s.io/images/k8s-staging-ingress-nginx/images.yaml"
|
||||
ctx = context.Background() // Context used for GitHub Client
|
||||
)
|
||||
|
||||
const INDEX_DOCS = "docs/deploy/index.md" //index.md has a version of the controller and needs to updated
|
||||
const CHANGELOG = "Changelog.md" //Name of the changelog
|
||||
const (
|
||||
INDEX_DOCS = "docs/deploy/index.md" // index.md has a version of the controller and needs to updated
|
||||
CHANGELOG = "Changelog.md" // Name of the changelog
|
||||
)
|
||||
|
||||
// ControllerImage - struct with info about controllers
|
||||
type ControllerImage struct {
|
||||
|
|
@ -101,81 +107,80 @@ func init() {
|
|||
|
||||
// PromoteImage Creates PR into the k8s.io repo for promotion of ingress from staging to production
|
||||
func (Release) PromoteImage(version, sha string) {
|
||||
|
||||
}
|
||||
|
||||
// Release Create a new release of ingress nginx controller
|
||||
func (Release) NewRelease(version string) {
|
||||
//newRelease := Release{}
|
||||
// newRelease := Release{}
|
||||
|
||||
//update ingress-nginx version
|
||||
//This is the step that kicks all the release process
|
||||
//it is already done, so it kicks off the gcloud build of the controller images
|
||||
//mg.Deps(mg.F(Tag.BumpNginx, version))
|
||||
// update ingress-nginx version
|
||||
// This is the step that kicks all the release process
|
||||
// it is already done, so it kicks off the gcloud build of the controller images
|
||||
// mg.Deps(mg.F(Tag.BumpNginx, version))
|
||||
|
||||
tag, err := getIngressNGINXVersion()
|
||||
CheckIfError(err, "RELEASE Retrieving the current Ingress Nginx Version")
|
||||
|
||||
Info("RELEASE Checking Current Version %s to New Version %s", tag, version)
|
||||
//if the version were upgrading does not match the TAG file, lets update the TAG file
|
||||
// if the version were upgrading does not match the TAG file, lets update the TAG file
|
||||
if tag[1:] != version {
|
||||
Warning("RELEASE Ingress Nginx TAG %s and new version %s do not match", tag, version)
|
||||
mg.Deps(mg.F(Tag.BumpNginx, fmt.Sprintf("v%s", version)))
|
||||
}
|
||||
|
||||
//update git controller tag controller-v$version
|
||||
// update git controller tag controller-v$version
|
||||
mg.Deps(mg.F(Tag.NewControllerTag, version))
|
||||
|
||||
//make release notes
|
||||
// make release notes
|
||||
releaseNotes, err := makeReleaseNotes(version)
|
||||
CheckIfError(err, "RELEASE Creating Release Notes for version %s", version)
|
||||
Info("RELEASE Release Notes %s completed", releaseNotes.Version)
|
||||
|
||||
//update chart values.yaml new controller tag and image digest
|
||||
// update chart values.yaml new controller tag and image digest
|
||||
releaseNotes.PreviousHelmChartVersion = currentChartVersion()
|
||||
|
||||
//controller tag
|
||||
// controller tag
|
||||
updateChartValue("controller.image.tag", fmt.Sprintf("v%s", releaseNotes.Version))
|
||||
Debug("releaseNotes.ControllerImages[0].Name %s", releaseNotes.ControllerImages[0].Name)
|
||||
Debug("releaseNotes.ControllerImages[1].Name %s", releaseNotes.ControllerImages[1].Name)
|
||||
//controller digest
|
||||
// controller digest
|
||||
if releaseNotes.ControllerImages[0].Name == "ingress-nginx/controller" {
|
||||
Debug("Updating Chart Value %s with %s", "controller.image.digest", releaseNotes.ControllerImages[0].Digest)
|
||||
updateChartValue("controller.image.digest", releaseNotes.ControllerImages[0].Digest)
|
||||
}
|
||||
//controller chroot digest
|
||||
// controller chroot digest
|
||||
if releaseNotes.ControllerImages[1].Name == "ingress-nginx/controller-chroot" {
|
||||
Debug("Updating Chart Value %s with %s", "controller.image.digestChroot", releaseNotes.ControllerImages[1].Digest)
|
||||
updateChartValue("controller.image.digestChroot", releaseNotes.ControllerImages[1].Digest)
|
||||
}
|
||||
|
||||
//update helm chart app version
|
||||
// update helm chart app version
|
||||
mg.Deps(mg.F(Helm.UpdateVersion, version))
|
||||
|
||||
releaseNotes.NewHelmChartVersion = currentChartVersion()
|
||||
|
||||
//update helm chart release notes
|
||||
// update helm chart release notes
|
||||
updateChartReleaseNotes(releaseNotes.HelmUpdates)
|
||||
|
||||
//Run helm docs update
|
||||
// Run helm docs update
|
||||
CheckIfError(runHelmDocs(), "Error Updating Helm Docs ")
|
||||
|
||||
releaseNotes.helmTemplate()
|
||||
|
||||
//update static manifest
|
||||
// update static manifest
|
||||
CheckIfError(updateStaticManifest(), "Error Updating Static manifests")
|
||||
|
||||
////update e2e docs
|
||||
updateE2EDocs()
|
||||
|
||||
//update documentation with ingress-nginx version
|
||||
// update documentation with ingress-nginx version
|
||||
CheckIfError(updateIndexMD(releaseNotes.PreviousControllerVersion, releaseNotes.NewControllerVersion), "Error Updating %s", INDEX_DOCS)
|
||||
|
||||
//keeping these manual for now
|
||||
//git commit TODO
|
||||
//make Pull Request TODO
|
||||
//make release TODO
|
||||
//mg.Deps(mg.F(Release.CreateRelease, version))
|
||||
// keeping these manual for now
|
||||
// git commit TODO
|
||||
// make Pull Request TODO
|
||||
// make release TODO
|
||||
// mg.Deps(mg.F(Release.CreateRelease, version))
|
||||
}
|
||||
|
||||
// the index.md doc needs the controller version updated
|
||||
|
|
@ -204,7 +209,7 @@ func updateE2EDocs() {
|
|||
// The static deploy scripts use kustomize to generate them, this function ensures kustomize is installed
|
||||
func installKustomize() error {
|
||||
Info("Install Kustomize")
|
||||
var g0 = sh.RunCmd("go")
|
||||
g0 := sh.RunCmd("go")
|
||||
// somewhere in your main code
|
||||
err := g0("install", KUSTOMIZE_INSTALL_VERSION)
|
||||
if err != nil {
|
||||
|
|
@ -215,7 +220,7 @@ func installKustomize() error {
|
|||
|
||||
func updateStaticManifest() error {
|
||||
CheckIfError(installKustomize(), "error installing kustomize")
|
||||
//hack/generate-deploy-scripts.sh
|
||||
// hack/generate-deploy-scripts.sh
|
||||
err := sh.RunV("./hack/generate-deploy-scripts.sh")
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
@ -270,28 +275,28 @@ func (Release) ReleaseNotes(newVersion string) error {
|
|||
}
|
||||
|
||||
func makeReleaseNotes(newVersion string) (*ReleaseNote, error) {
|
||||
var newReleaseNotes = ReleaseNote{}
|
||||
newReleaseNotes := ReleaseNote{}
|
||||
|
||||
newReleaseNotes.Version = newVersion
|
||||
allControllerTags := getAllControllerTags()
|
||||
|
||||
//new version
|
||||
// new version
|
||||
newReleaseNotes.NewControllerVersion = allControllerTags[0]
|
||||
newControllerVersion := fmt.Sprintf("controller-v%s", newVersion)
|
||||
|
||||
//the newControllerVersion should match the latest tag
|
||||
// the newControllerVersion should match the latest tag
|
||||
if newControllerVersion != allControllerTags[0] {
|
||||
return nil, errors.New(fmt.Sprintf("Generating release new version %s didnt match the current latest tag %s", newControllerVersion, allControllerTags[0]))
|
||||
}
|
||||
//previous version
|
||||
// previous version
|
||||
newReleaseNotes.PreviousControllerVersion = allControllerTags[1]
|
||||
|
||||
Info("New Version: %s Old Version: %s", newReleaseNotes.NewControllerVersion, newReleaseNotes.PreviousControllerVersion)
|
||||
|
||||
commits := commitsBetweenTags()
|
||||
|
||||
//dependency_updates
|
||||
//all_updates
|
||||
// dependency_updates
|
||||
// all_updates
|
||||
var allUpdates []string
|
||||
var depUpdates []string
|
||||
var helmUpdates []string
|
||||
|
|
@ -299,9 +304,9 @@ func makeReleaseNotes(newVersion string) (*ReleaseNote, error) {
|
|||
depBot := regexp.MustCompile("^(\\w){1,10} Bump ")
|
||||
helmRegex := regexp.MustCompile("helm|chart")
|
||||
for i, s := range commits {
|
||||
//matches on PR
|
||||
// matches on PR
|
||||
if prRegex.Match([]byte(s)) {
|
||||
//matches a dependant bot update
|
||||
// matches a dependant bot update
|
||||
if depBot.Match([]byte(s)) { //
|
||||
Debug("#%v DEPENDABOT %v", i, s)
|
||||
u := strings.SplitN(s, " ", 2)
|
||||
|
|
@ -311,13 +316,12 @@ func makeReleaseNotes(newVersion string) (*ReleaseNote, error) {
|
|||
u := strings.SplitN(s, " ", 2)
|
||||
allUpdates = append(allUpdates, u[1])
|
||||
|
||||
//helm chart updates
|
||||
// helm chart updates
|
||||
if helmRegex.Match([]byte(s)) {
|
||||
u := strings.SplitN(s, " ", 2)
|
||||
helmUpdates = append(helmUpdates, u[1])
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
helmUpdates = append(helmUpdates, fmt.Sprintf("Update Ingress-Nginx version %s", newReleaseNotes.NewControllerVersion))
|
||||
|
|
@ -326,7 +330,7 @@ func makeReleaseNotes(newVersion string) (*ReleaseNote, error) {
|
|||
newReleaseNotes.DepUpdates = depUpdates
|
||||
newReleaseNotes.HelmUpdates = helmUpdates
|
||||
|
||||
//controller_image_digests
|
||||
// controller_image_digests
|
||||
imagesYaml, err := downloadFile(IMAGES_YAML)
|
||||
if err != nil {
|
||||
ErrorF("Could not download file %s : %s", IMAGES_YAML, err)
|
||||
|
|
@ -342,7 +346,7 @@ func makeReleaseNotes(newVersion string) (*ReleaseNote, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
//controller
|
||||
// controller
|
||||
controllerDigest := findImageDigest(data, "controller", newVersion)
|
||||
if len(controllerDigest) == 0 {
|
||||
ErrorF("Controller Digest could not be found")
|
||||
|
|
@ -379,7 +383,7 @@ func makeReleaseNotes(newVersion string) (*ReleaseNote, error) {
|
|||
newReleaseNotes.printRelease()
|
||||
}
|
||||
|
||||
//write it all out to the changelog file
|
||||
// write it all out to the changelog file
|
||||
newReleaseNotes.template()
|
||||
|
||||
return &newReleaseNotes, nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue