mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 05:57:25 +00:00
Merge pull request #91855 from SataQiu/fix-kubectl-2020060602
kubectl: fix the bug that kubectl autoscale does not honor --name flag
This commit is contained in:
commit
9ad74781c7
@ -78,7 +78,7 @@ type AutoscaleOptions struct {
|
|||||||
dryRunStrategy cmdutil.DryRunStrategy
|
dryRunStrategy cmdutil.DryRunStrategy
|
||||||
dryRunVerifier *resource.DryRunVerifier
|
dryRunVerifier *resource.DryRunVerifier
|
||||||
builder *resource.Builder
|
builder *resource.Builder
|
||||||
generatorFunc func(string, *meta.RESTMapping) (generate.StructuredGenerator, error)
|
generatorFunc func(name, refName string, mapping *meta.RESTMapping) (generate.StructuredGenerator, error)
|
||||||
fieldManager string
|
fieldManager string
|
||||||
|
|
||||||
HPAClient autoscalingv1client.HorizontalPodAutoscalersGetter
|
HPAClient autoscalingv1client.HorizontalPodAutoscalersGetter
|
||||||
@ -170,7 +170,10 @@ func (o *AutoscaleOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args
|
|||||||
o.HPAClient = kubeClient.AutoscalingV1()
|
o.HPAClient = kubeClient.AutoscalingV1()
|
||||||
|
|
||||||
// get the generator
|
// get the generator
|
||||||
o.generatorFunc = func(name string, mapping *meta.RESTMapping) (generate.StructuredGenerator, error) {
|
o.generatorFunc = func(name, refName string, mapping *meta.RESTMapping) (generate.StructuredGenerator, error) {
|
||||||
|
if len(name) == 0 {
|
||||||
|
name = refName
|
||||||
|
}
|
||||||
switch o.Generator {
|
switch o.Generator {
|
||||||
case generateversioned.HorizontalPodAutoscalerV1GeneratorName:
|
case generateversioned.HorizontalPodAutoscalerV1GeneratorName:
|
||||||
return &generateversioned.HorizontalPodAutoscalerGeneratorV1{
|
return &generateversioned.HorizontalPodAutoscalerGeneratorV1{
|
||||||
@ -178,7 +181,7 @@ func (o *AutoscaleOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args
|
|||||||
MinReplicas: o.Min,
|
MinReplicas: o.Min,
|
||||||
MaxReplicas: o.Max,
|
MaxReplicas: o.Max,
|
||||||
CPUPercent: o.CPUPercent,
|
CPUPercent: o.CPUPercent,
|
||||||
ScaleRefName: name,
|
ScaleRefName: refName,
|
||||||
ScaleRefKind: mapping.GroupVersionKind.Kind,
|
ScaleRefKind: mapping.GroupVersionKind.Kind,
|
||||||
ScaleRefAPIVersion: mapping.GroupVersionKind.GroupVersion().String(),
|
ScaleRefAPIVersion: mapping.GroupVersionKind.GroupVersion().String(),
|
||||||
}, nil
|
}, nil
|
||||||
@ -240,7 +243,7 @@ func (o *AutoscaleOptions) Run() error {
|
|||||||
return fmt.Errorf("cannot autoscale a %v: %v", mapping.GroupVersionKind.Kind, err)
|
return fmt.Errorf("cannot autoscale a %v: %v", mapping.GroupVersionKind.Kind, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
generator, err := o.generatorFunc(info.Name, mapping)
|
generator, err := o.generatorFunc(o.Name, info.Name, mapping)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user