From 41168f59dfce668c63c7b911116c134b928605ac Mon Sep 17 00:00:00 2001 From: zufardhiyaulhaq Date: Wed, 7 Dec 2022 22:16:45 +0700 Subject: [PATCH 1/3] Add warning notes if helm charts Istio version is already EOL Signed-off-by: zufardhiyaulhaq --- pkg/build/helm.go | 23 +++++++++++++++++++++++ pkg/manifest.go | 1 + pkg/model/model.go | 6 ++++++ 3 files changed, 30 insertions(+) diff --git a/pkg/build/helm.go b/pkg/build/helm.go index 5cf19dba..31446e10 100644 --- a/pkg/build/helm.go +++ b/pkg/build/helm.go @@ -154,6 +154,29 @@ func sanitizeChart(manifest model.Manifest, s string) error { return err } } + + if fname == "NOTES.txt" { + read, err := os.ReadFile(p) + if err != nil { + return err + } + contents := string(read) + + EOLTemplate := ` +{{- $EndOfLife := toDate "2006-01" "%s" | unixEpoch -}} +{{- $Now := now | unixEpoch -}} + +{{- if ge $Now $EndOfLife}} + +WARNING: may be installing an EOL version: see https://istio.io/latest/docs/releases/supported-releases/ for supported releases +{{ end }} +` + contents = contents + fmt.Sprintf(EOLTemplate, manifest.EOLDate) + err = os.WriteFile(p, []byte(contents), 0) + if err != nil { + return err + } + } return nil }); err != nil { return err diff --git a/pkg/manifest.go b/pkg/manifest.go index 1dbd296e..8daa75a0 100644 --- a/pkg/manifest.go +++ b/pkg/manifest.go @@ -74,6 +74,7 @@ func InputManifestToManifest(in model.InputManifest) (model.Manifest, error) { return model.Manifest{ Dependencies: in.Dependencies, Version: in.Version, + EOLDate: in.EOLDate, Docker: in.Docker, DockerOutput: do, Directory: wd, diff --git a/pkg/model/model.go b/pkg/model/model.go index 86e51f0f..1dc919f7 100644 --- a/pkg/model/model.go +++ b/pkg/model/model.go @@ -131,6 +131,9 @@ type InputManifest struct { Dependencies IstioDependencies `json:"dependencies"` // Version specifies what version of Istio this release is Version string `json:"version"` + // EOLDate specifies what is the date when this Istio version become EOL + // Should be in format "yyyy-mm" + EOLDate string `json:"eolDate"` // Docker specifies the docker hub to use in the helm charts. Docker string `json:"docker"` // DockerOutput specifies where docker images are written. @@ -160,6 +163,9 @@ type Manifest struct { Dependencies IstioDependencies `json:"dependencies"` // Version specifies what version of Istio this release is Version string `json:"version"` + // EOLDate specifies what is the date when this Istio version become EOL + // Should be in format "yyyy-mm" + EOLDate string `json:"eolDate"` // Docker specifies the docker hub to use in the helm charts. Docker string `json:"docker"` // DockerOutput specifies where docker images are written. From 0e689c6685f82f794fc1eb81775fe7ab329bda0c Mon Sep 17 00:00:00 2001 From: zufardhiyaulhaq Date: Wed, 7 Dec 2022 22:23:13 +0700 Subject: [PATCH 2/3] Add nolint for the template to escape gocritic Signed-off-by: zufardhiyaulhaq --- pkg/build/helm.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/build/helm.go b/pkg/build/helm.go index 31446e10..f01b7f5c 100644 --- a/pkg/build/helm.go +++ b/pkg/build/helm.go @@ -162,6 +162,7 @@ func sanitizeChart(manifest model.Manifest, s string) error { } contents := string(read) + //nolint EOLTemplate := ` {{- $EndOfLife := toDate "2006-01" "%s" | unixEpoch -}} {{- $Now := now | unixEpoch -}} From d1b536f19579284313a8e34a217d7076026364f8 Mon Sep 17 00:00:00 2001 From: zufardhiyaulhaq Date: Thu, 8 Dec 2022 21:47:49 +0700 Subject: [PATCH 3/3] fix gocritic Signed-off-by: zufardhiyaulhaq --- pkg/build/helm.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/build/helm.go b/pkg/build/helm.go index f01b7f5c..89e2eb35 100644 --- a/pkg/build/helm.go +++ b/pkg/build/helm.go @@ -162,7 +162,6 @@ func sanitizeChart(manifest model.Manifest, s string) error { } contents := string(read) - //nolint EOLTemplate := ` {{- $EndOfLife := toDate "2006-01" "%s" | unixEpoch -}} {{- $Now := now | unixEpoch -}} @@ -172,7 +171,7 @@ func sanitizeChart(manifest model.Manifest, s string) error { WARNING: may be installing an EOL version: see https://istio.io/latest/docs/releases/supported-releases/ for supported releases {{ end }} ` - contents = contents + fmt.Sprintf(EOLTemplate, manifest.EOLDate) + contents += fmt.Sprintf(EOLTemplate, manifest.EOLDate) err = os.WriteFile(p, []byte(contents), 0) if err != nil { return err