From c03f60ec32dcb50e02cb91d0be823325870e788b Mon Sep 17 00:00:00 2001 From: Paul Date: Sat, 18 Mar 2023 21:42:44 +0100 Subject: [PATCH] Change featureMatrix to use the new replace function (it has more error checks) --- build/generate/featureMatrix.go | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/build/generate/featureMatrix.go b/build/generate/featureMatrix.go index 4642597089..460d22ec3a 100644 --- a/build/generate/featureMatrix.go +++ b/build/generate/featureMatrix.go @@ -1,7 +1,6 @@ package main import ( - "os" "sort" "strings" @@ -18,9 +17,9 @@ func generateFeatureMatrix() error { return err } - replaceInlineContent( + replaceTextBetweenMarkers( "documentation/providers.md", - "", + "\n", "", markdownTable, ) @@ -290,29 +289,3 @@ type FeatureMatrix struct { Features []string Providers map[string]FeatureMap } - -func replaceInlineContent( - file string, - startMarker string, - endMarker string, - newContent string, -) { - contentBytes, err := os.ReadFile(file) - if err != nil { - panic(err) - } - content := string(contentBytes) - - start := strings.Index(content, startMarker) - end := strings.Index(content, endMarker) - - newContentString := startMarker + "\n" + newContent + endMarker - newContentBytes := []byte(newContentString) - contentBytes = []byte(content) - contentBytes = append(contentBytes[:start], append(newContentBytes, contentBytes[end+len(endMarker):]...)...) - - err = os.WriteFile(file, contentBytes, 0644) - if err != nil { - panic(err) - } -}