Setting sane defaults for node and profile selection
This commit is contained in:
@@ -9,7 +9,6 @@ import (
|
|||||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||||
"github.com/hpcng/warewulf/internal/pkg/warewulfd"
|
"github.com/hpcng/warewulf/internal/pkg/warewulfd"
|
||||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||||
"github.com/hpcng/warewulf/pkg/hostlist"
|
|
||||||
"github.com/manifoldco/promptui"
|
"github.com/manifoldco/promptui"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@@ -32,14 +31,10 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !SetNodeAll {
|
if SetNodeAll || (len(args) == 0 && len(nodes) > 0) {
|
||||||
if len(args) > 0 {
|
fmt.Printf("\n*** WARNING: This command will modify all nodes! ***\n\n")
|
||||||
nodes = node.FilterByName(nodes, hostlist.Expand(args))
|
} else {
|
||||||
} else {
|
nodes = node.FilterByName(nodes, args)
|
||||||
//nolint:errcheck
|
|
||||||
cmd.Usage()
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(nodes) == 0 {
|
if len(nodes) == 0 {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ var (
|
|||||||
Use: "set [OPTIONS] PATTERN [PATTERN ...]",
|
Use: "set [OPTIONS] PATTERN [PATTERN ...]",
|
||||||
Short: "Configure node properties",
|
Short: "Configure node properties",
|
||||||
Long: "This command sets configuration properties for nodes matching PATTERN.\n\nNote: use the string 'UNSET' to remove a configuration",
|
Long: "This command sets configuration properties for nodes matching PATTERN.\n\nNote: use the string 'UNSET' to remove a configuration",
|
||||||
Args: cobra.MinimumNArgs(1),
|
Args: cobra.MinimumNArgs(0),
|
||||||
RunE: CobraRunE,
|
RunE: CobraRunE,
|
||||||
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||||
if len(args) != 0 {
|
if len(args) != 0 {
|
||||||
|
|||||||
@@ -28,14 +28,13 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !SetAll {
|
if SetAll {
|
||||||
if len(args) > 0 {
|
fmt.Printf("\n*** WARNING: This command will modify all profiles! ***\n\n")
|
||||||
profiles = node.FilterByName(profiles, args)
|
} else if len(args) > 0 {
|
||||||
} else {
|
profiles = node.FilterByName(profiles, args)
|
||||||
//nolint:errcheck
|
} else {
|
||||||
cmd.Usage()
|
wwlog.Printf(wwlog.INFO, "No profile specified, selecting the 'default' profile\n")
|
||||||
os.Exit(1)
|
profiles = node.FilterByName(profiles, []string{"default"})
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(profiles) == 0 {
|
if len(profiles) == 0 {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ var (
|
|||||||
Short: "Configure node profile properties",
|
Short: "Configure node profile properties",
|
||||||
Long: "This command sets configuration properties for the node PROFILE(s).\n\n" +
|
Long: "This command sets configuration properties for the node PROFILE(s).\n\n" +
|
||||||
"Note: use the string 'UNSET' to remove a configuration",
|
"Note: use the string 'UNSET' to remove a configuration",
|
||||||
Args: cobra.MinimumNArgs(1),
|
Args: cobra.MinimumNArgs(0),
|
||||||
RunE: CobraRunE,
|
RunE: CobraRunE,
|
||||||
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||||
if len(args) != 0 {
|
if len(args) != 0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user