added wwctl genconfig warewulfconf print
Signed-off-by: Christian Goll <cgoll@suse.de>
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/genconf/dfaults"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/genconf/man"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/genconf/reference"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/genconf/warewulfconf"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@@ -25,6 +26,7 @@ func init() {
|
||||
baseCmd.AddCommand(man.GetCommand())
|
||||
baseCmd.AddCommand(reference.GetCommand())
|
||||
baseCmd.AddCommand(dfaults.GetCommand())
|
||||
baseCmd.AddCommand(warewulfconf.GetCommand())
|
||||
}
|
||||
|
||||
// GetRootCommand returns the root cobra.Command for the application.
|
||||
|
||||
19
internal/app/wwctl/genconf/warewulfconf/print/main.go
Normal file
19
internal/app/wwctl/genconf/warewulfconf/print/main.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package print
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
|
||||
"github.com/spf13/cobra"
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) (err error) {
|
||||
conf := warewulfconf.New()
|
||||
buffer, err := yaml.Marshal(&conf)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
fmt.Println(string(buffer))
|
||||
return
|
||||
}
|
||||
22
internal/app/wwctl/genconf/warewulfconf/print/root.go
Normal file
22
internal/app/wwctl/genconf/warewulfconf/print/root.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package print
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
baseCmd = &cobra.Command{
|
||||
Use: "print",
|
||||
Short: "print wareweulf.conf",
|
||||
Long: "This command prints the actual used warewulf.conf, can be used to create an empty valid warewulf.conf",
|
||||
RunE: CobraRunE,
|
||||
Args: cobra.ExactArgs(0),
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
}
|
||||
|
||||
func GetCommand() *cobra.Command {
|
||||
return baseCmd
|
||||
}
|
||||
27
internal/app/wwctl/genconf/warewulfconf/root.go
Normal file
27
internal/app/wwctl/genconf/warewulfconf/root.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package warewulfconf
|
||||
|
||||
import (
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/genconf/warewulfconf/print"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
baseCmd = &cobra.Command{
|
||||
Use: "warewulfconf",
|
||||
Short: "access warewulf.conf",
|
||||
Long: "Commands for accessing the actual used warewulf.conf",
|
||||
Args: cobra.ExactArgs(0),
|
||||
Aliases: []string{"cnf"},
|
||||
}
|
||||
ListFull bool
|
||||
WWctlRoot *cobra.Command
|
||||
)
|
||||
|
||||
func init() {
|
||||
baseCmd.AddCommand(print.GetCommand())
|
||||
}
|
||||
|
||||
// GetRootCommand returns the root cobra.Command for the application.
|
||||
func GetCommand() *cobra.Command {
|
||||
return baseCmd
|
||||
}
|
||||
Reference in New Issue
Block a user