Commit fd9e9b01 authored by Jordan Liggitt's avatar Jordan Liggitt

Remove uses of extensions/v1beta1 clients

parent 842bd1e1
......@@ -84,7 +84,7 @@ func TestValidateEvent(t *testing.T) {
Namespace: metav1.NamespaceDefault,
},
InvolvedObject: core.ObjectReference{
APIVersion: "extensions/v1beta1",
APIVersion: "apps/v1",
Kind: "NoKind",
Namespace: metav1.NamespaceDefault,
},
......@@ -97,7 +97,7 @@ func TestValidateEvent(t *testing.T) {
Namespace: metav1.NamespaceDefault,
},
InvolvedObject: core.ObjectReference{
APIVersion: "extensions/v1beta1",
APIVersion: "batch/v1",
Kind: "Job",
Namespace: "foo",
},
......@@ -110,7 +110,7 @@ func TestValidateEvent(t *testing.T) {
Namespace: metav1.NamespaceDefault,
},
InvolvedObject: core.ObjectReference{
APIVersion: "extensions/v1beta1",
APIVersion: "batch/v1",
Kind: "Job",
Namespace: metav1.NamespaceDefault,
},
......@@ -149,7 +149,7 @@ func TestValidateEvent(t *testing.T) {
Namespace: metav1.NamespaceDefault,
},
InvolvedObject: core.ObjectReference{
APIVersion: "extensions",
APIVersion: "batch",
Kind: "Job",
Namespace: "foo",
},
......@@ -162,8 +162,7 @@ func TestValidateEvent(t *testing.T) {
Namespace: "foo",
},
InvolvedObject: core.ObjectReference{
// must register in v1beta1 to be true
APIVersion: "extensions/v1beta1",
APIVersion: "batch/v1",
Kind: "Job",
Namespace: "foo",
},
......
......@@ -412,7 +412,7 @@ type RealRSControl struct {
var _ RSControlInterface = &RealRSControl{}
func (r RealRSControl) PatchReplicaSet(namespace, name string, data []byte) error {
_, err := r.KubeClient.ExtensionsV1beta1().ReplicaSets(namespace).Patch(name, types.StrategicMergePatchType, data)
_, err := r.KubeClient.AppsV1().ReplicaSets(namespace).Patch(name, types.StrategicMergePatchType, data)
return err
}
......
......@@ -234,8 +234,8 @@ func TestSyncNamespaceThatIsTerminatingNonExperimental(t *testing.T) {
testSyncNamespaceThatIsTerminating(t, &metav1.APIVersions{})
}
func TestSyncNamespaceThatIsTerminatingV1Beta1(t *testing.T) {
testSyncNamespaceThatIsTerminating(t, &metav1.APIVersions{Versions: []string{"extensions/v1beta1"}})
func TestSyncNamespaceThatIsTerminatingV1(t *testing.T) {
testSyncNamespaceThatIsTerminating(t, &metav1.APIVersions{Versions: []string{"apps/v1"}})
}
func TestSyncNamespaceThatIsActive(t *testing.T) {
......@@ -331,7 +331,7 @@ func testResources() []*metav1.APIResourceList {
},
},
{
GroupVersion: "extensions/v1beta1",
GroupVersion: "apps/v1",
APIResources: []metav1.APIResource{
{
Name: "deployments",
......
......@@ -51,8 +51,8 @@ import (
"github.com/stretchr/testify/assert"
_ "k8s.io/kubernetes/pkg/apis/apps/install"
_ "k8s.io/kubernetes/pkg/apis/autoscaling/install"
_ "k8s.io/kubernetes/pkg/apis/extensions/install"
)
var statusOk = []autoscalingv2.HorizontalPodAutoscalerCondition{
......@@ -862,7 +862,7 @@ func TestScaleUpDeployment(t *testing.T) {
useMetricsAPI: true,
resource: &fakeResource{
name: "test-dep",
apiVersion: "extensions/v1beta1",
apiVersion: "apps/v1",
kind: "Deployment",
},
}
......@@ -882,7 +882,7 @@ func TestScaleUpReplicaSet(t *testing.T) {
useMetricsAPI: true,
resource: &fakeResource{
name: "test-replicaset",
apiVersion: "extensions/v1beta1",
apiVersion: "apps/v1",
kind: "ReplicaSet",
},
}
......@@ -1033,7 +1033,7 @@ func TestScaleUpCMObject(t *testing.T) {
Type: autoscalingv2.ObjectMetricSourceType,
Object: &autoscalingv2.ObjectMetricSource{
DescribedObject: autoscalingv2.CrossVersionObjectReference{
APIVersion: "extensions/v1beta1",
APIVersion: "apps/v1",
Kind: "Deployment",
Name: "some-deployment",
},
......@@ -1183,7 +1183,7 @@ func TestScaleDownCMObject(t *testing.T) {
Type: autoscalingv2.ObjectMetricSourceType,
Object: &autoscalingv2.ObjectMetricSource{
DescribedObject: autoscalingv2.CrossVersionObjectReference{
APIVersion: "extensions/v1beta1",
APIVersion: "apps/v1",
Kind: "Deployment",
Name: "some-deployment",
},
......@@ -1392,7 +1392,7 @@ func TestToleranceCMObject(t *testing.T) {
Type: autoscalingv2.ObjectMetricSourceType,
Object: &autoscalingv2.ObjectMetricSource{
DescribedObject: autoscalingv2.CrossVersionObjectReference{
APIVersion: "extensions/v1beta1",
APIVersion: "apps/v1",
Kind: "Deployment",
Name: "some-deployment",
},
......@@ -1860,7 +1860,7 @@ func TestConditionFailedGetMetrics(t *testing.T) {
Type: autoscalingv2.ObjectMetricSourceType,
Object: &autoscalingv2.ObjectMetricSource{
DescribedObject: autoscalingv2.CrossVersionObjectReference{
APIVersion: "extensions/v1beta1",
APIVersion: "apps/v1",
Kind: "Deployment",
Name: "some-deployment",
},
......
......@@ -50,9 +50,9 @@ import (
"github.com/stretchr/testify/assert"
_ "k8s.io/kubernetes/pkg/apis/apps/install"
_ "k8s.io/kubernetes/pkg/apis/autoscaling/install"
_ "k8s.io/kubernetes/pkg/apis/core/install"
_ "k8s.io/kubernetes/pkg/apis/extensions/install"
)
func (w fakeResponseWrapper) DoRaw() ([]byte, error) {
......@@ -588,7 +588,7 @@ func TestLegacyScaleUpDeployment(t *testing.T) {
useMetricsAPI: true,
resource: &fakeResource{
name: "test-dep",
apiVersion: "extensions/v1beta1",
apiVersion: "apps/v1",
kind: "Deployment",
},
}
......@@ -608,7 +608,7 @@ func TestLegacyScaleUpReplicaSet(t *testing.T) {
useMetricsAPI: true,
resource: &fakeResource{
name: "test-replicaset",
apiVersion: "extensions/v1beta1",
apiVersion: "apps/v1",
kind: "ReplicaSet",
},
}
......
......@@ -31,7 +31,7 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
core "k8s.io/client-go/testing"
"k8s.io/kubernetes/pkg/api/legacyscheme"
_ "k8s.io/kubernetes/pkg/apis/extensions/install"
_ "k8s.io/kubernetes/pkg/apis/apps/install"
cmapi "k8s.io/metrics/pkg/apis/custom_metrics/v1beta2"
emapi "k8s.io/metrics/pkg/apis/external_metrics/v1beta1"
metricsapi "k8s.io/metrics/pkg/apis/metrics/v1beta1"
......@@ -305,7 +305,7 @@ func TestRESTClientSingleObject(t *testing.T) {
targetTimestamp: 1,
reportedMetricPoints: []metricPoint{{10, 1}},
singleObject: &autoscalingapi.CrossVersionObjectReference{
APIVersion: "extensions/v1beta1",
APIVersion: "apps/v1",
Kind: "Deployment",
Name: "some-dep",
},
......
......@@ -623,7 +623,7 @@ func TestReplicaCalcScaleUpCMObject(t *testing.T) {
expectedUtilization: 20000,
singleObject: &autoscalingv2.CrossVersionObjectReference{
Kind: "Deployment",
APIVersion: "extensions/v1beta1",
APIVersion: "apps/v1",
Name: "some-deployment",
},
},
......@@ -643,7 +643,7 @@ func TestReplicaCalcScaleUpCMObjectIgnoresUnreadyPods(t *testing.T) {
expectedUtilization: 50000,
singleObject: &autoscalingv2.CrossVersionObjectReference{
Kind: "Deployment",
APIVersion: "extensions/v1beta1",
APIVersion: "apps/v1",
Name: "some-deployment",
},
},
......@@ -758,7 +758,7 @@ func TestReplicaCalcScaleDownCMObject(t *testing.T) {
expectedUtilization: 12000,
singleObject: &autoscalingv2.CrossVersionObjectReference{
Kind: "Deployment",
APIVersion: "extensions/v1beta1",
APIVersion: "apps/v1",
Name: "some-deployment",
},
},
......@@ -916,7 +916,7 @@ func TestReplicaCalcToleranceCMObject(t *testing.T) {
expectedUtilization: 20666,
singleObject: &autoscalingv2.CrossVersionObjectReference{
Kind: "Deployment",
APIVersion: "extensions/v1beta1",
APIVersion: "apps/v1",
Name: "some-deployment",
},
},
......
......@@ -27,6 +27,7 @@ import (
"time"
apps "k8s.io/api/apps/v1"
autoscalingv1 "k8s.io/api/autoscaling/v1"
"k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
......@@ -239,6 +240,16 @@ func (c conversionClient) Patch(name string, pt types.PatchType, data []byte, su
return nil, errors.New("Patch() is not implemented for conversionClient")
}
func (c conversionClient) GetScale(name string, options metav1.GetOptions) (result *autoscalingv1.Scale, err error) {
// This is not used by RSC.
return nil, errors.New("GetScale() is not implemented for conversionClient")
}
func (c conversionClient) UpdateScale(name string, scale *autoscalingv1.Scale) (result *autoscalingv1.Scale, err error) {
// This is not used by RSC.
return nil, errors.New("UpdateScale() is not implemented for conversionClient")
}
func convertSlice(rcList []*v1.ReplicationController) ([]*apps.ReplicaSet, error) {
rsList := make([]*apps.ReplicaSet, 0, len(rcList))
for _, rc := range rcList {
......
......@@ -26,19 +26,19 @@ var _ = Describe("Comparing fields of remote and recorded ", func() {
Context("Test conflict in map fields of remote and recorded", func() {
It("If conflicts found, expected return error", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
foo1: "key1"
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
foo2: "baz2-1"
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
foo1: "baz1-0"
......@@ -53,7 +53,7 @@ spec:
Context("Test conflict in list fields of remote and recorded ", func() {
It("If conflicts found, expected return false", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
finalizers:
......@@ -62,7 +62,7 @@ metadata:
- "d"
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
finalizers:
......@@ -70,7 +70,7 @@ metadata:
- "b"
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
finalizers:
......@@ -87,7 +87,7 @@ metadata:
Context("Test conflict in Map-List fields of remote and recorded ", func() {
It("should leave the item", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -97,7 +97,7 @@ spec:
image: image1
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -107,7 +107,7 @@ spec:
image: image2
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -125,21 +125,21 @@ spec:
Context("Test conflicts in nested map field", func() {
It("If conflicts found, expected return error", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
foo1:
name: "key1"
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
foo1:
name: "baz1-0"
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
foo1:
......@@ -154,7 +154,7 @@ spec:
Context("Test conflicts in complicated map, list", func() {
It("Should catch conflict in key-value in map element", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -170,7 +170,7 @@ spec:
hostPort: 2022
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -183,7 +183,7 @@ spec:
hostPort: 2020
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......
......@@ -28,7 +28,7 @@ var _ = Describe("Merging fields of type list-of-map with openapi", func() {
Context("where one of the items has been deleted resulting in the containers being empty", func() {
It("should set the containers field to null", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -38,7 +38,7 @@ spec:
image: image
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -46,7 +46,7 @@ spec:
containers:
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -58,7 +58,7 @@ spec:
image: image2
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -71,7 +71,7 @@ spec:
Context("where one of the items has been deleted", func() {
It("should be deleted from the result", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -83,7 +83,7 @@ spec:
image: image-delete
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -93,7 +93,7 @@ spec:
image: image-keep
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -105,7 +105,7 @@ spec:
image: image-delete
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -121,7 +121,7 @@ spec:
Context("where one of the items is only in the remote", func() {
It("should leave the item", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -131,7 +131,7 @@ spec:
image: image2
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -141,7 +141,7 @@ spec:
image: image2
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -151,7 +151,7 @@ spec:
image: image
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -169,7 +169,7 @@ spec:
Context("where one of the items differs from the remote value and is missing from the recorded", func() {
It("should update the item", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -177,7 +177,7 @@ spec:
containers:
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -187,7 +187,7 @@ spec:
image: image:2
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -197,7 +197,7 @@ spec:
image: image:1
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -213,7 +213,7 @@ spec:
Context("where one of the items differs from the remote value but matches the recorded", func() {
It("should update the item", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -223,7 +223,7 @@ spec:
image: image:2
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -233,7 +233,7 @@ spec:
image: image:2
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -243,7 +243,7 @@ spec:
image: image:1
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -259,7 +259,7 @@ spec:
Context("where one of the items is missing from the remote but matches the recorded", func() {
It("should add the item", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -269,7 +269,7 @@ spec:
image: image:2
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -279,7 +279,7 @@ spec:
image: image:2
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -287,7 +287,7 @@ spec:
containers:
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -303,7 +303,7 @@ spec:
Context("where one of the items is missing from the remote and missing from the recorded ", func() {
It("should add the item", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -312,7 +312,7 @@ spec:
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -322,7 +322,7 @@ spec:
image: image:2
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -330,7 +330,7 @@ spec:
containers:
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -346,7 +346,7 @@ spec:
Context("where the order of the resolved, local and remote lists differs", func() {
It("should keep the order specified in local and append items appears only in remote", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -363,7 +363,7 @@ spec:
timeoutSeconds: 4
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -383,7 +383,7 @@ spec:
initialDelaySeconds: 18
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -403,7 +403,7 @@ spec:
imagePullPolicy: Always
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -441,7 +441,7 @@ var _ = Describe("Merging fields of type list-of-map with openapi containing a m
Context("where one of the items has been deleted", func() {
It("should delete the item", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -457,7 +457,7 @@ spec:
hostPort: 2022
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -470,7 +470,7 @@ spec:
hostPort: 2020
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -487,7 +487,7 @@ spec:
hostIP: "127.0.0.1"
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -506,7 +506,7 @@ spec:
Context("where one of the items has been updated", func() {
It("should merge updates to the item", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -522,7 +522,7 @@ spec:
hostPort: 2021
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -538,7 +538,7 @@ spec:
hostPort: 2022
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -555,7 +555,7 @@ spec:
hostIP: "127.0.0.1"
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -578,7 +578,7 @@ spec:
Context("where one of the items has been added", func() {
It("should add the item", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -591,7 +591,7 @@ spec:
hostPort: 2020
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -607,7 +607,7 @@ spec:
hostPort: 2022
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -621,7 +621,7 @@ spec:
hostIP: "127.0.0.1"
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......
......@@ -26,7 +26,7 @@ var _ = Describe("Merging fields of type map with openapi for some fields", func
Context("where a field has been deleted", func() {
It("should delete the field", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
replicas: 3
......@@ -35,14 +35,14 @@ spec:
image: "1"
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
replicas: 3
foo2: null
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
replicas: 3
......@@ -57,7 +57,7 @@ spec:
image: "3"
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
replicas: 3
......@@ -72,7 +72,7 @@ spec:
Context("where a field is has been added", func() {
It("should add the field", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
foo1:
......@@ -80,7 +80,7 @@ spec:
image: "1"
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
replicas: 3
......@@ -92,12 +92,12 @@ spec:
image: "2"
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
replicas: 3
......@@ -115,7 +115,7 @@ spec:
Context("where a field is has been updated", func() {
It("should update the field", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
foo1:
......@@ -123,7 +123,7 @@ spec:
image: "1-1"
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
replicas: 3
......@@ -135,7 +135,7 @@ spec:
image: "2-1"
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
replicas: 2
......@@ -147,7 +147,7 @@ spec:
image: "2-0"
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
replicas: 3
......
......@@ -26,7 +26,7 @@ var _ = Describe("Merging fields of type list-of-primitive with openapi", func()
Context("where one of the items has been deleted", func() {
It("should delete the deleted item", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
finalizers:
......@@ -35,7 +35,7 @@ metadata:
- "c"
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
finalizers:
......@@ -43,7 +43,7 @@ metadata:
- "c"
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
finalizers:
......@@ -52,7 +52,7 @@ metadata:
- "c"
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
finalizers:
......@@ -66,7 +66,7 @@ metadata:
Context("where one of the items is only on the remote", func() {
It("should move the remote-only item to the end but keep it", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
finalizers:
......@@ -74,7 +74,7 @@ metadata:
- "b"
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
finalizers:
......@@ -82,7 +82,7 @@ metadata:
- "b"
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
finalizers:
......@@ -91,7 +91,7 @@ metadata:
- "a"
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
finalizers:
......@@ -106,7 +106,7 @@ metadata:
Context("where one of the items is repeated", func() {
It("should de-duplicate the repeated items", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
finalizers:
......@@ -114,7 +114,7 @@ metadata:
- "b"
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
finalizers:
......@@ -123,7 +123,7 @@ metadata:
- "a"
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
finalizers:
......@@ -131,7 +131,7 @@ metadata:
- "b"
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
finalizers:
......@@ -145,7 +145,7 @@ metadata:
Context("where some items are deleted and others are on remote only", func() {
It("should retain the correct items in the correct order", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
finalizers:
......@@ -154,7 +154,7 @@ metadata:
- "c"
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
finalizers:
......@@ -163,7 +163,7 @@ metadata:
- "a"
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
finalizers:
......@@ -174,7 +174,7 @@ metadata:
- "e"
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
finalizers:
......
......@@ -26,7 +26,7 @@ var _ = Describe("Merging fields of type map with openapi", func() {
Context("where a field has been deleted", func() {
It("should delete the field when it is the only field in the map", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
# delete - recorded/remote match
......@@ -35,14 +35,14 @@ spec:
progressDeadlineSeconds: 1
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
# delete - not present in recorded
replicas: null
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
replicas: 3
......@@ -51,7 +51,7 @@ spec:
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
`)
......@@ -60,7 +60,7 @@ spec:
It("should delete the field when there are other fields in the map", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
# delete - recorded/remote match
......@@ -69,7 +69,7 @@ spec:
progressDeadlineSeconds: 1
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
# delete - not present in recorded
......@@ -78,7 +78,7 @@ spec:
revisionHistoryLimit: 1
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
replicas: 3
......@@ -88,7 +88,7 @@ spec:
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
revisionHistoryLimit: 1
......@@ -100,14 +100,14 @@ spec:
Context("where a field is has been added", func() {
It("should add the field", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
paused: true
progressDeadlineSeconds: 1
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
# Add this - it is missing from recorded and remote
......@@ -118,12 +118,12 @@ spec:
progressDeadlineSeconds: 2
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
replicas: 3
......@@ -137,14 +137,14 @@ spec:
Context("where a field is has been updated", func() {
It("should add the field", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
paused: true
progressDeadlineSeconds: 1
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
# Missing from recorded
......@@ -155,7 +155,7 @@ spec:
progressDeadlineSeconds: 2
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
replicas: 2
......@@ -163,7 +163,7 @@ spec:
progressDeadlineSeconds: 3
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
replicas: 3
......@@ -175,26 +175,26 @@ spec:
It("should update the field", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
replicas: 2
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
replicas: 3
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
replicas: 2
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
replicas: 3
......@@ -208,7 +208,7 @@ var _ = Describe("Merging fields of type map without openapi", func() {
Context("where a field has been deleted", func() {
It("should delete the field when it is the only field in the map", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Foo
spec:
# delete - recorded/remote match
......@@ -217,14 +217,14 @@ spec:
progressDeadlineSeconds: 1
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Foo
spec:
# delete - not present in recorded
replicas: null
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Foo
spec:
replicas: 3
......@@ -233,7 +233,7 @@ spec:
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Foo
spec:
`)
......@@ -242,7 +242,7 @@ spec:
It("should delete the field when there are other fields in the map", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Foo
spec:
# delete - recorded/remote match
......@@ -251,7 +251,7 @@ spec:
progressDeadlineSeconds: 1
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Foo
spec:
# delete - not present in recorded
......@@ -260,7 +260,7 @@ spec:
revisionHistoryLimit: 1
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Foo
spec:
replicas: 3
......@@ -270,7 +270,7 @@ spec:
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Foo
spec:
revisionHistoryLimit: 1
......@@ -282,14 +282,14 @@ spec:
Context("where a field is has been added", func() {
It("should add the field", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Foo
spec:
paused: true
progressDeadlineSeconds: 1
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Foo
spec:
# Add this - it is missing from recorded and remote
......@@ -300,12 +300,12 @@ spec:
progressDeadlineSeconds: 2
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Foo
spec:
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Foo
spec:
replicas: 3
......@@ -319,14 +319,14 @@ spec:
Context("where a field is has been updated", func() {
It("should add the field", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Foo
spec:
paused: true
progressDeadlineSeconds: 1
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Foo
spec:
# Matches recorded
......@@ -337,7 +337,7 @@ spec:
progressDeadlineSeconds: 2
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Foo
spec:
replicas: 2
......@@ -345,7 +345,7 @@ spec:
progressDeadlineSeconds: 3
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Foo
spec:
replicas: 3
......@@ -357,26 +357,26 @@ spec:
It("should update the field", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Foo
spec:
replicas: 2
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Foo
spec:
replicas: 3
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Foo
spec:
replicas: 2
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Foo
spec:
replicas: 3
......@@ -390,7 +390,7 @@ var _ = Describe("Merging fields of type map with openapi", func() {
Context("where a field has been deleted", func() {
It("should delete the field when it is the only field in the map", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
# delete - recorded/remote match
......@@ -399,14 +399,14 @@ spec:
bar: 1
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
# delete - not present in recorded
baz: null
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
baz: 3
......@@ -415,7 +415,7 @@ spec:
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
`)
......@@ -424,7 +424,7 @@ spec:
It("should delete the field when there are other fields in the map", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
# delete - recorded/remote match
......@@ -433,7 +433,7 @@ spec:
bar: 1
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
# delete - not present in recorded
......@@ -442,7 +442,7 @@ spec:
biz: 1
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
bar: 3
......@@ -452,7 +452,7 @@ spec:
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
biz: 1
......@@ -464,14 +464,14 @@ spec:
Context("where a field is has been added", func() {
It("should add the field", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
foo: true
biz: 1
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
# Add this - it is missing from recorded and remote
......@@ -482,12 +482,12 @@ spec:
biz: 2
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
baz: 3
......@@ -501,14 +501,14 @@ spec:
Context("where a field is has been updated", func() {
It("should add the field", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
foo: true
baz: 1
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
# Missing from recorded
......@@ -519,7 +519,7 @@ spec:
baz: 2
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
bar: 2
......@@ -527,7 +527,7 @@ spec:
baz: 3
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
bar: 3
......
......@@ -26,7 +26,7 @@ var _ = Describe("Replacing fields of type list without openapi", func() {
Context("where a field is has been updated", func() {
It("should replace the field", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Foo
spec:
bar:
......@@ -36,7 +36,7 @@ spec:
value: 2
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Foo
spec:
bar:
......@@ -46,7 +46,7 @@ spec:
value: 2
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Foo
spec:
bar:
......@@ -58,7 +58,7 @@ spec:
value: 4
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Foo
spec:
bar:
......
......@@ -33,7 +33,7 @@ var _ = Describe("Replacing fields of type map with openapi for some fields", fu
Context("where a field is has been updated", func() {
It("should update the field", func() {
recorded := create(`
apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: ReplicaSet
spec:
template:
......@@ -42,7 +42,7 @@ spec:
image: image1
`)
local := create(`
apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: ReplicaSet
spec:
template:
......@@ -51,7 +51,7 @@ spec:
image: image1
`)
remote := create(`
apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: ReplicaSet
spec:
template:
......@@ -64,7 +64,7 @@ spec:
image: image3
`)
expected := create(`
apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: ReplicaSet
spec:
template:
......
......@@ -26,7 +26,7 @@ var _ = Describe("Replacing fields of type list with openapi", func() {
Context("where the field has been deleted", func() {
It("should delete the field if present in recorded and missing from local.", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -38,7 +38,7 @@ spec:
- b
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -47,7 +47,7 @@ spec:
- name: container
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -62,7 +62,7 @@ spec:
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -75,7 +75,7 @@ spec:
It("should delete the field if missing in recorded and set to null in local.", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -84,7 +84,7 @@ spec:
- name: container
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -95,7 +95,7 @@ spec:
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -109,7 +109,7 @@ spec:
- "y"
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -124,14 +124,14 @@ spec:
Context("where the field is has been added", func() {
It("should add the field when missing from recorded", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
spec:
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -144,14 +144,14 @@ spec:
- c
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
spec:
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -168,7 +168,7 @@ spec:
It("should add the field when even when present in recorded", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -181,7 +181,7 @@ spec:
- c
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -194,14 +194,14 @@ spec:
- c
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
spec:
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -218,12 +218,12 @@ spec:
It("should add the field when the parent field is missing as well", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -236,12 +236,12 @@ spec:
- c
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -260,7 +260,7 @@ spec:
Context("where a field is has been updated", func() {
It("should replace the field", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -273,7 +273,7 @@ spec:
- c
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -286,7 +286,7 @@ spec:
- f
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
spec:
......@@ -302,7 +302,7 @@ spec:
- "y"
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -319,7 +319,7 @@ spec:
It("should replace the field even if recorded matches", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -332,7 +332,7 @@ spec:
- f
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -345,7 +345,7 @@ spec:
- f
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
spec:
......@@ -361,7 +361,7 @@ spec:
- "y"
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -378,7 +378,7 @@ spec:
It("should replace the field even if the only change is ordering", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -391,7 +391,7 @@ spec:
- f
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -404,7 +404,7 @@ spec:
- f
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
spec:
......@@ -418,7 +418,7 @@ spec:
- c
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -439,7 +439,7 @@ var _ = Describe("Replacing fields of type list with openapi for the type, but n
Context("where a field is has been updated", func() {
It("should replace the field", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -452,7 +452,7 @@ spec:
- c
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -471,7 +471,7 @@ spec:
- g
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
spec:
......@@ -503,7 +503,7 @@ spec:
- m
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -530,7 +530,7 @@ var _ = Describe("Replacing fields of type list without openapi", func() {
Context("where the field has been deleted", func() {
It("should delete the field.", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Foo
spec:
template:
......@@ -539,14 +539,14 @@ spec:
- b
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Foo
spec:
template:
arguments:
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Foo
spec:
template:
......@@ -570,7 +570,7 @@ spec:
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Foo
spec:
template:
......@@ -587,7 +587,7 @@ spec:
Context("where the field is has been added", func() {
It("should add the field", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Foo
spec:
template:
......@@ -598,7 +598,7 @@ spec:
- "y"
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Foo
spec:
template:
......@@ -616,12 +616,12 @@ spec:
- w
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Foo
spec:
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Foo
spec:
template:
......@@ -643,7 +643,7 @@ spec:
Context("where a field is has been updated", func() {
It("should replace field", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Foo
spec:
template:
......@@ -657,7 +657,7 @@ spec:
- u
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Foo
spec:
template:
......@@ -677,7 +677,7 @@ spec:
- u
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Foo
spec:
spec:
......@@ -698,7 +698,7 @@ spec:
- "t"
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Foo
spec:
template:
......
......@@ -26,20 +26,20 @@ var _ = Describe("Merging fields with the retainkeys strategy", func() {
Context("where some fields are only defined remotely", func() {
It("should drop those fields ", func() {
recorded := create(`
apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
strategy:
`)
local := create(`
apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
strategy:
type: Recreate
`)
remote := create(`
apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
strategy:
......@@ -49,7 +49,7 @@ spec:
maxSurge: 1
`)
expected := create(`
apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
strategy:
......@@ -62,13 +62,13 @@ spec:
Context("where some fields are defined both locally and remotely", func() {
It("should merge those fields", func() {
recorded := create(`
apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
strategy:
`)
local := create(`
apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
strategy:
......@@ -77,7 +77,7 @@ spec:
maxUnavailable: 2
`)
remote := create(`
apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
strategy:
......@@ -86,7 +86,7 @@ spec:
maxSurge: 1
`)
expected := create(`
apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
strategy:
......@@ -102,14 +102,14 @@ spec:
Context("where the elements are in a list and some fields are only defined remotely", func() {
It("should drop those fields ", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
spec:
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -119,7 +119,7 @@ spec:
emptyDir:
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -130,7 +130,7 @@ spec:
path: /tmp/cache-volume
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -146,14 +146,14 @@ spec:
Context("where the elements are in a list", func() {
It("the fields defined both locally and remotely should be merged", func() {
recorded := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
spec:
`)
local := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -165,7 +165,7 @@ spec:
emptyDir:
`)
remote := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......@@ -177,7 +177,7 @@ spec:
type: Directory
`)
expected := create(`
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
spec:
template:
......
......@@ -32,8 +32,8 @@ import (
"github.com/googleapis/gnostic/OpenAPIv2"
"github.com/spf13/cobra"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
kubeerr "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
......@@ -876,7 +876,7 @@ const (
func readDeploymentFromFile(t *testing.T, file string) []byte {
raw := readBytesFromFile(t, file)
obj := &extensionsv1beta1.Deployment{}
obj := &appsv1.Deployment{}
if err := runtime.DecodeInto(codec, raw, obj); err != nil {
t.Fatal(err)
}
......@@ -948,7 +948,7 @@ func TestApplyNULLPreservation(t *testing.T) {
cmd.Run(cmd, []string{})
expected := "deployment.extensions/" + deploymentName + "\n"
expected := "deployment.apps/" + deploymentName + "\n"
if buf.String() != expected {
t.Fatalf("unexpected output: %s\nexpected: %s", buf.String(), expected)
}
......
......@@ -401,7 +401,7 @@ func (o *DrainOptions) daemonsetFilter(pod corev1.Pod) (bool, *warning, *fatal)
return true, nil, nil
}
if _, err := o.client.ExtensionsV1beta1().DaemonSets(pod.Namespace).Get(controllerRef.Name, metav1.GetOptions{}); err != nil {
if _, err := o.client.AppsV1().DaemonSets(pod.Namespace).Get(controllerRef.Name, metav1.GetOptions{}); err != nil {
// remove orphaned pods with a warning if --force is used
if apierrors.IsNotFound(err) && o.Force {
return true, &warning{err.Error()}, nil
......
......@@ -33,9 +33,9 @@ import (
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
appsv1 "k8s.io/api/apps/v1"
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
policyv1beta1 "k8s.io/api/policy/v1beta1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
......@@ -294,13 +294,13 @@ func TestDrain(t *testing.T) {
},
}
ds := extensionsv1beta1.DaemonSet{
ds := appsv1.DaemonSet{
ObjectMeta: metav1.ObjectMeta{
Name: "ds",
Namespace: "default",
CreationTimestamp: metav1.Time{Time: time.Now()},
},
Spec: extensionsv1beta1.DaemonSetSpec{
Spec: appsv1.DaemonSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: labels},
},
}
......@@ -313,7 +313,7 @@ func TestDrain(t *testing.T) {
Labels: labels,
OwnerReferences: []metav1.OwnerReference{
{
APIVersion: "extensions/v1beta1",
APIVersion: "apps/v1",
Kind: "DaemonSet",
Name: "ds",
BlockOwnerDeletion: boolptr(true),
......@@ -334,7 +334,7 @@ func TestDrain(t *testing.T) {
Labels: labels,
OwnerReferences: []metav1.OwnerReference{
{
APIVersion: "extensions/v1beta1",
APIVersion: "apps/v1",
Kind: "DaemonSet",
Name: "ds",
BlockOwnerDeletion: boolptr(true),
......@@ -358,7 +358,7 @@ func TestDrain(t *testing.T) {
Labels: labels,
OwnerReferences: []metav1.OwnerReference{
{
APIVersion: "extensions/v1beta1",
APIVersion: "apps/v1",
Kind: "DaemonSet",
Name: "ds",
BlockOwnerDeletion: boolptr(true),
......@@ -457,14 +457,14 @@ func TestDrain(t *testing.T) {
},
}
rs := extensionsv1beta1.ReplicaSet{
rs := appsv1.ReplicaSet{
ObjectMeta: metav1.ObjectMeta{
Name: "rs",
Namespace: "default",
CreationTimestamp: metav1.Time{Time: time.Now()},
Labels: labels,
},
Spec: extensionsv1beta1.ReplicaSetSpec{
Spec: appsv1.ReplicaSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: labels},
},
}
......@@ -546,7 +546,7 @@ func TestDrain(t *testing.T) {
expected *corev1.Node
pods []corev1.Pod
rcs []corev1.ReplicationController
replicaSets []extensionsv1beta1.ReplicaSet
replicaSets []appsv1.ReplicaSet
args []string
expectWarning string
expectFatal bool
......@@ -648,7 +648,7 @@ func TestDrain(t *testing.T) {
node: node,
expected: cordonedNode,
pods: []corev1.Pod{rsPod},
replicaSets: []extensionsv1beta1.ReplicaSet{rs},
replicaSets: []appsv1.ReplicaSet{rs},
args: []string{"node"},
expectFatal: false,
expectDelete: true,
......@@ -776,7 +776,7 @@ func TestDrain(t *testing.T) {
case m.isFor("GET", "/namespaces/default/daemonsets/ds"):
return &http.Response{StatusCode: 200, Header: cmdtesting.DefaultHeader(), Body: cmdtesting.ObjBody(codec, &ds)}, nil
case m.isFor("GET", "/namespaces/default/daemonsets/missing-ds"):
return &http.Response{StatusCode: 404, Header: cmdtesting.DefaultHeader(), Body: cmdtesting.ObjBody(codec, &extensionsv1beta1.DaemonSet{})}, nil
return &http.Response{StatusCode: 404, Header: cmdtesting.DefaultHeader(), Body: cmdtesting.ObjBody(codec, &appsv1.DaemonSet{})}, nil
case m.isFor("GET", "/namespaces/default/jobs/job"):
return &http.Response{StatusCode: 200, Header: cmdtesting.DefaultHeader(), Body: cmdtesting.ObjBody(codec, &job)}, nil
case m.isFor("GET", "/namespaces/default/replicasets/rs"):
......@@ -1027,6 +1027,6 @@ func (m *MyReq) isFor(method string, path string) bool {
return method == req.Method && (req.URL.Path == path ||
req.URL.Path == strings.Join([]string{"/api/v1", path}, "") ||
req.URL.Path == strings.Join([]string{"/apis/extensions/v1beta1", path}, "") ||
req.URL.Path == strings.Join([]string{"/apis/apps/v1", path}, "") ||
req.URL.Path == strings.Join([]string{"/apis/batch/v1", path}, ""))
}
......@@ -421,6 +421,7 @@ func (f *TestFactory) KubernetesClientSet() (*kubernetes.Clientset, error) {
clientset.StorageV1beta1().RESTClient().(*restclient.RESTClient).Client = fakeClient.Client
clientset.AppsV1beta1().RESTClient().(*restclient.RESTClient).Client = fakeClient.Client
clientset.AppsV1beta2().RESTClient().(*restclient.RESTClient).Client = fakeClient.Client
clientset.AppsV1().RESTClient().(*restclient.RESTClient).Client = fakeClient.Client
clientset.PolicyV1beta1().RESTClient().(*restclient.RESTClient).Client = fakeClient.Client
clientset.DiscoveryClient.RESTClient().(*restclient.RESTClient).Client = fakeClient.Client
......
......@@ -24,6 +24,7 @@ import (
utilerrors "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/kube-openapi/pkg/util/proto/validation"
// This dependency is needed to register API types.
"k8s.io/kube-openapi/pkg/util/proto/testing"
"k8s.io/kubernetes/pkg/kubectl/cmd/util/openapi"
......@@ -44,7 +45,7 @@ var _ = Describe("resource validation using OpenAPI Schema", func() {
It("finds Deployment in Schema and validates it", func() {
err := validator.ValidateBytes([]byte(`
apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
......@@ -52,6 +53,9 @@ metadata:
name: name
spec:
replicas: 1
selector:
matchLabels:
app: redis
template:
metadata:
labels:
......
......@@ -383,6 +383,92 @@ func TestMapBasedSelectorForObject(t *testing.T) {
},
// Node can not be exposed -- error
{
object: &appsv1.Deployment{
Spec: appsv1.DeploymentSpec{
Selector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"foo": "bar",
},
},
},
},
expectSelector: "foo=bar",
},
{
object: &appsv1.Deployment{
Spec: appsv1.DeploymentSpec{
Selector: &metav1.LabelSelector{
MatchExpressions: []metav1.LabelSelectorRequirement{
{
Key: "foo",
},
},
},
},
},
expectErr: true,
},
{
object: &appsv1.ReplicaSet{
Spec: appsv1.ReplicaSetSpec{
Selector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"foo": "bar",
},
},
},
},
expectSelector: "foo=bar",
},
{
object: &appsv1.ReplicaSet{
Spec: appsv1.ReplicaSetSpec{
Selector: &metav1.LabelSelector{
MatchExpressions: []metav1.LabelSelectorRequirement{
{
Key: "foo",
},
},
},
},
},
expectErr: true,
},
{
object: &appsv1.Deployment{
Spec: appsv1.DeploymentSpec{
Selector: nil,
},
},
expectErr: true,
},
{
object: &appsv1.Deployment{
Spec: appsv1.DeploymentSpec{
Selector: nil,
},
},
expectErr: true,
},
{
object: &appsv1.ReplicaSet{
Spec: appsv1.ReplicaSetSpec{
Selector: nil,
},
},
expectErr: true,
},
{
object: &appsv1.ReplicaSet{
Spec: appsv1.ReplicaSetSpec{
Selector: nil,
},
},
expectErr: true,
},
{
object: &corev1.Node{},
expectErr: true,
},
......
......@@ -21,8 +21,8 @@ import (
"strings"
"testing"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
extensionv1beta1 "k8s.io/api/extensions/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
......@@ -112,7 +112,7 @@ func newGCPermissionsEnforcement() (*gcPermissionsEnforcement, error) {
},
},
{
GroupVersion: extensionv1beta1.SchemeGroupVersion.String(),
GroupVersion: appsv1.SchemeGroupVersion.String(),
APIResources: []metav1.APIResource{
{Name: "daemonsets", Namespaced: true, Kind: "DaemonSet"},
},
......@@ -372,13 +372,13 @@ func TestBlockOwnerDeletionAdmission(t *testing.T) {
Name: "rc2",
}
blockDS1 := metav1.OwnerReference{
APIVersion: "extensions/v1beta1",
APIVersion: "apps/v1",
Kind: "DaemonSet",
Name: "ds1",
BlockOwnerDeletion: getTrueVar(),
}
notBlockDS1 := metav1.OwnerReference{
APIVersion: "extensions/v1beta1",
APIVersion: "apps/v1",
Kind: "DaemonSet",
Name: "ds1",
BlockOwnerDeletion: getFalseVar(),
......
......@@ -34,7 +34,7 @@ func TestGroupVersionUnmarshalJSON(t *testing.T) {
expect GroupVersion
}{
{[]byte(`{"val": "v1"}`), GroupVersion{"", "v1"}},
{[]byte(`{"val": "extensions/v1beta1"}`), GroupVersion{"extensions", "v1beta1"}},
{[]byte(`{"val": "apps/v1"}`), GroupVersion{"apps", "v1"}},
}
for _, c := range cases {
......@@ -63,7 +63,7 @@ func TestGroupVersionMarshalJSON(t *testing.T) {
expect []byte
}{
{GroupVersion{"", "v1"}, []byte(`{"val":"v1"}`)},
{GroupVersion{"extensions", "v1beta1"}, []byte(`{"val":"extensions/v1beta1"}`)},
{GroupVersion{"apps", "v1"}, []byte(`{"val":"apps/v1"}`)},
}
for _, c := range cases {
......
......@@ -66,7 +66,7 @@ func TestParseRuntimeConfig(t *testing.T) {
{
// version enabled by runtimeConfig override.
runtimeConfig: map[string]string{
"extensions/v1beta1": "",
"apps/v1": "",
},
defaultResourceConfig: func() *serverstore.ResourceConfig {
config := newFakeAPIResourceConfigSource()
......
......@@ -183,7 +183,7 @@ run_deployment_tests() {
# Post-Condition: Deployment "nginx" is created.
kube::test::get_object_assert 'deploy test-nginx-extensions' "{{$container_name_field}}" 'nginx'
# and old generator was used, iow. old defaults are applied
output_message=$(kubectl get deployment.extensions/test-nginx-extensions -o jsonpath='{.spec.revisionHistoryLimit}')
output_message=$(kubectl get deployment.apps/test-nginx-extensions -o jsonpath='{.spec.revisionHistoryLimit}')
kube::test::if_has_not_string "${output_message}" '2'
# Ensure we can interact with deployments through extensions and apps endpoints
output_message=$(kubectl get deployment.extensions -o=jsonpath='{.items[0].apiVersion}' 2>&1 "${kube_flags[@]}")
......@@ -275,7 +275,7 @@ run_deployment_tests() {
# Clean up
# Note that we should delete hpa first, otherwise it may fight with the deployment reaper.
kubectl delete hpa nginx-deployment "${kube_flags[@]}"
kubectl delete deployment.extensions nginx-deployment "${kube_flags[@]}"
kubectl delete deployment.apps nginx-deployment "${kube_flags[@]}"
### Rollback a deployment
# Pre-condition: no deployment exists
......@@ -290,10 +290,10 @@ run_deployment_tests() {
kube::test::get_object_assert deployment "{{range.items}}{{$image_field0}}:{{end}}" "${IMAGE_DEPLOYMENT_R1}:"
# Update the deployment (revision 2)
kubectl apply -f hack/testdata/deployment-revision2.yaml "${kube_flags[@]}"
kube::test::get_object_assert deployment.extensions "{{range.items}}{{$image_field0}}:{{end}}" "${IMAGE_DEPLOYMENT_R2}:"
kube::test::get_object_assert deployment.apps "{{range.items}}{{$image_field0}}:{{end}}" "${IMAGE_DEPLOYMENT_R2}:"
# Rollback to revision 1 with dry-run - should be no-op
kubectl rollout undo deployment nginx --dry-run=true "${kube_flags[@]}" | grep "test-cmd"
kube::test::get_object_assert deployment.extensions "{{range.items}}{{$image_field0}}:{{end}}" "${IMAGE_DEPLOYMENT_R2}:"
kube::test::get_object_assert deployment.apps "{{range.items}}{{$image_field0}}:{{end}}" "${IMAGE_DEPLOYMENT_R2}:"
# Rollback to revision 1
kubectl rollout undo deployment nginx --to-revision=1 "${kube_flags[@]}"
sleep 1
......
......@@ -268,10 +268,10 @@ run_recursive_resources_tests() {
kube::test::get_object_assert deployment "{{range.items}}{{$id_field}}:{{end}}" 'nginx:'
kube::test::get_object_assert deployment "{{range.items}}{{$image_field0}}:{{end}}" "${IMAGE_DEPLOYMENT_R1}:"
# Command
output_message=$(kubectl convert --local -f hack/testdata/deployment-revision1.yaml --output-version=apps/v1beta1 -o yaml "${kube_flags[@]}")
output_message=$(kubectl convert --local -f hack/testdata/deployment-revision1.yaml --output-version=apps/v1 -o yaml "${kube_flags[@]}")
# Post-condition: apiVersion is still extensions/v1beta1 in the live deployment, but command output is the new value
kube::test::get_object_assert 'deployment nginx' "{{ .apiVersion }}" 'extensions/v1beta1'
kube::test::if_has_string "${output_message}" "apps/v1beta1"
kube::test::if_has_string "${output_message}" "apps/v1"
# Clean up
kubectl delete deployment nginx "${kube_flags[@]}"
......
......@@ -34,10 +34,10 @@ run_clusterroles_tests() {
kube::test::get_object_assert clusterrole/pod-admin "{{range.rules}}{{range.verbs}}{{.}}:{{end}}{{end}}" '\*:'
kube::test::get_object_assert clusterrole/pod-admin "{{range.rules}}{{range.resources}}{{.}}:{{end}}{{end}}" 'pods:'
kube::test::get_object_assert clusterrole/pod-admin "{{range.rules}}{{range.apiGroups}}{{.}}:{{end}}{{end}}" ':'
kubectl create "${kube_flags[@]}" clusterrole resource-reader --verb=get,list --resource=pods,deployments.extensions
kubectl create "${kube_flags[@]}" clusterrole resource-reader --verb=get,list --resource=pods,deployments.apps
kube::test::get_object_assert clusterrole/resource-reader "{{range.rules}}{{range.verbs}}{{.}}:{{end}}{{end}}" 'get:list:get:list:'
kube::test::get_object_assert clusterrole/resource-reader "{{range.rules}}{{range.resources}}{{.}}:{{end}}{{end}}" 'pods:deployments:'
kube::test::get_object_assert clusterrole/resource-reader "{{range.rules}}{{range.apiGroups}}{{.}}:{{end}}{{end}}" ':extensions:'
kube::test::get_object_assert clusterrole/resource-reader "{{range.rules}}{{range.apiGroups}}{{.}}:{{end}}{{end}}" ':apps:'
kubectl create "${kube_flags[@]}" clusterrole resourcename-reader --verb=get,list --resource=pods --resource-name=foo
kube::test::get_object_assert clusterrole/resourcename-reader "{{range.rules}}{{range.verbs}}{{.}}:{{end}}{{end}}" 'get:list:'
kube::test::get_object_assert clusterrole/resourcename-reader "{{range.rules}}{{range.resources}}{{.}}:{{end}}{{end}}" 'pods:'
......@@ -124,10 +124,10 @@ run_role_tests() {
output_message=$(! kubectl create "${kube_flags[@]}" role invalid-pod-admin --verb=* --resource=invalid-resource 2>&1)
kube::test::if_has_string "${output_message}" "the server doesn't have a resource type \"invalid-resource\""
# Create Role from command (resource + group)
kubectl create "${kube_flags[@]}" role group-reader --verb=get,list --resource=deployments.extensions
kubectl create "${kube_flags[@]}" role group-reader --verb=get,list --resource=deployments.apps
kube::test::get_object_assert role/group-reader "{{range.rules}}{{range.verbs}}{{.}}:{{end}}{{end}}" 'get:list:'
kube::test::get_object_assert role/group-reader "{{range.rules}}{{range.resources}}{{.}}:{{end}}{{end}}" 'deployments:'
kube::test::get_object_assert role/group-reader "{{range.rules}}{{range.apiGroups}}{{.}}:{{end}}{{end}}" 'extensions:'
kube::test::get_object_assert role/group-reader "{{range.rules}}{{range.apiGroups}}{{.}}:{{end}}{{end}}" 'apps:'
output_message=$(! kubectl create "${kube_flags[@]}" role invalid-group --verb=get,list --resource=deployments.invalid-group 2>&1)
kube::test::if_has_string "${output_message}" "the server doesn't have a resource type \"deployments\" in group \"invalid-group\""
# Create Role from command (resource / subresource)
......@@ -136,10 +136,10 @@ run_role_tests() {
kube::test::get_object_assert role/subresource-reader "{{range.rules}}{{range.resources}}{{.}}:{{end}}{{end}}" 'pods/status:'
kube::test::get_object_assert role/subresource-reader "{{range.rules}}{{range.apiGroups}}{{.}}:{{end}}{{end}}" ':'
# Create Role from command (resource + group / subresource)
kubectl create "${kube_flags[@]}" role group-subresource-reader --verb=get,list --resource=replicasets.extensions/scale
kubectl create "${kube_flags[@]}" role group-subresource-reader --verb=get,list --resource=replicasets.apps/scale
kube::test::get_object_assert role/group-subresource-reader "{{range.rules}}{{range.verbs}}{{.}}:{{end}}{{end}}" 'get:list:'
kube::test::get_object_assert role/group-subresource-reader "{{range.rules}}{{range.resources}}{{.}}:{{end}}{{end}}" 'replicasets/scale:'
kube::test::get_object_assert role/group-subresource-reader "{{range.rules}}{{range.apiGroups}}{{.}}:{{end}}{{end}}" 'extensions:'
kube::test::get_object_assert role/group-subresource-reader "{{range.rules}}{{range.apiGroups}}{{.}}:{{end}}{{end}}" 'apps:'
output_message=$(! kubectl create "${kube_flags[@]}" role invalid-group --verb=get,list --resource=rs.invalid-group/scale 2>&1)
kube::test::if_has_string "${output_message}" "the server doesn't have a resource type \"rs\" in group \"invalid-group\""
# Create Role from command (resource + resourcename)
......@@ -149,10 +149,10 @@ run_role_tests() {
kube::test::get_object_assert role/resourcename-reader "{{range.rules}}{{range.apiGroups}}{{.}}:{{end}}{{end}}" ':'
kube::test::get_object_assert role/resourcename-reader "{{range.rules}}{{range.resourceNames}}{{.}}:{{end}}{{end}}" 'foo:'
# Create Role from command (multi-resources)
kubectl create "${kube_flags[@]}" role resource-reader --verb=get,list --resource=pods/status,deployments.extensions
kubectl create "${kube_flags[@]}" role resource-reader --verb=get,list --resource=pods/status,deployments.apps
kube::test::get_object_assert role/resource-reader "{{range.rules}}{{range.verbs}}{{.}}:{{end}}{{end}}" 'get:list:get:list:'
kube::test::get_object_assert role/resource-reader "{{range.rules}}{{range.resources}}{{.}}:{{end}}{{end}}" 'pods/status:deployments:'
kube::test::get_object_assert role/resource-reader "{{range.rules}}{{range.apiGroups}}{{.}}:{{end}}{{end}}" ':extensions:'
kube::test::get_object_assert role/resource-reader "{{range.rules}}{{range.apiGroups}}{{.}}:{{end}}{{end}}" ':apps:'
set +o nounset
set +o errexit
......
......@@ -43,7 +43,7 @@ run_kubectl_run_tests() {
# Command
kubectl run nginx-extensions "--image=$IMAGE_NGINX" "${kube_flags[@]}"
# Post-Condition: Deployment "nginx" is created
kube::test::get_object_assert deployment.extensions "{{range.items}}{{$id_field}}:{{end}}" 'nginx-extensions:'
kube::test::get_object_assert deployment.apps "{{range.items}}{{$id_field}}:{{end}}" 'nginx-extensions:'
# new generator was used
output_message=$(kubectl get deployment.apps/nginx-extensions -o jsonpath='{.spec.revisionHistoryLimit}')
kube::test::if_has_string "${output_message}" '10'
......
......@@ -185,7 +185,7 @@ func verifyRemainingObjects(f *framework.Framework, objects map[string]int) (boo
By(fmt.Sprintf("expected %d pods, got %d pods", num, len(pods.Items)))
}
case "Deployments":
deployments, err := f.ClientSet.ExtensionsV1beta1().Deployments(f.Namespace.Name).List(metav1.ListOptions{})
deployments, err := f.ClientSet.AppsV1().Deployments(f.Namespace.Name).List(metav1.ListOptions{})
if err != nil {
return false, fmt.Errorf("failed to list deployments: %v", err)
}
......@@ -194,7 +194,7 @@ func verifyRemainingObjects(f *framework.Framework, objects map[string]int) (boo
By(fmt.Sprintf("expected %d Deployments, got %d Deployments", num, len(deployments.Items)))
}
case "ReplicaSets":
rs, err := f.ClientSet.ExtensionsV1beta1().ReplicaSets(f.Namespace.Name).List(metav1.ListOptions{})
rs, err := f.ClientSet.AppsV1().ReplicaSets(f.Namespace.Name).List(metav1.ListOptions{})
if err != nil {
return false, fmt.Errorf("failed to list rs: %v", err)
}
......
......@@ -22,9 +22,9 @@ import (
"time"
gcm "google.golang.org/api/monitoring/v3"
appsv1 "k8s.io/api/apps/v1"
as "k8s.io/api/autoscaling/v2beta1"
corev1 "k8s.io/api/core/v1"
extensions "k8s.io/api/extensions/v1beta1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
......@@ -219,7 +219,7 @@ type CustomMetricTestCase struct {
framework *framework.Framework
hpa *as.HorizontalPodAutoscaler
kubeClient clientset.Interface
deployment *extensions.Deployment
deployment *appsv1.Deployment
pod *corev1.Pod
initialReplicas int
scaledReplicas int
......@@ -282,9 +282,9 @@ func (tc *CustomMetricTestCase) Run() {
waitForReplicas(tc.deployment.ObjectMeta.Name, tc.framework.Namespace.ObjectMeta.Name, tc.kubeClient, 15*time.Minute, tc.scaledReplicas)
}
func createDeploymentToScale(f *framework.Framework, cs clientset.Interface, deployment *extensions.Deployment, pod *corev1.Pod) error {
func createDeploymentToScale(f *framework.Framework, cs clientset.Interface, deployment *appsv1.Deployment, pod *corev1.Pod) error {
if deployment != nil {
_, err := cs.Extensions().Deployments(f.Namespace.ObjectMeta.Name).Create(deployment)
_, err := cs.AppsV1().Deployments(f.Namespace.ObjectMeta.Name).Create(deployment)
if err != nil {
return err
}
......@@ -298,9 +298,9 @@ func createDeploymentToScale(f *framework.Framework, cs clientset.Interface, dep
return nil
}
func cleanupDeploymentsToScale(f *framework.Framework, cs clientset.Interface, deployment *extensions.Deployment, pod *corev1.Pod) {
func cleanupDeploymentsToScale(f *framework.Framework, cs clientset.Interface, deployment *appsv1.Deployment, pod *corev1.Pod) {
if deployment != nil {
_ = cs.Extensions().Deployments(f.Namespace.ObjectMeta.Name).Delete(deployment.ObjectMeta.Name, &metav1.DeleteOptions{})
_ = cs.AppsV1().Deployments(f.Namespace.ObjectMeta.Name).Delete(deployment.ObjectMeta.Name, &metav1.DeleteOptions{})
}
if pod != nil {
_ = cs.CoreV1().Pods(f.Namespace.ObjectMeta.Name).Delete(pod.ObjectMeta.Name, &metav1.DeleteOptions{})
......@@ -333,7 +333,7 @@ func podsHPA(namespace string, deploymentName string, metricTargets map[string]i
MaxReplicas: 3,
MinReplicas: &minReplicas,
ScaleTargetRef: as.CrossVersionObjectReference{
APIVersion: "extensions/v1beta1",
APIVersion: "apps/v1",
Kind: "Deployment",
Name: deploymentName,
},
......@@ -365,7 +365,7 @@ func objectHPA(namespace string, metricTarget int64) *as.HorizontalPodAutoscaler
MaxReplicas: 3,
MinReplicas: &minReplicas,
ScaleTargetRef: as.CrossVersionObjectReference{
APIVersion: "extensions/v1beta1",
APIVersion: "apps/v1",
Kind: "Deployment",
Name: dummyDeploymentName,
},
......@@ -424,7 +424,7 @@ func externalHPA(namespace string, metricTargets map[string]externalMetricTarget
MaxReplicas: 3,
MinReplicas: &minReplicas,
ScaleTargetRef: as.CrossVersionObjectReference{
APIVersion: "extensions/v1beta1",
APIVersion: "apps/v1",
Kind: "Deployment",
Name: dummyDeploymentName,
},
......
......@@ -78,7 +78,7 @@ func PrivilegedPSP(name string) *policy.PodSecurityPolicy {
func IsPodSecurityPolicyEnabled(f *Framework) bool {
isPSPEnabledOnce.Do(func() {
psps, err := f.ClientSet.ExtensionsV1beta1().PodSecurityPolicies().List(metav1.ListOptions{})
psps, err := f.ClientSet.PolicyV1beta1().PodSecurityPolicies().List(metav1.ListOptions{})
if err != nil {
Logf("Error listing PodSecurityPolicies; assuming PodSecurityPolicy is disabled: %v", err)
isPSPEnabled = false
......@@ -103,7 +103,7 @@ func CreatePrivilegedPSPBinding(f *Framework, namespace string) {
}
// Create the privileged PSP & role
privilegedPSPOnce.Do(func() {
_, err := f.ClientSet.ExtensionsV1beta1().PodSecurityPolicies().Get(
_, err := f.ClientSet.PolicyV1beta1().PodSecurityPolicies().Get(
podSecurityPolicyPrivileged, metav1.GetOptions{})
if !apierrs.IsNotFound(err) {
// Privileged PSP was already created.
......
......@@ -130,7 +130,7 @@ func NewReplicaSet(name, namespace string, replicas int32, podLabels map[string]
return &apps.ReplicaSet{
TypeMeta: metav1.TypeMeta{
Kind: "ReplicaSet",
APIVersion: "extensions/v1beta1",
APIVersion: "apps/v1",
},
ObjectMeta: metav1.ObjectMeta{
Namespace: namespace,
......
......@@ -3110,10 +3110,16 @@ func getSelectorFromRuntimeObject(obj runtime.Object) (labels.Selector, error) {
return labels.SelectorFromSet(typed.Spec.Selector), nil
case *extensions.ReplicaSet:
return metav1.LabelSelectorAsSelector(typed.Spec.Selector)
case *apps.ReplicaSet:
return metav1.LabelSelectorAsSelector(typed.Spec.Selector)
case *extensions.Deployment:
return metav1.LabelSelectorAsSelector(typed.Spec.Selector)
case *apps.Deployment:
return metav1.LabelSelectorAsSelector(typed.Spec.Selector)
case *extensions.DaemonSet:
return metav1.LabelSelectorAsSelector(typed.Spec.Selector)
case *apps.DaemonSet:
return metav1.LabelSelectorAsSelector(typed.Spec.Selector)
case *batch.Job:
return metav1.LabelSelectorAsSelector(typed.Spec.Selector)
default:
......@@ -3133,13 +3139,25 @@ func getReplicasFromRuntimeObject(obj runtime.Object) (int32, error) {
return *typed.Spec.Replicas, nil
}
return 0, nil
case *apps.ReplicaSet:
if typed.Spec.Replicas != nil {
return *typed.Spec.Replicas, nil
}
return 0, nil
case *extensions.Deployment:
if typed.Spec.Replicas != nil {
return *typed.Spec.Replicas, nil
}
return 0, nil
case *apps.Deployment:
if typed.Spec.Replicas != nil {
return *typed.Spec.Replicas, nil
}
return 0, nil
case *extensions.DaemonSet:
return 0, nil
case *apps.DaemonSet:
return 0, nil
case *batch.Job:
// TODO: currently we use pause pods so that's OK. When we'll want to switch to Pods
// that actually finish we need a better way to do this.
......
......@@ -20,13 +20,14 @@ import (
"fmt"
"strings"
"os/exec"
gcm "google.golang.org/api/monitoring/v3"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
extensions "k8s.io/api/extensions/v1beta1"
rbac "k8s.io/api/rbac/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/test/e2e/framework"
"os/exec"
)
var (
......@@ -71,7 +72,7 @@ type CustomMetricContainerSpec struct {
// SimpleStackdriverExporterDeployment is a Deployment of simple application that exports a metric of
// fixed value to Stackdriver in a loop.
func SimpleStackdriverExporterDeployment(name, namespace string, replicas int32, metricValue int64) *extensions.Deployment {
func SimpleStackdriverExporterDeployment(name, namespace string, replicas int32, metricValue int64) *appsv1.Deployment {
return StackdriverExporterDeployment(name, namespace, replicas,
[]CustomMetricContainerSpec{
{
......@@ -86,18 +87,18 @@ func SimpleStackdriverExporterDeployment(name, namespace string, replicas int32,
// an arbitrary amount of metrics of fixed value to Stackdriver in a loop. Each metric
// is exposed by a different container in one pod.
// The metric names and values are configured via the containers parameter.
func StackdriverExporterDeployment(name, namespace string, replicas int32, containers []CustomMetricContainerSpec) *extensions.Deployment {
func StackdriverExporterDeployment(name, namespace string, replicas int32, containers []CustomMetricContainerSpec) *appsv1.Deployment {
podSpec := corev1.PodSpec{Containers: []corev1.Container{}}
for _, containerSpec := range containers {
podSpec.Containers = append(podSpec.Containers, stackdriverExporterContainerSpec(containerSpec.Name, namespace, containerSpec.MetricName, containerSpec.MetricValue))
}
return &extensions.Deployment{
return &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: namespace,
},
Spec: extensions.DeploymentSpec{
Spec: appsv1.DeploymentSpec{
Selector: &metav1.LabelSelector{
MatchLabels: map[string]string{"name": name},
},
......@@ -175,13 +176,13 @@ func stackdriverExporterContainerSpec(name string, namespace string, metricName
// PrometheusExporterDeployment is a Deployment of simple application with two containers
// one exposing a metric in prometheus format and second a prometheus-to-sd container
// that scrapes the metric and pushes it to stackdriver.
func PrometheusExporterDeployment(name, namespace string, replicas int32, metricValue int64) *extensions.Deployment {
return &extensions.Deployment{
func PrometheusExporterDeployment(name, namespace string, replicas int32, metricValue int64) *appsv1.Deployment {
return &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: namespace,
},
Spec: extensions.DeploymentSpec{
Spec: appsv1.DeploymentSpec{
Selector: &metav1.LabelSelector{
MatchLabels: map[string]string{"name": name},
},
......
......@@ -562,11 +562,11 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
It("should sync endpoints to NEG", func() {
name := "hostname"
scaleAndValidateNEG := func(num int) {
scale, err := f.ClientSet.ExtensionsV1beta1().Deployments(ns).GetScale(name, metav1.GetOptions{})
scale, err := f.ClientSet.AppsV1().Deployments(ns).GetScale(name, metav1.GetOptions{})
Expect(err).NotTo(HaveOccurred())
if scale.Spec.Replicas != int32(num) {
scale.Spec.Replicas = int32(num)
_, err = f.ClientSet.ExtensionsV1beta1().Deployments(ns).UpdateScale(name, scale)
_, err = f.ClientSet.AppsV1().Deployments(ns).UpdateScale(name, scale)
Expect(err).NotTo(HaveOccurred())
}
wait.Poll(10*time.Second, ingress.NEGUpdateTimeout, func() (bool, error) {
......@@ -611,10 +611,10 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
Expect(usingNEG).To(BeTrue())
By(fmt.Sprintf("Scale backend replicas to %d", replicas))
scale, err := f.ClientSet.ExtensionsV1beta1().Deployments(ns).GetScale(name, metav1.GetOptions{})
scale, err := f.ClientSet.AppsV1().Deployments(ns).GetScale(name, metav1.GetOptions{})
Expect(err).NotTo(HaveOccurred())
scale.Spec.Replicas = int32(replicas)
_, err = f.ClientSet.ExtensionsV1beta1().Deployments(ns).UpdateScale(name, scale)
_, err = f.ClientSet.AppsV1().Deployments(ns).UpdateScale(name, scale)
Expect(err).NotTo(HaveOccurred())
wait.Poll(10*time.Second, framework.LoadBalancerPollTimeout, func() (bool, error) {
res, err := jig.GetDistinctResponseFromIngress()
......@@ -657,11 +657,11 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
expectedKeys := []int32{80, 443}
scaleAndValidateExposedNEG := func(num int) {
scale, err := f.ClientSet.ExtensionsV1beta1().Deployments(ns).GetScale(name, metav1.GetOptions{})
scale, err := f.ClientSet.AppsV1().Deployments(ns).GetScale(name, metav1.GetOptions{})
Expect(err).NotTo(HaveOccurred())
if scale.Spec.Replicas != int32(num) {
scale.Spec.Replicas = int32(num)
_, err = f.ClientSet.ExtensionsV1beta1().Deployments(ns).UpdateScale(name, scale)
_, err = f.ClientSet.AppsV1().Deployments(ns).UpdateScale(name, scale)
Expect(err).NotTo(HaveOccurred())
}
wait.Poll(10*time.Second, ingress.NEGUpdateTimeout, func() (bool, error) {
......
......@@ -20,8 +20,8 @@ import (
"fmt"
"time"
appsv1 "k8s.io/api/apps/v1"
"k8s.io/api/core/v1"
extensions "k8s.io/api/extensions/v1beta1"
"k8s.io/api/scheduling/v1beta1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/resource"
......@@ -464,27 +464,27 @@ var _ = SIGDescribe("ResourceQuota", func() {
By("Ensuring resource quota status is calculated")
usedResources := v1.ResourceList{}
usedResources[v1.ResourceQuotas] = resource.MustParse("1")
usedResources[v1.ResourceName("count/replicasets.extensions")] = resource.MustParse("0")
usedResources[v1.ResourceName("count/replicasets.apps")] = resource.MustParse("0")
err = waitForResourceQuota(f.ClientSet, f.Namespace.Name, quotaName, usedResources)
Expect(err).NotTo(HaveOccurred())
By("Creating a ReplicaSet")
replicaSet := newTestReplicaSetForQuota("test-rs", "nginx", 0)
replicaSet, err = f.ClientSet.ExtensionsV1beta1().ReplicaSets(f.Namespace.Name).Create(replicaSet)
replicaSet, err = f.ClientSet.AppsV1().ReplicaSets(f.Namespace.Name).Create(replicaSet)
Expect(err).NotTo(HaveOccurred())
By("Ensuring resource quota status captures replicaset creation")
usedResources = v1.ResourceList{}
usedResources[v1.ResourceName("count/replicasets.extensions")] = resource.MustParse("1")
usedResources[v1.ResourceName("count/replicasets.apps")] = resource.MustParse("1")
err = waitForResourceQuota(f.ClientSet, f.Namespace.Name, quotaName, usedResources)
Expect(err).NotTo(HaveOccurred())
By("Deleting a ReplicaSet")
err = f.ClientSet.ExtensionsV1beta1().ReplicaSets(f.Namespace.Name).Delete(replicaSet.Name, nil)
err = f.ClientSet.AppsV1().ReplicaSets(f.Namespace.Name).Delete(replicaSet.Name, nil)
Expect(err).NotTo(HaveOccurred())
By("Ensuring resource quota status released usage")
usedResources[v1.ResourceName("count/replicasets.extensions")] = resource.MustParse("0")
usedResources[v1.ResourceName("count/replicasets.apps")] = resource.MustParse("0")
err = waitForResourceQuota(f.ClientSet, f.Namespace.Name, quotaName, usedResources)
Expect(err).NotTo(HaveOccurred())
})
......@@ -1351,7 +1351,7 @@ func newTestResourceQuota(name string) *v1.ResourceQuota {
hard[core.V1ResourceByStorageClass(classGold, v1.ResourcePersistentVolumeClaims)] = resource.MustParse("10")
hard[core.V1ResourceByStorageClass(classGold, v1.ResourceRequestsStorage)] = resource.MustParse("10Gi")
// test quota on discovered resource type
hard[v1.ResourceName("count/replicasets.extensions")] = resource.MustParse("5")
hard[v1.ResourceName("count/replicasets.apps")] = resource.MustParse("5")
// test quota on extended resource
hard[v1.ResourceName(v1.DefaultResourceRequestsPrefix+extendedResourceName)] = resource.MustParse("3")
return &v1.ResourceQuota{
......@@ -1453,14 +1453,15 @@ func newTestReplicationControllerForQuota(name, image string, replicas int32) *v
}
// newTestReplicaSetForQuota returns a simple replica set
func newTestReplicaSetForQuota(name, image string, replicas int32) *extensions.ReplicaSet {
func newTestReplicaSetForQuota(name, image string, replicas int32) *appsv1.ReplicaSet {
zero := int64(0)
return &extensions.ReplicaSet{
return &appsv1.ReplicaSet{
ObjectMeta: metav1.ObjectMeta{
Name: name,
},
Spec: extensions.ReplicaSetSpec{
Spec: appsv1.ReplicaSetSpec{
Replicas: &replicas,
Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"name": name}},
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{"name": name},
......
......@@ -1629,7 +1629,7 @@ func createProvisionerDaemonset(config *localTestConfig) {
provisioner := &appsv1.DaemonSet{
TypeMeta: metav1.TypeMeta{
Kind: "DaemonSet",
APIVersion: "extensions/v1beta1",
APIVersion: "apps/v1",
},
ObjectMeta: metav1.ObjectMeta{
Name: daemonSetName,
......
......@@ -109,7 +109,9 @@ func TestNewDeployment(t *testing.T) {
}
}
// Deployments should support roll out, roll back, and roll over
// Deployments should support roll out, roll back, and roll over.
// TODO: drop the rollback portions of this test when extensions/v1beta1 is no longer served
// and rollback endpoint is no longer supported.
func TestDeploymentRollingUpdate(t *testing.T) {
s, closeFn, rm, dc, informers, c := dcSetup(t)
defer closeFn()
......@@ -239,6 +241,7 @@ func TestDeploymentSelectorImmutability(t *testing.T) {
}
// test to ensure extensions/v1beta1 selector is mutable
// TODO: drop the extensions/v1beta1 portion of this test when extensions/v1beta1 is no longer served
newSelectorLabels := map[string]string{"name_extensions_v1beta1": "test_extensions_v1beta1"}
deploymentExtensionsV1beta1, err := c.ExtensionsV1beta1().Deployments(ns.Name).Get(name, metav1.GetOptions{})
if err != nil {
......@@ -553,6 +556,7 @@ func TestDeploymentHashCollision(t *testing.T) {
}
// Deployment supports rollback even when there's old replica set without revision.
// TODO: drop this test when extensions/v1beta1 is no longer served
func TestRollbackDeploymentRSNoRevision(t *testing.T) {
s, closeFn, rm, dc, informers, c := dcSetup(t)
defer closeFn()
......
......@@ -105,7 +105,7 @@ func newReplicaSet(name, ns string, replicas int32) *apps.ReplicaSet {
return &apps.ReplicaSet{
TypeMeta: metav1.TypeMeta{
Kind: "ReplicaSet",
APIVersion: "extensions/v1beta1",
APIVersion: "apps/v1",
},
ObjectMeta: metav1.ObjectMeta{
Namespace: ns,
......
......@@ -24,6 +24,7 @@ import (
"net"
"net/http"
"os"
"path"
"strconv"
"strings"
"sync"
......@@ -47,7 +48,6 @@ import (
clientsetv1 "k8s.io/client-go/kubernetes"
clienttypedv1 "k8s.io/client-go/kubernetes/typed/core/v1"
restclient "k8s.io/client-go/rest"
"k8s.io/kubernetes/pkg/api/testapi"
api "k8s.io/kubernetes/pkg/apis/core"
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/kubernetes/pkg/master"
......@@ -298,7 +298,7 @@ func TestObjectSizeResponses(t *testing.T) {
_, s, closeFn := framework.RunAMaster(nil)
defer closeFn()
client := clientsetv1.NewForConfigOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Groups[api.GroupName].GroupVersion()}})
client := clientsetv1.NewForConfigOrDie(&restclient.Config{Host: s.URL})
const DeploymentMegabyteSize = 100000
const DeploymentTwoMegabyteSize = 1000000
......@@ -403,7 +403,7 @@ var deploymentExtensions string = `
var deploymentApps string = `
{
"apiVersion": "apps/v1beta1",
"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": {
"name": "test-deployment2",
......@@ -411,6 +411,11 @@ var deploymentApps string = `
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"app": "nginx0"
}
},
"template": {
"metadata": {
"labels": {
......@@ -429,19 +434,31 @@ var deploymentApps string = `
`
func autoscalingPath(resource, namespace, name string) string {
return testapi.Autoscaling.ResourcePath(resource, namespace, name)
if namespace != "" {
namespace = path.Join("namespaces", namespace)
}
return path.Join("/apis/autoscaling/v1", namespace, resource, name)
}
func batchPath(resource, namespace, name string) string {
return testapi.Batch.ResourcePath(resource, namespace, name)
if namespace != "" {
namespace = path.Join("namespaces", namespace)
}
return path.Join("/apis/batch/v1", namespace, resource, name)
}
func extensionsPath(resource, namespace, name string) string {
return testapi.Extensions.ResourcePath(resource, namespace, name)
if namespace != "" {
namespace = path.Join("namespaces", namespace)
}
return path.Join("/apis/extensions/v1beta1", namespace, resource, name)
}
func appsPath(resource, namespace, name string) string {
return testapi.Apps.ResourcePath(resource, namespace, name)
if namespace != "" {
namespace = path.Join("namespaces", namespace)
}
return path.Join("/apis/apps/v1", namespace, resource, name)
}
func TestAutoscalingGroupBackwardCompatibility(t *testing.T) {
......@@ -457,7 +474,7 @@ func TestAutoscalingGroupBackwardCompatibility(t *testing.T) {
expectedVersion string
}{
{"POST", autoscalingPath("horizontalpodautoscalers", metav1.NamespaceDefault, ""), hpaV1, integration.Code201, ""},
{"GET", autoscalingPath("horizontalpodautoscalers", metav1.NamespaceDefault, ""), "", integration.Code200, testapi.Autoscaling.GroupVersion().String()},
{"GET", autoscalingPath("horizontalpodautoscalers", metav1.NamespaceDefault, ""), "", integration.Code200, "autoscaling/v1"},
}
for _, r := range requests {
......@@ -503,14 +520,15 @@ func TestAppsGroupBackwardCompatibility(t *testing.T) {
}{
// Post to extensions endpoint and get back from both: extensions and apps
{"POST", extensionsPath("deployments", metav1.NamespaceDefault, ""), deploymentExtensions, integration.Code201, ""},
{"GET", extensionsPath("deployments", metav1.NamespaceDefault, "test-deployment1"), "", integration.Code200, testapi.Extensions.GroupVersion().String()},
{"GET", appsPath("deployments", metav1.NamespaceDefault, "test-deployment1"), "", integration.Code200, testapi.Apps.GroupVersion().String()},
{"DELETE", extensionsPath("deployments", metav1.NamespaceDefault, "test-deployment1"), "", integration.Code200, testapi.Extensions.GroupVersion().String()},
{"GET", extensionsPath("deployments", metav1.NamespaceDefault, "test-deployment1"), "", integration.Code200, "extensions/v1beta1"},
{"GET", appsPath("deployments", metav1.NamespaceDefault, "test-deployment1"), "", integration.Code200, "apps/v1"},
{"DELETE", extensionsPath("deployments", metav1.NamespaceDefault, "test-deployment1"), "", integration.Code200, "extensions/v1beta1"},
// Post to apps endpoint and get back from both: apps and extensions
{"POST", appsPath("deployments", metav1.NamespaceDefault, ""), deploymentApps, integration.Code201, ""},
{"GET", appsPath("deployments", metav1.NamespaceDefault, "test-deployment2"), "", integration.Code200, testapi.Apps.GroupVersion().String()},
{"GET", extensionsPath("deployments", metav1.NamespaceDefault, "test-deployment2"), "", integration.Code200, testapi.Extensions.GroupVersion().String()},
{"DELETE", appsPath("deployments", metav1.NamespaceDefault, "test-deployment2"), "", integration.Code200, testapi.Apps.GroupVersion().String()},
{"GET", appsPath("deployments", metav1.NamespaceDefault, "test-deployment2"), "", integration.Code200, "apps/v1"},
{"GET", extensionsPath("deployments", metav1.NamespaceDefault, "test-deployment2"), "", integration.Code200, "extensions/v1beta1"},
// set propagationPolicy=Orphan to force the object to be returned so we can check the apiVersion (otherwise, we just get a status object back)
{"DELETE", appsPath("deployments", metav1.NamespaceDefault, "test-deployment2") + "?propagationPolicy=Orphan", "", integration.Code200, "apps/v1"},
}
for _, r := range requests {
......@@ -624,7 +642,7 @@ func TestMasterService(t *testing.T) {
_, s, closeFn := framework.RunAMaster(framework.NewIntegrationTestMasterConfig())
defer closeFn()
client := clientset.NewForConfigOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Groups[api.GroupName].GroupVersion()}})
client := clientset.NewForConfigOrDie(&restclient.Config{Host: s.URL})
err := wait.Poll(time.Second, time.Minute, func() (bool, error) {
svcList, err := client.Core().Services(metav1.NamespaceDefault).List(metav1.ListOptions{})
......@@ -666,7 +684,7 @@ func TestServiceAlloc(t *testing.T) {
_, s, closeFn := framework.RunAMaster(cfg)
defer closeFn()
client := clientset.NewForConfigOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Groups[api.GroupName].GroupVersion()}})
client := clientset.NewForConfigOrDie(&restclient.Config{Host: s.URL})
svc := func(i int) *api.Service {
return &api.Service{
......
......@@ -471,6 +471,7 @@ func TestRSSelectorImmutability(t *testing.T) {
createRSsPods(t, clientSet, []*apps.ReplicaSet{rs}, []*v1.Pod{})
// test to ensure extensions/v1beta1 selector is mutable
// TODO: remove the extensions/v1beta1 portion of the test once we stop serving extensions/v1beta1
newSelectorLabels := map[string]string{"changed_name_extensions_v1beta1": "changed_test_extensions_v1beta1"}
rsExt, err := clientSet.ExtensionsV1beta1().ReplicaSets(ns.Name).Get(rs.Name, metav1.GetOptions{})
if err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment