Skip to content

Commit

Permalink
feat: now dump k8s will generate comment of config
Browse files Browse the repository at this point in the history
  • Loading branch information
morlay committed Sep 6, 2024
1 parent 823badd commit 3234809
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions pkg/cli/cmd_dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"context"
"fmt"
"github.com/octohelm/x/slices"
"os"
"path"
"strings"
Expand Down Expand Up @@ -59,6 +60,15 @@ spec: {
`)
}

toComment := func(s string) string {
return strings.Join(
slices.Map(strings.Split(s, "\n"), func(line string) string {
return "// " + line
}),
"\n",
)
}

var flagExposes []*flagVar

i := 0
Expand All @@ -74,14 +84,18 @@ spec: {

if f.Required {
_, _ = fmt.Fprintf(b,
`config: %q: string
`, f.EnvVar)
`
%s
config: %q: string
`, toComment(f.Desc), f.EnvVar)
continue
}

_, _ = fmt.Fprintf(b,
`config: %q: string | *%q
`, f.EnvVar, f.string())
`
%s
config: %q: string | *%q
`, toComment(f.Desc), f.EnvVar, f.string())

i++
}
Expand Down

0 comments on commit 3234809

Please sign in to comment.