From dfe4f74ea1e2435fd8ca562d6b22a92bdde872d6 Mon Sep 17 00:00:00 2001 From: Tamal Saha Date: Sat, 3 Jul 2021 08:41:33 -0700 Subject: [PATCH] Don't generate values example if provided in the doc.yaml Signed-off-by: Tamal Saha --- main.go | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/main.go b/main.go index afae02e..8c62112 100644 --- a/main.go +++ b/main.go @@ -22,6 +22,7 @@ import ( "io" "io/ioutil" "os" + "strings" "text/template" "kubepack.dev/chart-doc-gen/api" @@ -85,16 +86,18 @@ func main() { doc.Chart.Values = buf.String() - for _, row := range rows { - if row[2] != "" && - row[2] != `""` && - row[2] != "{}" && - row[2] != "[]" && - row[2] != "true" && - row[2] != "false" && - row[2] != "not-ca-cert" { - doc.Chart.ValuesExample = fmt.Sprintf("%v=%v", row[0], row[2]) - break + if doc.Chart.ValuesExample == "" || strings.HasPrefix(doc.Chart.ValuesExample, "-- generate from values file --") { + for _, row := range rows { + if row[2] != "" && + row[2] != `""` && + row[2] != "{}" && + row[2] != "[]" && + row[2] != "true" && + row[2] != "false" && + row[2] != "not-ca-cert" { + doc.Chart.ValuesExample = fmt.Sprintf("%v=%v", row[0], row[2]) + break + } } } } else if err == io.EOF {