Explicitly enforce the number or arguments accepted by some wwctl subcommands. #1717

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
Jonathon Anderson
2025-03-24 21:06:07 -06:00
parent 2d46a8b375
commit 9a3e48fa37
21 changed files with 21 additions and 0 deletions

View File

@@ -23,6 +23,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Changed
- Update GitHub actions to build aarch64 artifacts.
- Explicitly enforce the number or arguments accepted by some `wwctl` subcommands. #1717
### Removed

View File

@@ -31,6 +31,7 @@ var (
Long: "wwclient fetches the runtime overlay and puts it on the disk",
RunE: CobraRunE,
SilenceUsage: true,
Args: cobra.NoArgs,
}
DebugFlag bool
PIDFile string

View File

@@ -17,6 +17,7 @@ var (
Long: "This application allows you to manage and initialize Warewulf dependent system\n" +
"services based on the configuration in the warewulf.conf file.",
RunE: CobraRunE,
Args: cobra.NoArgs,
}
allFunctions bool
)

View File

@@ -13,6 +13,7 @@ var (
Short: "Delete an imported image",
Long: "This command will delete IMAGEs that have been imported into Warewulf.",
RunE: CobraRunE,
Args: cobra.ArbitraryArgs,
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
if len(args) != 0 {
return nil, cobra.ShellCompDirectiveNoFileComp

View File

@@ -23,6 +23,7 @@ func GetCommand() *cobra.Command {
Long: "This command will show you the images that are imported into Warewulf.",
RunE: CobraRunE(&vars),
Aliases: []string{"ls"},
Args: cobra.ArbitraryArgs,
ValidArgsFunction: completions.Images,
}
baseCmd.PersistentFlags().BoolVarP(&vars.full, "long", "l", false, "show all")

View File

@@ -23,6 +23,7 @@ var baseCmd = &cobra.Command{
"node images. These commands will help you import, manage, and transform\n" +
"images into bootable Warewulf images.",
Aliases: []string{"vnfs", "container"},
Args: cobra.NoArgs,
}
func init() {

View File

@@ -13,6 +13,7 @@ var (
Long: "This command opens an editor for the given nodes.",
RunE: CobraRunE,
ValidArgsFunction: completions.Nodes,
Args: cobra.ArbitraryArgs,
}
NoHeader bool
)

View File

@@ -13,6 +13,7 @@ var (
Long: "This command exports the given nodes as yaml to stdout.",
RunE: CobraRunE,
ValidArgsFunction: completions.Nodes,
Args: cobra.ArbitraryArgs,
}
NoHeader bool
)

View File

@@ -25,6 +25,7 @@ func GetCommand() *cobra.Command {
RunE: CobraRunE(&vars),
Aliases: []string{"ls"},
ValidArgsFunction: completions.Nodes,
Args: cobra.ArbitraryArgs,
}
baseCmd.PersistentFlags().BoolVarP(&vars.showNet, "net", "n", false, "Show node network configurations")
baseCmd.PersistentFlags().BoolVarP(&vars.showIpmi, "ipmi", "i", false, "Show node IPMI configurations")

View File

@@ -23,6 +23,7 @@ var (
"node ranges. For example: n00[00-4].cluster[0-1] will identify the first 5 nodes\n" +
"in cluster0 and cluster1.",
Aliases: []string{"nodes"},
Args: cobra.NoArgs,
}
)

View File

@@ -13,6 +13,7 @@ var (
Long: "View and monitor the status of nodes as they are provisioned and check in.",
RunE: CobraRunE,
ValidArgsFunction: completions.Nodes,
Args: cobra.ArbitraryArgs,
}
SetWatch bool
SetUpdate int

View File

@@ -13,6 +13,7 @@ var (
Long: "This command builds overlays for given nodes.",
RunE: CobraRunE,
ValidArgsFunction: completions.Nodes,
Args: cobra.ArbitraryArgs,
}
OverlayNames []string
OverlayDir string

View File

@@ -14,6 +14,7 @@ var (
RunE: CobraRunE,
Aliases: []string{"ls"},
ValidArgsFunction: completions.Overlays,
Args: cobra.ArbitraryArgs,
}
ListContents bool
ListLong bool

View File

@@ -20,6 +20,7 @@ var (
Use: "overlay COMMAND [OPTIONS]",
Short: "Warewulf Overlay Management",
Long: "Management interface for Warewulf overlays",
Args: cobra.NoArgs,
}
)

View File

@@ -16,6 +16,7 @@ var (
Use: "power COMMAND [OPTIONS]",
Short: "Warewulf node power management",
Long: "This command controls the power state of nodes.",
Args: cobra.NoArgs,
}
)

View File

@@ -24,6 +24,7 @@ func GetCommand() *cobra.Command {
Aliases: []string{"new", "create"},
RunE: CobraRunE(&vars),
ValidArgsFunction: completions.None,
Args: cobra.MinimumNArgs(1),
}
vars.profileConf.CreateFlags(baseCmd)
vars.profileAdd.CreateAddFlags(baseCmd)

View File

@@ -13,6 +13,7 @@ var (
Long: "This command opens an editor for the given profiles.",
RunE: CobraRunE,
ValidArgsFunction: completions.Profiles,
Args: cobra.ArbitraryArgs,
}
NoHeader bool
)

View File

@@ -22,6 +22,7 @@ func GetCommand() *cobra.Command {
RunE: CobraRunE(&vars),
Aliases: []string{"ls"},
ValidArgsFunction: completions.Profiles,
Args: cobra.ArbitraryArgs,
}
baseCmd.PersistentFlags().BoolVarP(&vars.showAll, "all", "a", false, "Show all profile configurations")
baseCmd.PersistentFlags().BoolVarP(&vars.showYaml, "yaml", "y", false, "Show profile configurations via yaml format")

View File

@@ -15,6 +15,7 @@ var (
Use: "profile COMMAND [OPTIONS]",
Short: "Node configuration profile management",
Long: "Management of node profile settings",
Args: cobra.NoArgs,
}
)

View File

@@ -35,6 +35,7 @@ func GetCommand() *cobra.Command {
Aliases: []string{"modify"},
RunE: CobraRunE(&vars),
ValidArgsFunction: completions.Profiles,
Args: cobra.ArbitraryArgs,
}
vars.profileConf.CreateFlags(baseCmd)
vars.profileDel.CreateDelFlags(baseCmd)

View File

@@ -30,6 +30,7 @@ var (
PersistentPreRunE: rootPersistentPreRunE,
SilenceUsage: true,
SilenceErrors: true,
Args: cobra.NoArgs,
}
verboseArg bool
DebugFlag bool