mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-04 23:17:50 +00:00
kubectl/cmd: many small refactors
* Rename variables and functions to match Go convention.
For example, UsageError --> UsageErrorf.
* Remove redundant or unreachable code.
* Simplify some utility functions (no functionality changes).
* Fix hanging 'if { return } else { return }' constructs.
* Fix several incorrect printf verbs.
This commit is contained in:
@@ -152,19 +152,19 @@ type ExecOptions struct {
|
||||
func (p *ExecOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, argsIn []string, argsLenAtDash int) error {
|
||||
// Let kubectl exec follow rules for `--`, see #13004 issue
|
||||
if len(p.PodName) == 0 && (len(argsIn) == 0 || argsLenAtDash == 0) {
|
||||
return cmdutil.UsageError(cmd, execUsageStr)
|
||||
return cmdutil.UsageErrorf(cmd, execUsageStr)
|
||||
}
|
||||
if len(p.PodName) != 0 {
|
||||
printDeprecationWarning("exec POD_NAME", "-p POD_NAME")
|
||||
if len(argsIn) < 1 {
|
||||
return cmdutil.UsageError(cmd, execUsageStr)
|
||||
return cmdutil.UsageErrorf(cmd, execUsageStr)
|
||||
}
|
||||
p.Command = argsIn
|
||||
} else {
|
||||
p.PodName = argsIn[0]
|
||||
p.Command = argsIn[1:]
|
||||
if len(p.Command) < 1 {
|
||||
return cmdutil.UsageError(cmd, execUsageStr)
|
||||
return cmdutil.UsageErrorf(cmd, execUsageStr)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user