Return an error if rename arguments != 2

The original implementation presented a warning if more than two
arguments were presented, and didn't handle the case where fewer than
two arguments were provided. This change requires precisely two
arguments and returns an error otherwise.

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
Jonathon Anderson
2024-01-24 15:05:34 -07:00
parent d262ec10ef
commit acfd70a645

View File

@@ -11,8 +11,8 @@ import (
)
func CobraRunE(cmd *cobra.Command, args []string) (err error) {
if len(args) > 2 {
wwlog.Warn("rename only requires 2 arguments but you provided %d arguments. Hence, they will be ignored.", len(args))
if len(args) != 2 {
return fmt.Errorf("rename requires 2 arguments: %d provided", len(args))
}
crp := &wwapiv1.ContainerRenameParameter{