Files
warewulf/internal/app/wwctl/profile/add/root.go
2022-07-15 11:10:12 +02:00

66 lines
2.3 KiB
Go

package add
import (
"log"
"github.com/hpcng/warewulf/internal/pkg/container"
"github.com/hpcng/warewulf/internal/pkg/kernel"
"github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/overlay"
"github.com/spf13/cobra"
)
var (
baseCmd = &cobra.Command{
DisableFlagsInUseLine: true,
Use: "add PROFILE",
Short: "Add a new node profile",
Long: "This command adds a new named PROFILE.",
RunE: CobraRunE,
Args: cobra.ExactArgs(1),
}
SetNetDevDel string
SetNodeAll bool
SetYes bool
SetForce bool
OptionStrMap map[string]*string
)
// GetRootCommand returns the root cobra.Command for the application.
func GetCommand() *cobra.Command {
// init empty helper structs, so that we know what's inside
myBase := node.CobraCommand{Command: baseCmd}
var emptyNodeConf node.NodeConf
emptyNodeConf.Kernel = new(node.KernelConf)
emptyNodeConf.Ipmi = new(node.IpmiConf)
OptionStrMap = myBase.CreateFlags(emptyNodeConf,
[]string{"ipaddr", "ipaddr6", "ipmiaddr", "profile"})
// register the command line completions
if err := baseCmd.RegisterFlagCompletionFunc("container", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
list, _ := container.ListSources()
return list, cobra.ShellCompDirectiveNoFileComp
}); err != nil {
log.Println(err)
}
if err := baseCmd.RegisterFlagCompletionFunc("kerneloverride", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
list, _ := kernel.ListKernels()
return list, cobra.ShellCompDirectiveNoFileComp
}); err != nil {
log.Println(err)
}
if err := baseCmd.RegisterFlagCompletionFunc("runtime", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
list, _ := overlay.FindOverlays()
return list, cobra.ShellCompDirectiveNoFileComp
}); err != nil {
log.Println(err)
}
if err := baseCmd.RegisterFlagCompletionFunc("wwinit", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
list, _ := overlay.FindOverlays()
return list, cobra.ShellCompDirectiveNoFileComp
}); err != nil {
log.Println(err)
}
return baseCmd
}