From 9d4b81ca2ad27f26bbbc1d5d586f970b5d04443e Mon Sep 17 00:00:00 2001 From: James Strong Date: Wed, 18 Jan 2023 15:54:44 -0500 Subject: [PATCH] update docs, and production urls Signed-off-by: James Strong --- magefiles/helm.go | 2 +- magefiles/release.go | 112 ++++++++++++++++++++++--------------------- 2 files changed, 59 insertions(+), 55 deletions(-) diff --git a/magefiles/helm.go b/magefiles/helm.go index f9bf09cb5..a57c46813 100644 --- a/magefiles/helm.go +++ b/magefiles/helm.go @@ -104,7 +104,7 @@ func updateChartReleaseNotes(releasesNotes []string) { for i := range releasesNotes { releaseNoteString = fmt.Sprintf("%s - %s\n", releaseNoteString, releasesNotes[i]) } - Info("HLEM Release note string %s", releaseNoteString) + Info("HELM Release note string %s", releaseNoteString) chart.Annotations["artifacthub.io/changes"] = releaseNoteString err = chartutil.SaveChartfile(HelmChartPath, chart) CheckIfError(err, "HELM Saving updated release notes for Chart") diff --git a/magefiles/release.go b/magefiles/release.go index cbc4d51de..3340a99ff 100644 --- a/magefiles/release.go +++ b/magefiles/release.go @@ -40,22 +40,61 @@ import ( type Release mg.Namespace -var INGRESS_ORG = "strongjz" // 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 = "strongjz" //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 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 // 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/k8s.gcr.io/images/k8s-staging-ingress-nginx/images.yaml" -var IMAGES_YAML = "https://raw.githubusercontent.com/strongjz/k8s.io/testing/k8s.gcr.io/images/k8s-staging-ingress-nginx/images.yaml" - +var IMAGES_YAML = "https://raw.githubusercontent.com/kubernetes/k8s.io/main/k8s.gcr.io/images/k8s-staging-ingress-nginx/images.yaml" var ctx = context.Background() // Context used for GitHub Client -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 +const CHANGELOG = "Changelog.md" //Name of the changelog +//ControllerImage - struct with info about controllers +type ControllerImage struct { + Tag string + Digest string + Registry string + Name string +} + +//IngressRelease All the information about an ingress-nginx release that gets updated +type IngressRelease struct { + ControllerVersion string + ControllerImage ControllerImage + ReleaseNote ReleaseNote + Release *github.RepositoryRelease +} + +//ReleaseNote - All the pieces of information/documents that get updated during a release +type ReleaseNote struct { + Version string + NewControllerVersion string + PreviousControllerVersion string + ControllerImages []ControllerImage + DepUpdates []string + Updates []string + HelmUpdates []string + NewHelmChartVersion string + PreviousHelmChartVersion string +} + +//IMAGES_YAML returns this data structure +type ImageYamls []ImageElement + +//ImageElement - a specific image and it's data structure the dmap is a list of shas and container versions +type ImageElement struct { + Name string `json:"name"` + Dmap map[string][]string `json:"dmap"` +} + +//init will set the GitHub token from the committers/releasers env var func init() { GITHUB_TOKEN = os.Getenv("GITHUB_TOKEN") } @@ -79,7 +118,7 @@ func (Release) NewRelease(version string) { 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 tag != version { + 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))) } @@ -122,22 +161,20 @@ func (Release) NewRelease(version string) { //update static manifest CheckIfError(updateStaticManifest(), "Error Updating Static manifests") - ////update e2e docs TODO + ////update e2e docs updateE2EDocs() //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)) } -const INDEX_DOCS = "docs/deploy/index.md" - +// the index.md doc needs the controller version updated func updateIndexMD(old, new string) error { Info("Updating Deploy docs with new version") data, err := os.ReadFile(INDEX_DOCS) @@ -152,29 +189,29 @@ func updateIndexMD(old, new string) error { return nil } +//runs the hack/generate-deploy-scripts.sh func updateE2EDocs() { - //hack/generate-deploy-scripts.sh updates, err := sh.Output("./hack/generate-e2e-suite-doc.sh") CheckIfError(err, "Could not run update hack script") err = os.WriteFile("docs/e2e-tests.md", []byte(updates), 644) CheckIfError(err, "Could not write new e2e test file ") } +//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") - // somewhere in your main code - err := g0("install", "sigs.k8s.io/kustomize/kustomize/v4@v4.5.4") + err := g0("install", KUSTOMIZE_INSTALL_VERSION) if err != nil { return err } return nil } +// func updateStaticManifest() error { CheckIfError(installKustomize(), "error installing kustomize") - //hack/generate-deploy-scripts.sh err := sh.RunV("./hack/generate-deploy-scripts.sh") if err != nil { @@ -192,32 +229,6 @@ func updateStaticManifest() error { // Info("New Release: Tag %v, ID: %v", newRelease.TagName, newRelease.ID) //} -type ControllerImage struct { - Tag string - Digest string - Registry string - Name string -} - -type IngressRelease struct { - ControllerVersion string - ControllerImage ControllerImage - ReleaseNote ReleaseNote - Release *github.RepositoryRelease -} - -type ReleaseNote struct { - Version string - NewControllerVersion string - PreviousControllerVersion string - ControllerImages []ControllerImage - DepUpdates []string - Updates []string - HelmUpdates []string - NewHelmChartVersion string - PreviousHelmChartVersion string -} - // Returns a GitHub client ready for use func githubClient() *github.Client { ts := oauth2.StaticTokenSource( @@ -428,13 +439,6 @@ func (r ReleaseNote) printRelease() { } } -type ImageYamls []ImageElement - -type ImageElement struct { - Name string `json:"name"` - Dmap map[string][]string `json:"dmap"` -} - func findImageDigest(yaml ImageYamls, image, version string) string { version = fmt.Sprintf("v%s", version) Info("Searching Digest for %s:%s", image, version)