internal/commands: RegisterLegacy: remove redundant copy
The RegisterLegacy and Register functions register constructors for commands, so we should expect them to be a fresh copy that is not shared, which means that we can mutate the command in-place. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@ -22,14 +22,13 @@ func Register(f func(command.Cli) *cobra.Command) {
|
||||
// in an init function and is not safe for concurrent use.
|
||||
func RegisterLegacy(f func(command.Cli) *cobra.Command) {
|
||||
commands = append(commands, func(c command.Cli) *cobra.Command {
|
||||
cmd := f(c)
|
||||
if os.Getenv("DOCKER_HIDE_LEGACY_COMMANDS") == "" {
|
||||
return cmd
|
||||
return f(c)
|
||||
}
|
||||
cmdCopy := *cmd
|
||||
cmdCopy.Hidden = true
|
||||
cmdCopy.Aliases = []string{}
|
||||
return &cmdCopy
|
||||
cmd := f(c)
|
||||
cmd.Hidden = true
|
||||
cmd.Aliases = []string{}
|
||||
return cmd
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user