mirror of
https://github.com/kubernetes/client-go.git
synced 2025-09-04 16:40:21 +00:00
[client-go] Add apps.Scale support to Scale client
apps/v1betaX inadventertently contains its own variant of Scale. In order to support scaling Deployments, ReplicaSets, etc, we need to support these versions of Scale as well. Kubernetes-commit: 2c9fc432947bedb2fffc12faf7fc0ee1d0ceffd9
This commit is contained in:
committed by
Kubernetes Publisher
parent
9177580b4c
commit
742a5f2338
@@ -35,6 +35,7 @@ import (
|
||||
fakerest "k8s.io/client-go/rest/fake"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
appsv1beta1 "k8s.io/api/apps/v1beta1"
|
||||
appsv1beta2 "k8s.io/api/apps/v1beta2"
|
||||
autoscalingv1 "k8s.io/api/autoscaling/v1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
@@ -75,7 +76,14 @@ func fakeScaleClient(t *testing.T) (ScalesGetter, []schema.GroupResource) {
|
||||
GroupVersion: appsv1beta2.SchemeGroupVersion.String(),
|
||||
APIResources: []metav1.APIResource{
|
||||
{Name: "deployments", Namespaced: true, Kind: "Deployment"},
|
||||
{Name: "deployments/scale", Namespaced: true, Kind: "Scale", Group: "autoscaling", Version: "v1"},
|
||||
{Name: "deployments/scale", Namespaced: true, Kind: "Scale", Group: "apps", Version: "v1beta2"},
|
||||
},
|
||||
},
|
||||
{
|
||||
GroupVersion: appsv1beta1.SchemeGroupVersion.String(),
|
||||
APIResources: []metav1.APIResource{
|
||||
{Name: "statefulsets", Namespaced: true, Kind: "StatefulSet"},
|
||||
{Name: "statefulsets/scale", Namespaced: true, Kind: "Scale", Group: "apps", Version: "v1beta1"},
|
||||
},
|
||||
},
|
||||
// test a resource that doesn't exist anywere to make sure we're not accidentally depending
|
||||
@@ -123,11 +131,40 @@ func fakeScaleClient(t *testing.T) (ScalesGetter, []schema.GroupResource) {
|
||||
TargetSelector: "foo=bar",
|
||||
},
|
||||
}
|
||||
appsV1beta2Scale := &appsv1beta2.Scale{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
Kind: "Scale",
|
||||
APIVersion: appsv1beta2.SchemeGroupVersion.String(),
|
||||
},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "foo",
|
||||
},
|
||||
Spec: appsv1beta2.ScaleSpec{Replicas: 10},
|
||||
Status: appsv1beta2.ScaleStatus{
|
||||
Replicas: 10,
|
||||
TargetSelector: "foo=bar",
|
||||
},
|
||||
}
|
||||
appsV1beta1Scale := &appsv1beta1.Scale{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
Kind: "Scale",
|
||||
APIVersion: appsv1beta1.SchemeGroupVersion.String(),
|
||||
},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "foo",
|
||||
},
|
||||
Spec: appsv1beta1.ScaleSpec{Replicas: 10},
|
||||
Status: appsv1beta1.ScaleStatus{
|
||||
Replicas: 10,
|
||||
TargetSelector: "foo=bar",
|
||||
},
|
||||
}
|
||||
|
||||
resourcePaths := map[string]runtime.Object{
|
||||
"/api/v1/namespaces/default/replicationcontrollers/foo/scale": autoscalingScale,
|
||||
"/apis/extensions/v1beta1/namespaces/default/replicasets/foo/scale": extScale,
|
||||
"/apis/apps/v1beta2/namespaces/default/deployments/foo/scale": autoscalingScale,
|
||||
"/apis/apps/v1beta1/namespaces/default/statefulsets/foo/scale": appsV1beta1Scale,
|
||||
"/apis/apps/v1beta2/namespaces/default/deployments/foo/scale": appsV1beta2Scale,
|
||||
"/apis/cheese.testing.k8s.io/v27alpha15/namespaces/default/cheddars/foo/scale": extScale,
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user