Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Anuj Chaudhari <[email protected]>
  • Loading branch information
anujc25 committed Jan 13, 2025
1 parent d9063fd commit 901fd27
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions pkg/command/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ func convertInvokedAs(plugins []cli.PluginInfo) {
}

// createRootCmd creates a root command.
// NOTE: Do not use this function directly as it will bypass the locking. Use `NewRootCmd` instead
func createRootCmd() (*cobra.Command, error) { //nolint: gocyclo
go interruptHandle()
var rootCmd = newRootCmd()
Expand Down Expand Up @@ -825,12 +826,11 @@ func NewRootCmd() (*cobra.Command, error) {
globalRootCmdLock.Lock()
defer globalRootCmdLock.Unlock()

var err error
if globalRootCmd == nil {
var err error
globalRootCmd, err = createRootCmd()
return globalRootCmd, err
}
return globalRootCmd, nil
return globalRootCmd, err
}

// Execute executes the CLI.
Expand Down Expand Up @@ -930,6 +930,5 @@ func printShortDescOfCmdInActiveHelp(cmd *cobra.Command, args []string) {
// NewRootCmdForTest creates a new instance of the root command for unit test purpose
// Note: This must not be used as part of the production code and only used for unit tests
func NewRootCmdForTest() (*cobra.Command, error) {
globalRootCmd = nil
return NewRootCmd()
return createRootCmd()
}

0 comments on commit 901fd27

Please sign in to comment.