mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 18:24:07 +00:00
Merge pull request #56779 from Lion-Wei/kubectl-2
Automatic merge from submit-queue (batch tested with PRs 57651, 56411, 56779, 57523, 57624). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Error out if kubectl create with extra argument **What this PR does / why we need it**: When using `kubectl create` command with extra args, kubectl will accept the first one and ignore the others. This pr give a warnning in this case **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes kubernetes/kubectl#148 **Special notes for your reviewer**: **Release note**: ```release-note NONE ```
This commit is contained in:
commit
b3cf1bd102
@ -278,8 +278,8 @@ func createAndRefresh(info *resource.Info) error {
|
||||
|
||||
// NameFromCommandArgs is a utility function for commands that assume the first argument is a resource name
|
||||
func NameFromCommandArgs(cmd *cobra.Command, args []string) (string, error) {
|
||||
if len(args) == 0 {
|
||||
return "", cmdutil.UsageErrorf(cmd, "NAME is required")
|
||||
if len(args) != 1 {
|
||||
return "", cmdutil.UsageErrorf(cmd, "exactly one NAME is required, got %d", len(args))
|
||||
}
|
||||
return args[0], nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user