add more generic documentation via wwdoc(n)
doc
This commit is contained in:
committed by
Jonathon Anderson
parent
68758e3e45
commit
d1d398d2ff
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/warewulf/warewulf/internal/pkg/node"
|
||||
"github.com/warewulf/warewulf/internal/pkg/overlay"
|
||||
"github.com/warewulf/warewulf/internal/pkg/wwlog"
|
||||
"golang.org/x/exp/maps"
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
@@ -30,6 +31,13 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
if vars == nil {
|
||||
return fmt.Errorf("could not parse variables for %s in overlay %s", filePath, overlayName)
|
||||
}
|
||||
commentKeys := maps.Keys(commentMap)
|
||||
sort.Strings(commentKeys)
|
||||
for _, docLn := range commentKeys {
|
||||
if strings.Contains(docLn, "wwdoc") {
|
||||
wwlog.Info(commentMap[docLn])
|
||||
}
|
||||
}
|
||||
t := table.New(cmd.OutOrStdout())
|
||||
t.AddHeader("OVERLAY VARIABLE", "HELP", "TYPE", "CMD OPTION")
|
||||
|
||||
|
||||
@@ -13,10 +13,13 @@ import (
|
||||
func Test_Overlay_Variables(t *testing.T) {
|
||||
env := testenv.New(t)
|
||||
defer env.RemoveAll()
|
||||
wwlog.SetLogLevel(wwlog.DEBUG)
|
||||
warewulfd.SetNoDaemon()
|
||||
|
||||
templateContent := `
|
||||
{{/* .Kernel.Tags.foo: "some help text" */}}
|
||||
{{/* wwdoc1: First Line */}}
|
||||
{{/* wwdoc2: Second Line */}}
|
||||
{{ .Kernel.Tags.foo }}
|
||||
{{ .Node.Tags.bar }}
|
||||
{{ .Cluster.Tags.baz }}
|
||||
@@ -39,6 +42,7 @@ func Test_Overlay_Variables(t *testing.T) {
|
||||
assert.Contains(t, output, "OVERLAY VARIABLE")
|
||||
assert.Contains(t, output, ".Kernel.Tags.foo")
|
||||
assert.Contains(t, output, "some help text")
|
||||
assert.Regexp(t, `(?s)First Line.*Second Line`, output, "First Line should come before Second Line")
|
||||
})
|
||||
|
||||
t.Run("overlay variables no file", func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user