From d968b021534af864845b0b33760abeeb1488836f Mon Sep 17 00:00:00 2001 From: Jonathon Anderson Date: Tue, 11 Feb 2025 10:23:56 -0700 Subject: [PATCH] Fix image completion - Fixes #1734 Signed-off-by: Jonathon Anderson --- internal/app/wwctl/completions/completions.go | 2 +- internal/app/wwctl/node/add/root.go | 4 ++-- internal/app/wwctl/node/set/root.go | 4 ++-- internal/app/wwctl/profile/add/root.go | 2 +- internal/app/wwctl/profile/set/root.go | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/app/wwctl/completions/completions.go b/internal/app/wwctl/completions/completions.go index 5ebb3ca7..a6b3847f 100644 --- a/internal/app/wwctl/completions/completions.go +++ b/internal/app/wwctl/completions/completions.go @@ -52,7 +52,7 @@ func ProfileKernelVersion(cmd *cobra.Command, args []string, toComplete string) } func Images(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if sources, err := image.ListSources(); err != nil { + if sources, err := image.ListSources(); err == nil { return sources, cobra.ShellCompDirectiveNoFileComp } return nil, cobra.ShellCompDirectiveNoFileComp diff --git a/internal/app/wwctl/node/add/root.go b/internal/app/wwctl/node/add/root.go index f7f90577..05c5ad85 100644 --- a/internal/app/wwctl/node/add/root.go +++ b/internal/app/wwctl/node/add/root.go @@ -33,7 +33,7 @@ func GetCommand() *cobra.Command { flags.AddWwinit(baseCmd, &(vars.nodeConf.SystemOverlay)) flags.AddRuntime(baseCmd, &(vars.nodeConf.RuntimeOverlay)) // register the command line completions - if err := baseCmd.RegisterFlagCompletionFunc("image", completions.Images); err != nil { // no limit + if err := baseCmd.RegisterFlagCompletionFunc("image", completions.Images); err != nil { panic(err) } if err := baseCmd.RegisterFlagCompletionFunc("kernelversion", completions.NodeKernelVersion); err != nil { @@ -51,7 +51,7 @@ func GetCommand() *cobra.Command { if err := baseCmd.RegisterFlagCompletionFunc("wwinit", completions.OverlayList); err != nil { panic(err) } - if err := baseCmd.RegisterFlagCompletionFunc("profile", completions.Profiles); err != nil { // no limit + if err := baseCmd.RegisterFlagCompletionFunc("profile", completions.Profiles); err != nil { panic(err) } diff --git a/internal/app/wwctl/node/set/root.go b/internal/app/wwctl/node/set/root.go index 13280c4f..7da68e93 100644 --- a/internal/app/wwctl/node/set/root.go +++ b/internal/app/wwctl/node/set/root.go @@ -40,7 +40,7 @@ func GetCommand() *cobra.Command { baseCmd.PersistentFlags().BoolVarP(&vars.setYes, "yes", "y", false, "Set 'yes' to all questions asked") baseCmd.PersistentFlags().BoolVarP(&vars.setForce, "force", "f", false, "Force configuration (even on error)") // register the command line completions - if err := baseCmd.RegisterFlagCompletionFunc("image", completions.Images); err != nil { // no limit + if err := baseCmd.RegisterFlagCompletionFunc("image", completions.Images); err != nil { panic(err) } if err := baseCmd.RegisterFlagCompletionFunc("kernelversion", completions.NodeKernelVersion); err != nil { @@ -58,7 +58,7 @@ func GetCommand() *cobra.Command { if err := baseCmd.RegisterFlagCompletionFunc("wwinit", completions.OverlayList); err != nil { panic(err) } - if err := baseCmd.RegisterFlagCompletionFunc("profile", completions.Profiles); err != nil { // no limit + if err := baseCmd.RegisterFlagCompletionFunc("profile", completions.Profiles); err != nil { panic(err) } diff --git a/internal/app/wwctl/profile/add/root.go b/internal/app/wwctl/profile/add/root.go index 4994bc9e..255bcef8 100644 --- a/internal/app/wwctl/profile/add/root.go +++ b/internal/app/wwctl/profile/add/root.go @@ -31,7 +31,7 @@ func GetCommand() *cobra.Command { flags.AddWwinit(baseCmd, &(vars.profileConf.SystemOverlay)) flags.AddRuntime(baseCmd, &(vars.profileConf.RuntimeOverlay)) // register the command line completions - if err := baseCmd.RegisterFlagCompletionFunc("image", completions.Images); err != nil { // no limit + if err := baseCmd.RegisterFlagCompletionFunc("image", completions.Images); err != nil { panic(err) } if err := baseCmd.RegisterFlagCompletionFunc("kernelversion", completions.ProfileKernelVersion); err != nil { diff --git a/internal/app/wwctl/profile/set/root.go b/internal/app/wwctl/profile/set/root.go index 0f3f8759..df76aab6 100644 --- a/internal/app/wwctl/profile/set/root.go +++ b/internal/app/wwctl/profile/set/root.go @@ -44,7 +44,7 @@ func GetCommand() *cobra.Command { flags.AddRuntime(baseCmd, &(vars.profileConf.RuntimeOverlay)) baseCmd.PersistentFlags().BoolVarP(&vars.setYes, "yes", "y", false, "Set 'yes' to all questions asked") // register the command line completions - if err := baseCmd.RegisterFlagCompletionFunc("image", completions.Images); err != nil { // no limit + if err := baseCmd.RegisterFlagCompletionFunc("image", completions.Images); err != nil { panic(err) } if err := baseCmd.RegisterFlagCompletionFunc("kernelversion", completions.ProfileKernelVersion); err != nil {