Refactor the CreateFlags command

* added the additional type flag, which can be bool,IP
* UNDEF is recognized for the bool flag
* 0.0.0.0 must be used as UNDEF for IP flag

Signed-off-by: Christian Goll <cgoll@suse.de>
This commit is contained in:
Christian Goll
2023-02-02 17:06:03 +01:00
parent 09d14039b0
commit 13bc378a6b
11 changed files with 241 additions and 116 deletions

View File

@@ -15,7 +15,7 @@ var (
Use: "set [OPTIONS] [PROFILE ...]",
Short: "Configure node profile properties",
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'/'0.0.0.0' to remove a configuration",
Args: cobra.MinimumNArgs(0),
RunE: CobraRunE,
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
@@ -38,11 +38,12 @@ var (
SetForce bool
NetName string
ProfileConf node.NodeConf
Converters []func()
)
func init() {
ProfileConf = node.NewConf()
ProfileConf.CreateFlags(baseCmd,
Converters = ProfileConf.CreateFlags(baseCmd,
[]string{"ipaddr", "ipaddr6", "ipmiaddr", "profile"})
baseCmd.PersistentFlags().StringVar(&NetName, "netname", "default", "Set network name for network options")
baseCmd.PersistentFlags().StringVarP(&SetNetDevDel, "netdel", "D", "", "Delete the node's network device")