mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
Merge pull request #92178 from zhouya0/remove_kubectl_run_replicas_flag
Remove kubectl run validate replicas logic
This commit is contained in:
commit
e24cbc9263
@ -280,10 +280,6 @@ func (o *RunOptions) Run(f cmdutil.Factory, cmd *cobra.Command, args []string) e
|
|||||||
if o.TTY && !o.Interactive {
|
if o.TTY && !o.Interactive {
|
||||||
return cmdutil.UsageErrorf(cmd, "-i/--stdin is required for containers with -t/--tty=true")
|
return cmdutil.UsageErrorf(cmd, "-i/--stdin is required for containers with -t/--tty=true")
|
||||||
}
|
}
|
||||||
replicas := cmdutil.GetFlagInt(cmd, "replicas")
|
|
||||||
if o.Interactive && replicas != 1 {
|
|
||||||
return cmdutil.UsageErrorf(cmd, "-i/--stdin requires that replicas is 1, found %d", replicas)
|
|
||||||
}
|
|
||||||
if o.Expose && len(o.Port) == 0 {
|
if o.Expose && len(o.Port) == 0 {
|
||||||
return cmdutil.UsageErrorf(cmd, "--port must be set when exposing a service")
|
return cmdutil.UsageErrorf(cmd, "--port must be set when exposing a service")
|
||||||
}
|
}
|
||||||
@ -296,9 +292,6 @@ func (o *RunOptions) Run(f cmdutil.Factory, cmd *cobra.Command, args []string) e
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if restartPolicy != corev1.RestartPolicyAlways && replicas != 1 {
|
|
||||||
return cmdutil.UsageErrorf(cmd, "--restart=%s requires that --replicas=1, found %d", restartPolicy, replicas)
|
|
||||||
}
|
|
||||||
|
|
||||||
remove := cmdutil.GetFlagBool(cmd, "rm")
|
remove := cmdutil.GetFlagBool(cmd, "rm")
|
||||||
if !o.Attach && remove {
|
if !o.Attach && remove {
|
||||||
|
@ -441,16 +441,6 @@ func TestRunValidations(t *testing.T) {
|
|||||||
},
|
},
|
||||||
expectedErr: "Invalid image name",
|
expectedErr: "Invalid image name",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "test stdin replicas value",
|
|
||||||
args: []string{"test"},
|
|
||||||
flags: map[string]string{
|
|
||||||
"image": "busybox",
|
|
||||||
"stdin": "true",
|
|
||||||
"replicas": "2",
|
|
||||||
},
|
|
||||||
expectedErr: "stdin requires that replicas is 1",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "test rm errors when used on non-attached containers",
|
name: "test rm errors when used on non-attached containers",
|
||||||
args: []string{"test"},
|
args: []string{"test"},
|
||||||
|
Loading…
Reference in New Issue
Block a user