mirror of
https://github.com/kubernetes/kubectl.git
synced 2026-06-03 22:04:23 -04:00
Merge pull request #100545 from xuhdev/scale-replica-flag
Validate scale's --current-replicas flag Kubernetes-commit: 4239837f23cad8398ddb0ca53c6ff582ac773ade
This commit is contained in:
commit
ac49920c0c
4 changed files with 23 additions and 19 deletions
8
Godeps/Godeps.json
generated
8
Godeps/Godeps.json
generated
|
|
@ -1036,11 +1036,11 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/api",
|
||||
"Rev": "86cef11b7287"
|
||||
"Rev": "648b77825832"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery",
|
||||
"Rev": "1ba67c107540"
|
||||
"Rev": "8daf28983e6e"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/cli-runtime",
|
||||
|
|
@ -1048,11 +1048,11 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/client-go",
|
||||
"Rev": "d974964d1226"
|
||||
"Rev": "8c8fa70f7a2a"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/code-generator",
|
||||
"Rev": "bdc239664504"
|
||||
"Rev": "70ccd8277642"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/component-base",
|
||||
|
|
|
|||
14
go.mod
14
go.mod
|
|
@ -33,10 +33,10 @@ require (
|
|||
github.com/stretchr/testify v1.6.1
|
||||
golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
k8s.io/api v0.0.0-20210416194706-86cef11b7287
|
||||
k8s.io/apimachinery v0.0.0-20210415154527-1ba67c107540
|
||||
k8s.io/api v0.0.0-20210417155159-648b77825832
|
||||
k8s.io/apimachinery v0.0.0-20210417144234-8daf28983e6e
|
||||
k8s.io/cli-runtime v0.0.0-20210416000535-a3112a1a9f25
|
||||
k8s.io/client-go v0.0.0-20210416194932-d974964d1226
|
||||
k8s.io/client-go v0.0.0-20210417155731-8c8fa70f7a2a
|
||||
k8s.io/component-base v0.0.0-20210412032905-a57cc3fac704
|
||||
k8s.io/component-helpers v0.0.0-20210411032753-ddd2d94034ce
|
||||
k8s.io/klog/v2 v2.8.0
|
||||
|
|
@ -49,11 +49,11 @@ require (
|
|||
)
|
||||
|
||||
replace (
|
||||
k8s.io/api => k8s.io/api v0.0.0-20210416194706-86cef11b7287
|
||||
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20210415154527-1ba67c107540
|
||||
k8s.io/api => k8s.io/api v0.0.0-20210417155159-648b77825832
|
||||
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20210417144234-8daf28983e6e
|
||||
k8s.io/cli-runtime => k8s.io/cli-runtime v0.0.0-20210416000535-a3112a1a9f25
|
||||
k8s.io/client-go => k8s.io/client-go v0.0.0-20210416194932-d974964d1226
|
||||
k8s.io/code-generator => k8s.io/code-generator v0.0.0-20210411031433-bdc239664504
|
||||
k8s.io/client-go => k8s.io/client-go v0.0.0-20210417155731-8c8fa70f7a2a
|
||||
k8s.io/code-generator => k8s.io/code-generator v0.0.0-20210417144234-70ccd8277642
|
||||
k8s.io/component-base => k8s.io/component-base v0.0.0-20210412032905-a57cc3fac704
|
||||
k8s.io/component-helpers => k8s.io/component-helpers v0.0.0-20210411032753-ddd2d94034ce
|
||||
k8s.io/metrics => k8s.io/metrics v0.0.0-20210411034019-e376210570bf
|
||||
|
|
|
|||
14
go.sum
14
go.sum
|
|
@ -727,15 +727,15 @@ honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWh
|
|||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
k8s.io/api v0.0.0-20210416194706-86cef11b7287 h1:nWl530sx2Lk0p+jyCnG2NcAZ/yO+6vd6MLe/QGTSXKg=
|
||||
k8s.io/api v0.0.0-20210416194706-86cef11b7287/go.mod h1:DHqxvzZf7mMtXnGgywYgvLoyfA2SGsMd1vdGAEcDjbA=
|
||||
k8s.io/apimachinery v0.0.0-20210415154527-1ba67c107540 h1:xFowz4QhYZAZ9cFw4BhLhTSkFSiYy6ArOL1oUAs15wI=
|
||||
k8s.io/apimachinery v0.0.0-20210415154527-1ba67c107540/go.mod h1:CRK4uy8GKqwLtMa4Gj9i/B2EBjcqOsuvwP2xZJWUwmk=
|
||||
k8s.io/api v0.0.0-20210417155159-648b77825832 h1:No2ZlATFo1sNHtuP1p7SIWTkq5cYeyBrAWOT98xshjY=
|
||||
k8s.io/api v0.0.0-20210417155159-648b77825832/go.mod h1:1rKdGusR4MnUa1eIY/WzLvM2oeduZr38Mmsgdft/2xg=
|
||||
k8s.io/apimachinery v0.0.0-20210417144234-8daf28983e6e h1:fjczwJMl+07DTfpVAqAfprBYXxSMgsqpjVXfzaEa8k4=
|
||||
k8s.io/apimachinery v0.0.0-20210417144234-8daf28983e6e/go.mod h1:CRK4uy8GKqwLtMa4Gj9i/B2EBjcqOsuvwP2xZJWUwmk=
|
||||
k8s.io/cli-runtime v0.0.0-20210416000535-a3112a1a9f25 h1:wjJP2Dhs8eHSzZs3fDzz3vyNknJ3rxeIhdu4FbmDn54=
|
||||
k8s.io/cli-runtime v0.0.0-20210416000535-a3112a1a9f25/go.mod h1:bY35daqhQG2nFzNoaAYiUXOO1sQPRqOZxq1Q6MReXlQ=
|
||||
k8s.io/client-go v0.0.0-20210416194932-d974964d1226 h1:4WX6yJ7a+0JxaxSm8ENdZRBCi0CRwMWLdOMEMjBs+ks=
|
||||
k8s.io/client-go v0.0.0-20210416194932-d974964d1226/go.mod h1:RbsIgkosH5M8OkVp5z3OCH5jtynzbv79nvpmcUh94EM=
|
||||
k8s.io/code-generator v0.0.0-20210411031433-bdc239664504/go.mod h1:PXvzWuKkvLN0uh/kV/NghowjknTgxfcJ0SaRzqi6vok=
|
||||
k8s.io/client-go v0.0.0-20210417155731-8c8fa70f7a2a h1:akZ/DJ4KidjhpYDg2A7VsptVVwpcR4Fnu0W4vBcOX9U=
|
||||
k8s.io/client-go v0.0.0-20210417155731-8c8fa70f7a2a/go.mod h1:NcSllaKuzG5G3cDEGxlLIN1HpxPHWykJaa67vGc32XY=
|
||||
k8s.io/code-generator v0.0.0-20210417144234-70ccd8277642/go.mod h1:PXvzWuKkvLN0uh/kV/NghowjknTgxfcJ0SaRzqi6vok=
|
||||
k8s.io/component-base v0.0.0-20210412032905-a57cc3fac704 h1:xstmd0kVbcrlTtk3MFlk3FKj0WXkJqnbaU2j3LzKxMI=
|
||||
k8s.io/component-base v0.0.0-20210412032905-a57cc3fac704/go.mod h1:zEytEW+Y696JL4g97mo/bP6hzeY26r9zDRw2IFbc7fE=
|
||||
k8s.io/component-helpers v0.0.0-20210411032753-ddd2d94034ce h1:VIdll4TybU2LhAhlCkr+TVVLHGi6RVRKi8HTuFMa2+s=
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ func NewCmdScale(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobr
|
|||
cmd.Flags().StringVarP(&o.Selector, "selector", "l", o.Selector, "Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)")
|
||||
cmd.Flags().BoolVar(&o.All, "all", o.All, "Select all resources in the namespace of the specified resource types")
|
||||
cmd.Flags().StringVar(&o.ResourceVersion, "resource-version", o.ResourceVersion, i18n.T("Precondition for resource version. Requires that the current resource version match this value in order to scale."))
|
||||
cmd.Flags().IntVar(&o.CurrentReplicas, "current-replicas", o.CurrentReplicas, "Precondition for current size. Requires that the current size of the resource match this value in order to scale.")
|
||||
cmd.Flags().IntVar(&o.CurrentReplicas, "current-replicas", o.CurrentReplicas, "Precondition for current size. Requires that the current size of the resource match this value in order to scale. -1 (default) for no condition.")
|
||||
cmd.Flags().IntVar(&o.Replicas, "replicas", o.Replicas, "The new desired number of replicas. Required.")
|
||||
cmd.MarkFlagRequired("replicas")
|
||||
cmd.Flags().DurationVar(&o.Timeout, "timeout", 0, "The length of time to wait before giving up on a scale operation, zero means don't wait. Any other values should contain a corresponding time unit (e.g. 1s, 2m, 3h).")
|
||||
|
|
@ -185,6 +185,10 @@ func (o *ScaleOptions) Validate(cmd *cobra.Command) error {
|
|||
return fmt.Errorf("The --replicas=COUNT flag is required, and COUNT must be greater than or equal to 0")
|
||||
}
|
||||
|
||||
if o.CurrentReplicas < -1 {
|
||||
return fmt.Errorf("The --current-replicas must specify an integer of -1 or greater")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue