From 78ae01c980b23b726b2bd93db76fa7fefd66b7b0 Mon Sep 17 00:00:00 2001 From: Sascha Grunert Date: Tue, 23 Apr 2024 09:10:21 +0200 Subject: [PATCH] schedule-builder: Add markdown help Add a help section of top of each markdown file to describe how the file is being generated. Signed-off-by: Sascha Grunert --- cmd/schedule-builder/cmd/markdown.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/schedule-builder/cmd/markdown.go b/cmd/schedule-builder/cmd/markdown.go index 9e8d0414bf9..350055d0e38 100644 --- a/cmd/schedule-builder/cmd/markdown.go +++ b/cmd/schedule-builder/cmd/markdown.go @@ -179,6 +179,12 @@ func processFile(fileName string, vars interface{}) string { const ( refDate = "2006-01-02" refDateMonthly = "January 2006" + markdownHelp = `# Use "schedule-builder" to maintain this file: +# https://github.com/kubernetes/release/tree/master/cmd/schedule-builder +# For example by running: +# schedule-builder -uc data/releases/schedule.yaml -e data/releases/eol.yaml +--- +` ) func updatePatchSchedule(refTime time.Time, schedule PatchSchedule, eolBranches EolBranches, filePath, eolFilePath string) error { @@ -311,6 +317,7 @@ func updatePatchSchedule(refTime time.Time, schedule PatchSchedule, eolBranches if err != nil { return fmt.Errorf("marshal schedule YAML: %w", err) } + yamlBytes = append([]byte(markdownHelp), yamlBytes...) //nolint:gocritic,gosec if err := os.WriteFile(filePath, yamlBytes, 0o644); err != nil { @@ -324,6 +331,7 @@ func updatePatchSchedule(refTime time.Time, schedule PatchSchedule, eolBranches if err != nil { return fmt.Errorf("marshal end of life YAML: %w", err) } + yamlBytes = append([]byte(markdownHelp), yamlBytes...) //nolint:gocritic,gosec if err := os.WriteFile(eolFilePath, yamlBytes, 0o644); err != nil {