Remove uses of extensions/v1beta1 clients

This commit is contained in:
Jordan Liggitt 2018-12-19 11:18:53 -05:00
parent 842bd1e1ec
commit fd9e9b01b1
44 changed files with 601 additions and 367 deletions

View File

@ -84,7 +84,7 @@ func TestValidateEvent(t *testing.T) {
Namespace: metav1.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
InvolvedObject: core.ObjectReference{ InvolvedObject: core.ObjectReference{
APIVersion: "extensions/v1beta1", APIVersion: "apps/v1",
Kind: "NoKind", Kind: "NoKind",
Namespace: metav1.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
@ -97,7 +97,7 @@ func TestValidateEvent(t *testing.T) {
Namespace: metav1.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
InvolvedObject: core.ObjectReference{ InvolvedObject: core.ObjectReference{
APIVersion: "extensions/v1beta1", APIVersion: "batch/v1",
Kind: "Job", Kind: "Job",
Namespace: "foo", Namespace: "foo",
}, },
@ -110,7 +110,7 @@ func TestValidateEvent(t *testing.T) {
Namespace: metav1.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
InvolvedObject: core.ObjectReference{ InvolvedObject: core.ObjectReference{
APIVersion: "extensions/v1beta1", APIVersion: "batch/v1",
Kind: "Job", Kind: "Job",
Namespace: metav1.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
@ -149,7 +149,7 @@ func TestValidateEvent(t *testing.T) {
Namespace: metav1.NamespaceDefault, Namespace: metav1.NamespaceDefault,
}, },
InvolvedObject: core.ObjectReference{ InvolvedObject: core.ObjectReference{
APIVersion: "extensions", APIVersion: "batch",
Kind: "Job", Kind: "Job",
Namespace: "foo", Namespace: "foo",
}, },
@ -162,8 +162,7 @@ func TestValidateEvent(t *testing.T) {
Namespace: "foo", Namespace: "foo",
}, },
InvolvedObject: core.ObjectReference{ InvolvedObject: core.ObjectReference{
// must register in v1beta1 to be true APIVersion: "batch/v1",
APIVersion: "extensions/v1beta1",
Kind: "Job", Kind: "Job",
Namespace: "foo", Namespace: "foo",
}, },

View File

@ -412,7 +412,7 @@ type RealRSControl struct {
var _ RSControlInterface = &RealRSControl{} var _ RSControlInterface = &RealRSControl{}
func (r RealRSControl) PatchReplicaSet(namespace, name string, data []byte) error { 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 return err
} }

View File

@ -234,8 +234,8 @@ func TestSyncNamespaceThatIsTerminatingNonExperimental(t *testing.T) {
testSyncNamespaceThatIsTerminating(t, &metav1.APIVersions{}) testSyncNamespaceThatIsTerminating(t, &metav1.APIVersions{})
} }
func TestSyncNamespaceThatIsTerminatingV1Beta1(t *testing.T) { func TestSyncNamespaceThatIsTerminatingV1(t *testing.T) {
testSyncNamespaceThatIsTerminating(t, &metav1.APIVersions{Versions: []string{"extensions/v1beta1"}}) testSyncNamespaceThatIsTerminating(t, &metav1.APIVersions{Versions: []string{"apps/v1"}})
} }
func TestSyncNamespaceThatIsActive(t *testing.T) { func TestSyncNamespaceThatIsActive(t *testing.T) {
@ -331,7 +331,7 @@ func testResources() []*metav1.APIResourceList {
}, },
}, },
{ {
GroupVersion: "extensions/v1beta1", GroupVersion: "apps/v1",
APIResources: []metav1.APIResource{ APIResources: []metav1.APIResource{
{ {
Name: "deployments", Name: "deployments",

View File

@ -51,8 +51,8 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
_ "k8s.io/kubernetes/pkg/apis/apps/install"
_ "k8s.io/kubernetes/pkg/apis/autoscaling/install" _ "k8s.io/kubernetes/pkg/apis/autoscaling/install"
_ "k8s.io/kubernetes/pkg/apis/extensions/install"
) )
var statusOk = []autoscalingv2.HorizontalPodAutoscalerCondition{ var statusOk = []autoscalingv2.HorizontalPodAutoscalerCondition{
@ -862,7 +862,7 @@ func TestScaleUpDeployment(t *testing.T) {
useMetricsAPI: true, useMetricsAPI: true,
resource: &fakeResource{ resource: &fakeResource{
name: "test-dep", name: "test-dep",
apiVersion: "extensions/v1beta1", apiVersion: "apps/v1",
kind: "Deployment", kind: "Deployment",
}, },
} }
@ -882,7 +882,7 @@ func TestScaleUpReplicaSet(t *testing.T) {
useMetricsAPI: true, useMetricsAPI: true,
resource: &fakeResource{ resource: &fakeResource{
name: "test-replicaset", name: "test-replicaset",
apiVersion: "extensions/v1beta1", apiVersion: "apps/v1",
kind: "ReplicaSet", kind: "ReplicaSet",
}, },
} }
@ -1033,7 +1033,7 @@ func TestScaleUpCMObject(t *testing.T) {
Type: autoscalingv2.ObjectMetricSourceType, Type: autoscalingv2.ObjectMetricSourceType,
Object: &autoscalingv2.ObjectMetricSource{ Object: &autoscalingv2.ObjectMetricSource{
DescribedObject: autoscalingv2.CrossVersionObjectReference{ DescribedObject: autoscalingv2.CrossVersionObjectReference{
APIVersion: "extensions/v1beta1", APIVersion: "apps/v1",
Kind: "Deployment", Kind: "Deployment",
Name: "some-deployment", Name: "some-deployment",
}, },
@ -1183,7 +1183,7 @@ func TestScaleDownCMObject(t *testing.T) {
Type: autoscalingv2.ObjectMetricSourceType, Type: autoscalingv2.ObjectMetricSourceType,
Object: &autoscalingv2.ObjectMetricSource{ Object: &autoscalingv2.ObjectMetricSource{
DescribedObject: autoscalingv2.CrossVersionObjectReference{ DescribedObject: autoscalingv2.CrossVersionObjectReference{
APIVersion: "extensions/v1beta1", APIVersion: "apps/v1",
Kind: "Deployment", Kind: "Deployment",
Name: "some-deployment", Name: "some-deployment",
}, },
@ -1392,7 +1392,7 @@ func TestToleranceCMObject(t *testing.T) {
Type: autoscalingv2.ObjectMetricSourceType, Type: autoscalingv2.ObjectMetricSourceType,
Object: &autoscalingv2.ObjectMetricSource{ Object: &autoscalingv2.ObjectMetricSource{
DescribedObject: autoscalingv2.CrossVersionObjectReference{ DescribedObject: autoscalingv2.CrossVersionObjectReference{
APIVersion: "extensions/v1beta1", APIVersion: "apps/v1",
Kind: "Deployment", Kind: "Deployment",
Name: "some-deployment", Name: "some-deployment",
}, },
@ -1860,7 +1860,7 @@ func TestConditionFailedGetMetrics(t *testing.T) {
Type: autoscalingv2.ObjectMetricSourceType, Type: autoscalingv2.ObjectMetricSourceType,
Object: &autoscalingv2.ObjectMetricSource{ Object: &autoscalingv2.ObjectMetricSource{
DescribedObject: autoscalingv2.CrossVersionObjectReference{ DescribedObject: autoscalingv2.CrossVersionObjectReference{
APIVersion: "extensions/v1beta1", APIVersion: "apps/v1",
Kind: "Deployment", Kind: "Deployment",
Name: "some-deployment", Name: "some-deployment",
}, },

View File

@ -50,9 +50,9 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
_ "k8s.io/kubernetes/pkg/apis/apps/install"
_ "k8s.io/kubernetes/pkg/apis/autoscaling/install" _ "k8s.io/kubernetes/pkg/apis/autoscaling/install"
_ "k8s.io/kubernetes/pkg/apis/core/install" _ "k8s.io/kubernetes/pkg/apis/core/install"
_ "k8s.io/kubernetes/pkg/apis/extensions/install"
) )
func (w fakeResponseWrapper) DoRaw() ([]byte, error) { func (w fakeResponseWrapper) DoRaw() ([]byte, error) {
@ -588,7 +588,7 @@ func TestLegacyScaleUpDeployment(t *testing.T) {
useMetricsAPI: true, useMetricsAPI: true,
resource: &fakeResource{ resource: &fakeResource{
name: "test-dep", name: "test-dep",
apiVersion: "extensions/v1beta1", apiVersion: "apps/v1",
kind: "Deployment", kind: "Deployment",
}, },
} }
@ -608,7 +608,7 @@ func TestLegacyScaleUpReplicaSet(t *testing.T) {
useMetricsAPI: true, useMetricsAPI: true,
resource: &fakeResource{ resource: &fakeResource{
name: "test-replicaset", name: "test-replicaset",
apiVersion: "extensions/v1beta1", apiVersion: "apps/v1",
kind: "ReplicaSet", kind: "ReplicaSet",
}, },
} }

View File

@ -31,7 +31,7 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
core "k8s.io/client-go/testing" core "k8s.io/client-go/testing"
"k8s.io/kubernetes/pkg/api/legacyscheme" "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" cmapi "k8s.io/metrics/pkg/apis/custom_metrics/v1beta2"
emapi "k8s.io/metrics/pkg/apis/external_metrics/v1beta1" emapi "k8s.io/metrics/pkg/apis/external_metrics/v1beta1"
metricsapi "k8s.io/metrics/pkg/apis/metrics/v1beta1" metricsapi "k8s.io/metrics/pkg/apis/metrics/v1beta1"
@ -305,7 +305,7 @@ func TestRESTClientSingleObject(t *testing.T) {
targetTimestamp: 1, targetTimestamp: 1,
reportedMetricPoints: []metricPoint{{10, 1}}, reportedMetricPoints: []metricPoint{{10, 1}},
singleObject: &autoscalingapi.CrossVersionObjectReference{ singleObject: &autoscalingapi.CrossVersionObjectReference{
APIVersion: "extensions/v1beta1", APIVersion: "apps/v1",
Kind: "Deployment", Kind: "Deployment",
Name: "some-dep", Name: "some-dep",
}, },

View File

@ -623,7 +623,7 @@ func TestReplicaCalcScaleUpCMObject(t *testing.T) {
expectedUtilization: 20000, expectedUtilization: 20000,
singleObject: &autoscalingv2.CrossVersionObjectReference{ singleObject: &autoscalingv2.CrossVersionObjectReference{
Kind: "Deployment", Kind: "Deployment",
APIVersion: "extensions/v1beta1", APIVersion: "apps/v1",
Name: "some-deployment", Name: "some-deployment",
}, },
}, },
@ -643,7 +643,7 @@ func TestReplicaCalcScaleUpCMObjectIgnoresUnreadyPods(t *testing.T) {
expectedUtilization: 50000, expectedUtilization: 50000,
singleObject: &autoscalingv2.CrossVersionObjectReference{ singleObject: &autoscalingv2.CrossVersionObjectReference{
Kind: "Deployment", Kind: "Deployment",
APIVersion: "extensions/v1beta1", APIVersion: "apps/v1",
Name: "some-deployment", Name: "some-deployment",
}, },
}, },
@ -758,7 +758,7 @@ func TestReplicaCalcScaleDownCMObject(t *testing.T) {
expectedUtilization: 12000, expectedUtilization: 12000,
singleObject: &autoscalingv2.CrossVersionObjectReference{ singleObject: &autoscalingv2.CrossVersionObjectReference{
Kind: "Deployment", Kind: "Deployment",
APIVersion: "extensions/v1beta1", APIVersion: "apps/v1",
Name: "some-deployment", Name: "some-deployment",
}, },
}, },
@ -916,7 +916,7 @@ func TestReplicaCalcToleranceCMObject(t *testing.T) {
expectedUtilization: 20666, expectedUtilization: 20666,
singleObject: &autoscalingv2.CrossVersionObjectReference{ singleObject: &autoscalingv2.CrossVersionObjectReference{
Kind: "Deployment", Kind: "Deployment",
APIVersion: "extensions/v1beta1", APIVersion: "apps/v1",
Name: "some-deployment", Name: "some-deployment",
}, },
}, },

View File

@ -27,6 +27,7 @@ import (
"time" "time"
apps "k8s.io/api/apps/v1" apps "k8s.io/api/apps/v1"
autoscalingv1 "k8s.io/api/autoscaling/v1"
"k8s.io/api/core/v1" "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels" "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") 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) { func convertSlice(rcList []*v1.ReplicationController) ([]*apps.ReplicaSet, error) {
rsList := make([]*apps.ReplicaSet, 0, len(rcList)) rsList := make([]*apps.ReplicaSet, 0, len(rcList))
for _, rc := range rcList { for _, rc := range rcList {

View File

@ -26,19 +26,19 @@ var _ = Describe("Comparing fields of remote and recorded ", func() {
Context("Test conflict in map 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() { It("If conflicts found, expected return error", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
foo1: "key1" foo1: "key1"
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
foo2: "baz2-1" foo2: "baz2-1"
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
foo1: "baz1-0" foo1: "baz1-0"
@ -53,7 +53,7 @@ spec:
Context("Test conflict in list fields of remote and recorded ", func() { Context("Test conflict in list fields of remote and recorded ", func() {
It("If conflicts found, expected return false", func() { It("If conflicts found, expected return false", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
finalizers: finalizers:
@ -62,7 +62,7 @@ metadata:
- "d" - "d"
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
finalizers: finalizers:
@ -70,7 +70,7 @@ metadata:
- "b" - "b"
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
finalizers: finalizers:
@ -87,7 +87,7 @@ metadata:
Context("Test conflict in Map-List fields of remote and recorded ", func() { Context("Test conflict in Map-List fields of remote and recorded ", func() {
It("should leave the item", func() { It("should leave the item", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -97,7 +97,7 @@ spec:
image: image1 image: image1
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -107,7 +107,7 @@ spec:
image: image2 image: image2
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -125,21 +125,21 @@ spec:
Context("Test conflicts in nested map field", func() { Context("Test conflicts in nested map field", func() {
It("If conflicts found, expected return error", func() { It("If conflicts found, expected return error", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
foo1: foo1:
name: "key1" name: "key1"
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
foo1: foo1:
name: "baz1-0" name: "baz1-0"
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
foo1: foo1:
@ -154,7 +154,7 @@ spec:
Context("Test conflicts in complicated map, list", func() { Context("Test conflicts in complicated map, list", func() {
It("Should catch conflict in key-value in map element", func() { It("Should catch conflict in key-value in map element", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -170,7 +170,7 @@ spec:
hostPort: 2022 hostPort: 2022
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -183,7 +183,7 @@ spec:
hostPort: 2020 hostPort: 2020
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:

View File

@ -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() { 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() { It("should set the containers field to null", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -38,7 +38,7 @@ spec:
image: image image: image
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -46,7 +46,7 @@ spec:
containers: containers:
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -58,7 +58,7 @@ spec:
image: image2 image: image2
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -71,7 +71,7 @@ spec:
Context("where one of the items has been deleted", func() { Context("where one of the items has been deleted", func() {
It("should be deleted from the result", func() { It("should be deleted from the result", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -83,7 +83,7 @@ spec:
image: image-delete image: image-delete
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -93,7 +93,7 @@ spec:
image: image-keep image: image-keep
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -105,7 +105,7 @@ spec:
image: image-delete image: image-delete
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -121,7 +121,7 @@ spec:
Context("where one of the items is only in the remote", func() { Context("where one of the items is only in the remote", func() {
It("should leave the item", func() { It("should leave the item", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -131,7 +131,7 @@ spec:
image: image2 image: image2
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -141,7 +141,7 @@ spec:
image: image2 image: image2
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -151,7 +151,7 @@ spec:
image: image image: image
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -169,7 +169,7 @@ spec:
Context("where one of the items differs from the remote value and is missing from the recorded", func() { Context("where one of the items differs from the remote value and is missing from the recorded", func() {
It("should update the item", func() { It("should update the item", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -177,7 +177,7 @@ spec:
containers: containers:
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -187,7 +187,7 @@ spec:
image: image:2 image: image:2
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -197,7 +197,7 @@ spec:
image: image:1 image: image:1
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -213,7 +213,7 @@ spec:
Context("where one of the items differs from the remote value but matches the recorded", func() { Context("where one of the items differs from the remote value but matches the recorded", func() {
It("should update the item", func() { It("should update the item", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -223,7 +223,7 @@ spec:
image: image:2 image: image:2
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -233,7 +233,7 @@ spec:
image: image:2 image: image:2
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -243,7 +243,7 @@ spec:
image: image:1 image: image:1
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -259,7 +259,7 @@ spec:
Context("where one of the items is missing from the remote but matches the recorded", func() { Context("where one of the items is missing from the remote but matches the recorded", func() {
It("should add the item", func() { It("should add the item", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -269,7 +269,7 @@ spec:
image: image:2 image: image:2
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -279,7 +279,7 @@ spec:
image: image:2 image: image:2
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -287,7 +287,7 @@ spec:
containers: containers:
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -303,7 +303,7 @@ spec:
Context("where one of the items is missing from the remote and missing from the recorded ", func() { Context("where one of the items is missing from the remote and missing from the recorded ", func() {
It("should add the item", func() { It("should add the item", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -312,7 +312,7 @@ spec:
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -322,7 +322,7 @@ spec:
image: image:2 image: image:2
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -330,7 +330,7 @@ spec:
containers: containers:
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -346,7 +346,7 @@ spec:
Context("where the order of the resolved, local and remote lists differs", func() { 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() { It("should keep the order specified in local and append items appears only in remote", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -363,7 +363,7 @@ spec:
timeoutSeconds: 4 timeoutSeconds: 4
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -383,7 +383,7 @@ spec:
initialDelaySeconds: 18 initialDelaySeconds: 18
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -403,7 +403,7 @@ spec:
imagePullPolicy: Always imagePullPolicy: Always
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: 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() { Context("where one of the items has been deleted", func() {
It("should delete the item", func() { It("should delete the item", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -457,7 +457,7 @@ spec:
hostPort: 2022 hostPort: 2022
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -470,7 +470,7 @@ spec:
hostPort: 2020 hostPort: 2020
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -487,7 +487,7 @@ spec:
hostIP: "127.0.0.1" hostIP: "127.0.0.1"
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -506,7 +506,7 @@ spec:
Context("where one of the items has been updated", func() { Context("where one of the items has been updated", func() {
It("should merge updates to the item", func() { It("should merge updates to the item", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -522,7 +522,7 @@ spec:
hostPort: 2021 hostPort: 2021
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -538,7 +538,7 @@ spec:
hostPort: 2022 hostPort: 2022
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -555,7 +555,7 @@ spec:
hostIP: "127.0.0.1" hostIP: "127.0.0.1"
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -578,7 +578,7 @@ spec:
Context("where one of the items has been added", func() { Context("where one of the items has been added", func() {
It("should add the item", func() { It("should add the item", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -591,7 +591,7 @@ spec:
hostPort: 2020 hostPort: 2020
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -607,7 +607,7 @@ spec:
hostPort: 2022 hostPort: 2022
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -621,7 +621,7 @@ spec:
hostIP: "127.0.0.1" hostIP: "127.0.0.1"
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:

View File

@ -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() { Context("where a field has been deleted", func() {
It("should delete the field", func() { It("should delete the field", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
replicas: 3 replicas: 3
@ -35,14 +35,14 @@ spec:
image: "1" image: "1"
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
replicas: 3 replicas: 3
foo2: null foo2: null
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
replicas: 3 replicas: 3
@ -57,7 +57,7 @@ spec:
image: "3" image: "3"
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
replicas: 3 replicas: 3
@ -72,7 +72,7 @@ spec:
Context("where a field is has been added", func() { Context("where a field is has been added", func() {
It("should add the field", func() { It("should add the field", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
foo1: foo1:
@ -80,7 +80,7 @@ spec:
image: "1" image: "1"
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
replicas: 3 replicas: 3
@ -92,12 +92,12 @@ spec:
image: "2" image: "2"
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
replicas: 3 replicas: 3
@ -115,7 +115,7 @@ spec:
Context("where a field is has been updated", func() { Context("where a field is has been updated", func() {
It("should update the field", func() { It("should update the field", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
foo1: foo1:
@ -123,7 +123,7 @@ spec:
image: "1-1" image: "1-1"
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
replicas: 3 replicas: 3
@ -135,7 +135,7 @@ spec:
image: "2-1" image: "2-1"
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
replicas: 2 replicas: 2
@ -147,7 +147,7 @@ spec:
image: "2-0" image: "2-0"
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
replicas: 3 replicas: 3

View File

@ -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() { Context("where one of the items has been deleted", func() {
It("should delete the deleted item", func() { It("should delete the deleted item", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
finalizers: finalizers:
@ -35,7 +35,7 @@ metadata:
- "c" - "c"
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
finalizers: finalizers:
@ -43,7 +43,7 @@ metadata:
- "c" - "c"
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
finalizers: finalizers:
@ -52,7 +52,7 @@ metadata:
- "c" - "c"
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
finalizers: finalizers:
@ -66,7 +66,7 @@ metadata:
Context("where one of the items is only on the remote", func() { 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() { It("should move the remote-only item to the end but keep it", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
finalizers: finalizers:
@ -74,7 +74,7 @@ metadata:
- "b" - "b"
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
finalizers: finalizers:
@ -82,7 +82,7 @@ metadata:
- "b" - "b"
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
finalizers: finalizers:
@ -91,7 +91,7 @@ metadata:
- "a" - "a"
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
finalizers: finalizers:
@ -106,7 +106,7 @@ metadata:
Context("where one of the items is repeated", func() { Context("where one of the items is repeated", func() {
It("should de-duplicate the repeated items", func() { It("should de-duplicate the repeated items", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
finalizers: finalizers:
@ -114,7 +114,7 @@ metadata:
- "b" - "b"
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
finalizers: finalizers:
@ -123,7 +123,7 @@ metadata:
- "a" - "a"
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
finalizers: finalizers:
@ -131,7 +131,7 @@ metadata:
- "b" - "b"
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
finalizers: finalizers:
@ -145,7 +145,7 @@ metadata:
Context("where some items are deleted and others are on remote only", func() { Context("where some items are deleted and others are on remote only", func() {
It("should retain the correct items in the correct order", func() { It("should retain the correct items in the correct order", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
finalizers: finalizers:
@ -154,7 +154,7 @@ metadata:
- "c" - "c"
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
finalizers: finalizers:
@ -163,7 +163,7 @@ metadata:
- "a" - "a"
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
finalizers: finalizers:
@ -174,7 +174,7 @@ metadata:
- "e" - "e"
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
finalizers: finalizers:

View File

@ -26,7 +26,7 @@ var _ = Describe("Merging fields of type map with openapi", func() {
Context("where a field has been deleted", func() { Context("where a field has been deleted", func() {
It("should delete the field when it is the only field in the map", func() { It("should delete the field when it is the only field in the map", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
# delete - recorded/remote match # delete - recorded/remote match
@ -35,14 +35,14 @@ spec:
progressDeadlineSeconds: 1 progressDeadlineSeconds: 1
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
# delete - not present in recorded # delete - not present in recorded
replicas: null replicas: null
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
replicas: 3 replicas: 3
@ -51,7 +51,7 @@ spec:
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
`) `)
@ -60,7 +60,7 @@ spec:
It("should delete the field when there are other fields in the map", func() { It("should delete the field when there are other fields in the map", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
# delete - recorded/remote match # delete - recorded/remote match
@ -69,7 +69,7 @@ spec:
progressDeadlineSeconds: 1 progressDeadlineSeconds: 1
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
# delete - not present in recorded # delete - not present in recorded
@ -78,7 +78,7 @@ spec:
revisionHistoryLimit: 1 revisionHistoryLimit: 1
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
replicas: 3 replicas: 3
@ -88,7 +88,7 @@ spec:
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
revisionHistoryLimit: 1 revisionHistoryLimit: 1
@ -100,14 +100,14 @@ spec:
Context("where a field is has been added", func() { Context("where a field is has been added", func() {
It("should add the field", func() { It("should add the field", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
paused: true paused: true
progressDeadlineSeconds: 1 progressDeadlineSeconds: 1
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
# Add this - it is missing from recorded and remote # Add this - it is missing from recorded and remote
@ -118,12 +118,12 @@ spec:
progressDeadlineSeconds: 2 progressDeadlineSeconds: 2
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
replicas: 3 replicas: 3
@ -137,14 +137,14 @@ spec:
Context("where a field is has been updated", func() { Context("where a field is has been updated", func() {
It("should add the field", func() { It("should add the field", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
paused: true paused: true
progressDeadlineSeconds: 1 progressDeadlineSeconds: 1
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
# Missing from recorded # Missing from recorded
@ -155,7 +155,7 @@ spec:
progressDeadlineSeconds: 2 progressDeadlineSeconds: 2
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
replicas: 2 replicas: 2
@ -163,7 +163,7 @@ spec:
progressDeadlineSeconds: 3 progressDeadlineSeconds: 3
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
replicas: 3 replicas: 3
@ -175,26 +175,26 @@ spec:
It("should update the field", func() { It("should update the field", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
replicas: 2 replicas: 2
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
replicas: 3 replicas: 3
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
replicas: 2 replicas: 2
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
replicas: 3 replicas: 3
@ -208,7 +208,7 @@ var _ = Describe("Merging fields of type map without openapi", func() {
Context("where a field has been deleted", func() { Context("where a field has been deleted", func() {
It("should delete the field when it is the only field in the map", func() { It("should delete the field when it is the only field in the map", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Foo kind: Foo
spec: spec:
# delete - recorded/remote match # delete - recorded/remote match
@ -217,14 +217,14 @@ spec:
progressDeadlineSeconds: 1 progressDeadlineSeconds: 1
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Foo kind: Foo
spec: spec:
# delete - not present in recorded # delete - not present in recorded
replicas: null replicas: null
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Foo kind: Foo
spec: spec:
replicas: 3 replicas: 3
@ -233,7 +233,7 @@ spec:
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Foo kind: Foo
spec: spec:
`) `)
@ -242,7 +242,7 @@ spec:
It("should delete the field when there are other fields in the map", func() { It("should delete the field when there are other fields in the map", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Foo kind: Foo
spec: spec:
# delete - recorded/remote match # delete - recorded/remote match
@ -251,7 +251,7 @@ spec:
progressDeadlineSeconds: 1 progressDeadlineSeconds: 1
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Foo kind: Foo
spec: spec:
# delete - not present in recorded # delete - not present in recorded
@ -260,7 +260,7 @@ spec:
revisionHistoryLimit: 1 revisionHistoryLimit: 1
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Foo kind: Foo
spec: spec:
replicas: 3 replicas: 3
@ -270,7 +270,7 @@ spec:
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Foo kind: Foo
spec: spec:
revisionHistoryLimit: 1 revisionHistoryLimit: 1
@ -282,14 +282,14 @@ spec:
Context("where a field is has been added", func() { Context("where a field is has been added", func() {
It("should add the field", func() { It("should add the field", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Foo kind: Foo
spec: spec:
paused: true paused: true
progressDeadlineSeconds: 1 progressDeadlineSeconds: 1
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Foo kind: Foo
spec: spec:
# Add this - it is missing from recorded and remote # Add this - it is missing from recorded and remote
@ -300,12 +300,12 @@ spec:
progressDeadlineSeconds: 2 progressDeadlineSeconds: 2
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Foo kind: Foo
spec: spec:
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Foo kind: Foo
spec: spec:
replicas: 3 replicas: 3
@ -319,14 +319,14 @@ spec:
Context("where a field is has been updated", func() { Context("where a field is has been updated", func() {
It("should add the field", func() { It("should add the field", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Foo kind: Foo
spec: spec:
paused: true paused: true
progressDeadlineSeconds: 1 progressDeadlineSeconds: 1
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Foo kind: Foo
spec: spec:
# Matches recorded # Matches recorded
@ -337,7 +337,7 @@ spec:
progressDeadlineSeconds: 2 progressDeadlineSeconds: 2
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Foo kind: Foo
spec: spec:
replicas: 2 replicas: 2
@ -345,7 +345,7 @@ spec:
progressDeadlineSeconds: 3 progressDeadlineSeconds: 3
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Foo kind: Foo
spec: spec:
replicas: 3 replicas: 3
@ -357,26 +357,26 @@ spec:
It("should update the field", func() { It("should update the field", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Foo kind: Foo
spec: spec:
replicas: 2 replicas: 2
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Foo kind: Foo
spec: spec:
replicas: 3 replicas: 3
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Foo kind: Foo
spec: spec:
replicas: 2 replicas: 2
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Foo kind: Foo
spec: spec:
replicas: 3 replicas: 3
@ -390,7 +390,7 @@ var _ = Describe("Merging fields of type map with openapi", func() {
Context("where a field has been deleted", func() { Context("where a field has been deleted", func() {
It("should delete the field when it is the only field in the map", func() { It("should delete the field when it is the only field in the map", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
# delete - recorded/remote match # delete - recorded/remote match
@ -399,14 +399,14 @@ spec:
bar: 1 bar: 1
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
# delete - not present in recorded # delete - not present in recorded
baz: null baz: null
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
baz: 3 baz: 3
@ -415,7 +415,7 @@ spec:
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
`) `)
@ -424,7 +424,7 @@ spec:
It("should delete the field when there are other fields in the map", func() { It("should delete the field when there are other fields in the map", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
# delete - recorded/remote match # delete - recorded/remote match
@ -433,7 +433,7 @@ spec:
bar: 1 bar: 1
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
# delete - not present in recorded # delete - not present in recorded
@ -442,7 +442,7 @@ spec:
biz: 1 biz: 1
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
bar: 3 bar: 3
@ -452,7 +452,7 @@ spec:
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
biz: 1 biz: 1
@ -464,14 +464,14 @@ spec:
Context("where a field is has been added", func() { Context("where a field is has been added", func() {
It("should add the field", func() { It("should add the field", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
foo: true foo: true
biz: 1 biz: 1
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
# Add this - it is missing from recorded and remote # Add this - it is missing from recorded and remote
@ -482,12 +482,12 @@ spec:
biz: 2 biz: 2
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
baz: 3 baz: 3
@ -501,14 +501,14 @@ spec:
Context("where a field is has been updated", func() { Context("where a field is has been updated", func() {
It("should add the field", func() { It("should add the field", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
foo: true foo: true
baz: 1 baz: 1
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
# Missing from recorded # Missing from recorded
@ -519,7 +519,7 @@ spec:
baz: 2 baz: 2
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
bar: 2 bar: 2
@ -527,7 +527,7 @@ spec:
baz: 3 baz: 3
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
bar: 3 bar: 3

View File

@ -26,7 +26,7 @@ var _ = Describe("Replacing fields of type list without openapi", func() {
Context("where a field is has been updated", func() { Context("where a field is has been updated", func() {
It("should replace the field", func() { It("should replace the field", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Foo kind: Foo
spec: spec:
bar: bar:
@ -36,7 +36,7 @@ spec:
value: 2 value: 2
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Foo kind: Foo
spec: spec:
bar: bar:
@ -46,7 +46,7 @@ spec:
value: 2 value: 2
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Foo kind: Foo
spec: spec:
bar: bar:
@ -58,7 +58,7 @@ spec:
value: 4 value: 4
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Foo kind: Foo
spec: spec:
bar: bar:

View File

@ -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() { Context("where a field is has been updated", func() {
It("should update the field", func() { It("should update the field", func() {
recorded := create(` recorded := create(`
apiVersion: extensions/v1beta1 apiVersion: apps/v1
kind: ReplicaSet kind: ReplicaSet
spec: spec:
template: template:
@ -42,7 +42,7 @@ spec:
image: image1 image: image1
`) `)
local := create(` local := create(`
apiVersion: extensions/v1beta1 apiVersion: apps/v1
kind: ReplicaSet kind: ReplicaSet
spec: spec:
template: template:
@ -51,7 +51,7 @@ spec:
image: image1 image: image1
`) `)
remote := create(` remote := create(`
apiVersion: extensions/v1beta1 apiVersion: apps/v1
kind: ReplicaSet kind: ReplicaSet
spec: spec:
template: template:
@ -64,7 +64,7 @@ spec:
image: image3 image: image3
`) `)
expected := create(` expected := create(`
apiVersion: extensions/v1beta1 apiVersion: apps/v1
kind: ReplicaSet kind: ReplicaSet
spec: spec:
template: template:

View File

@ -26,7 +26,7 @@ var _ = Describe("Replacing fields of type list with openapi", func() {
Context("where the field has been deleted", func() { Context("where the field has been deleted", func() {
It("should delete the field if present in recorded and missing from local.", func() { It("should delete the field if present in recorded and missing from local.", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -38,7 +38,7 @@ spec:
- b - b
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -47,7 +47,7 @@ spec:
- name: container - name: container
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -62,7 +62,7 @@ spec:
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -75,7 +75,7 @@ spec:
It("should delete the field if missing in recorded and set to null in local.", func() { It("should delete the field if missing in recorded and set to null in local.", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -84,7 +84,7 @@ spec:
- name: container - name: container
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -95,7 +95,7 @@ spec:
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -109,7 +109,7 @@ spec:
- "y" - "y"
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -124,14 +124,14 @@ spec:
Context("where the field is has been added", func() { Context("where the field is has been added", func() {
It("should add the field when missing from recorded", func() { It("should add the field when missing from recorded", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
spec: spec:
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -144,14 +144,14 @@ spec:
- c - c
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
spec: spec:
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -168,7 +168,7 @@ spec:
It("should add the field when even when present in recorded", func() { It("should add the field when even when present in recorded", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -181,7 +181,7 @@ spec:
- c - c
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -194,14 +194,14 @@ spec:
- c - c
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
spec: spec:
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -218,12 +218,12 @@ spec:
It("should add the field when the parent field is missing as well", func() { It("should add the field when the parent field is missing as well", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -236,12 +236,12 @@ spec:
- c - c
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -260,7 +260,7 @@ spec:
Context("where a field is has been updated", func() { Context("where a field is has been updated", func() {
It("should replace the field", func() { It("should replace the field", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -273,7 +273,7 @@ spec:
- c - c
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -286,7 +286,7 @@ spec:
- f - f
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
spec: spec:
@ -302,7 +302,7 @@ spec:
- "y" - "y"
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -319,7 +319,7 @@ spec:
It("should replace the field even if recorded matches", func() { It("should replace the field even if recorded matches", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -332,7 +332,7 @@ spec:
- f - f
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -345,7 +345,7 @@ spec:
- f - f
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
spec: spec:
@ -361,7 +361,7 @@ spec:
- "y" - "y"
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -378,7 +378,7 @@ spec:
It("should replace the field even if the only change is ordering", func() { It("should replace the field even if the only change is ordering", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -391,7 +391,7 @@ spec:
- f - f
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -404,7 +404,7 @@ spec:
- f - f
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
spec: spec:
@ -418,7 +418,7 @@ spec:
- c - c
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: 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() { Context("where a field is has been updated", func() {
It("should replace the field", func() { It("should replace the field", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -452,7 +452,7 @@ spec:
- c - c
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -471,7 +471,7 @@ spec:
- g - g
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
spec: spec:
@ -503,7 +503,7 @@ spec:
- m - m
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -530,7 +530,7 @@ var _ = Describe("Replacing fields of type list without openapi", func() {
Context("where the field has been deleted", func() { Context("where the field has been deleted", func() {
It("should delete the field.", func() { It("should delete the field.", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Foo kind: Foo
spec: spec:
template: template:
@ -539,14 +539,14 @@ spec:
- b - b
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Foo kind: Foo
spec: spec:
template: template:
arguments: arguments:
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Foo kind: Foo
spec: spec:
template: template:
@ -570,7 +570,7 @@ spec:
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Foo kind: Foo
spec: spec:
template: template:
@ -587,7 +587,7 @@ spec:
Context("where the field is has been added", func() { Context("where the field is has been added", func() {
It("should add the field", func() { It("should add the field", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Foo kind: Foo
spec: spec:
template: template:
@ -598,7 +598,7 @@ spec:
- "y" - "y"
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Foo kind: Foo
spec: spec:
template: template:
@ -616,12 +616,12 @@ spec:
- w - w
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Foo kind: Foo
spec: spec:
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Foo kind: Foo
spec: spec:
template: template:
@ -643,7 +643,7 @@ spec:
Context("where a field is has been updated", func() { Context("where a field is has been updated", func() {
It("should replace field", func() { It("should replace field", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Foo kind: Foo
spec: spec:
template: template:
@ -657,7 +657,7 @@ spec:
- u - u
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Foo kind: Foo
spec: spec:
template: template:
@ -677,7 +677,7 @@ spec:
- u - u
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Foo kind: Foo
spec: spec:
spec: spec:
@ -698,7 +698,7 @@ spec:
- "t" - "t"
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Foo kind: Foo
spec: spec:
template: template:

View File

@ -26,20 +26,20 @@ var _ = Describe("Merging fields with the retainkeys strategy", func() {
Context("where some fields are only defined remotely", func() { Context("where some fields are only defined remotely", func() {
It("should drop those fields ", func() { It("should drop those fields ", func() {
recorded := create(` recorded := create(`
apiVersion: extensions/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
strategy: strategy:
`) `)
local := create(` local := create(`
apiVersion: extensions/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
strategy: strategy:
type: Recreate type: Recreate
`) `)
remote := create(` remote := create(`
apiVersion: extensions/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
strategy: strategy:
@ -49,7 +49,7 @@ spec:
maxSurge: 1 maxSurge: 1
`) `)
expected := create(` expected := create(`
apiVersion: extensions/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
strategy: strategy:
@ -62,13 +62,13 @@ spec:
Context("where some fields are defined both locally and remotely", func() { Context("where some fields are defined both locally and remotely", func() {
It("should merge those fields", func() { It("should merge those fields", func() {
recorded := create(` recorded := create(`
apiVersion: extensions/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
strategy: strategy:
`) `)
local := create(` local := create(`
apiVersion: extensions/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
strategy: strategy:
@ -77,7 +77,7 @@ spec:
maxUnavailable: 2 maxUnavailable: 2
`) `)
remote := create(` remote := create(`
apiVersion: extensions/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
strategy: strategy:
@ -86,7 +86,7 @@ spec:
maxSurge: 1 maxSurge: 1
`) `)
expected := create(` expected := create(`
apiVersion: extensions/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
strategy: strategy:
@ -102,14 +102,14 @@ spec:
Context("where the elements are in a list and some fields are only defined remotely", func() { Context("where the elements are in a list and some fields are only defined remotely", func() {
It("should drop those fields ", func() { It("should drop those fields ", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
spec: spec:
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -119,7 +119,7 @@ spec:
emptyDir: emptyDir:
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -130,7 +130,7 @@ spec:
path: /tmp/cache-volume path: /tmp/cache-volume
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -146,14 +146,14 @@ spec:
Context("where the elements are in a list", func() { Context("where the elements are in a list", func() {
It("the fields defined both locally and remotely should be merged", func() { It("the fields defined both locally and remotely should be merged", func() {
recorded := create(` recorded := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
spec: spec:
`) `)
local := create(` local := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -165,7 +165,7 @@ spec:
emptyDir: emptyDir:
`) `)
remote := create(` remote := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:
@ -177,7 +177,7 @@ spec:
type: Directory type: Directory
`) `)
expected := create(` expected := create(`
apiVersion: apps/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
spec: spec:
template: template:

View File

@ -1,11 +1,10 @@
{ {
"swagger": "2.0", "swagger": "2.0",
"info": { "info": {
"title": "Kubernetes", "title": "Kubernetes",
"version": "v1.9.0" "version": "v1.9.0"
},
"paths": {
}, },
"paths": {},
"definitions": { "definitions": {
"io.k8s.api.core.v1.Container": { "io.k8s.api.core.v1.Container": {
"description": "A single application container that you want to run within a pod.", "description": "A single application container that you want to run within a pod.",
@ -63,8 +62,8 @@
} }
} }
}, },
"io.k8s.api.apps.v1beta1.Deployment": { "io.k8s.api.apps.v1.Deployment": {
"description": "DEPRECATED - This group version of Deployment is deprecated by apps/v1beta2/Deployment. See the release notes for more information. Deployment enables declarative updates for Pods and ReplicaSets.", "description": "Deployment enables declarative updates for Pods and ReplicaSets.",
"properties": { "properties": {
"apiVersion": { "apiVersion": {
"description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources",
@ -80,20 +79,21 @@
}, },
"spec": { "spec": {
"description": "Specification of the desired behavior of the Deployment.", "description": "Specification of the desired behavior of the Deployment.",
"$ref": "#/definitions/io.k8s.api.apps.v1beta1.DeploymentSpec" "$ref": "#/definitions/io.k8s.api.apps.v1.DeploymentSpec"
} }
}, },
"x-kubernetes-group-version-kind": [ "x-kubernetes-group-version-kind": [
{ {
"group": "apps", "group": "apps",
"kind": "Deployment", "kind": "Deployment",
"version": "v1beta1" "version": "v1"
} }
] ]
}, },
"io.k8s.api.apps.v1beta1.DeploymentSpec": { "io.k8s.api.apps.v1.DeploymentSpec": {
"description": "DeploymentSpec is the specification of the desired behavior of the Deployment.", "description": "DeploymentSpec is the specification of the desired behavior of the Deployment.",
"required": [ "required": [
"selector",
"template" "template"
], ],
"properties": { "properties": {
@ -107,7 +107,7 @@
"type": "boolean" "type": "boolean"
}, },
"progressDeadlineSeconds": { "progressDeadlineSeconds": {
"description": "The maximum time in seconds for a deployment to make progress before it is considered to be failed. The deployment controller will continue to process failed deployments and a condition with a ProgressDeadlineExceeded reason will be surfaced in the deployment status. Once autoRollback is implemented, the deployment controller will automatically rollback failed deployments. Note that progress will not be estimated during the time a deployment is paused. Defaults to 600s.", "description": "The maximum time in seconds for a deployment to make progress before it is considered to be failed. The deployment controller will continue to process failed deployments and a condition with a ProgressDeadlineExceeded reason will be surfaced in the deployment status. Note that progress will not be estimated during the time a deployment is paused. Defaults to 600s.",
"type": "integer", "type": "integer",
"format": "int32" "format": "int32"
}, },
@ -117,16 +117,56 @@
"format": "int32" "format": "int32"
}, },
"revisionHistoryLimit": { "revisionHistoryLimit": {
"description": "The number of old ReplicaSets to retain to allow rollback. This is a pointer to distinguish between explicit zero and not specified. Defaults to 2.", "description": "The number of old ReplicaSets to retain to allow rollback. This is a pointer to distinguish between explicit zero and not specified. Defaults to 10.",
"type": "integer", "type": "integer",
"format": "int32" "format": "int32"
}, },
"selector": {
"description": "Label selector for pods. Existing ReplicaSets whose pods are selected by this will be the ones affected by this deployment. It must match the pod template's labels.",
"$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector"
},
"strategy": {
"description": "The deployment strategy to use to replace existing pods with new ones.",
"x-kubernetes-patch-strategy": "retainKeys",
"$ref": "#/definitions/io.k8s.api.apps.v1.DeploymentStrategy"
},
"template": { "template": {
"description": "Template describes the pods that will be created.", "description": "Template describes the pods that will be created.",
"$ref": "#/definitions/io.k8s.api.core.v1.PodTemplateSpec" "$ref": "#/definitions/io.k8s.api.core.v1.PodTemplateSpec"
} }
} }
}, },
"io.k8s.api.apps.v1.DeploymentStrategy": {
"description": "DeploymentStrategy describes how to replace existing pods with new ones.",
"properties": {
"rollingUpdate": {
"description": "Rolling update config params. Present only if DeploymentStrategyType = RollingUpdate.",
"$ref": "#/definitions/io.k8s.api.apps.v1.RollingUpdateDeployment"
},
"type": {
"description": "Type of deployment. Can be \"Recreate\" or \"RollingUpdate\". Default is RollingUpdate.",
"type": "string"
}
}
},
"io.k8s.api.apps.v1.RollingUpdateDeployment": {
"description": "Spec to control the desired behavior of rolling update.",
"properties": {
"maxSurge": {
"description": "The maximum number of pods that can be scheduled above the desired number of pods. Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). This can not be 0 if MaxUnavailable is 0. Absolute number is calculated from percentage by rounding up. Defaults to 25%. Example: when this is set to 30%, the new ReplicaSet can be scaled up immediately when the rolling update starts, such that the total number of old and new pods do not exceed 130% of desired pods. Once old pods have been killed, new ReplicaSet can be scaled up further, ensuring that total number of pods running at any time during the update is at most 130% of desired pods.",
"$ref": "#/definitions/io.k8s.apimachinery.pkg.util.intstr.IntOrString"
},
"maxUnavailable": {
"description": "The maximum number of pods that can be unavailable during the update. Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). Absolute number is calculated from percentage by rounding down. This can not be 0 if MaxSurge is 0. Defaults to 25%. Example: when this is set to 30%, the old ReplicaSet can be scaled down to 70% of desired pods immediately when the rolling update starts. Once new pods are ready, old ReplicaSet can be scaled down further, followed by scaling up the new ReplicaSet, ensuring that the total number of pods available at all times during the update is at least 70% of desired pods.",
"$ref": "#/definitions/io.k8s.apimachinery.pkg.util.intstr.IntOrString"
}
}
},
"io.k8s.apimachinery.pkg.util.intstr.IntOrString": {
"description": "IntOrString is a type that can hold an int32 or a string. When used in JSON or YAML marshalling and unmarshalling, it produces or consumes the inner type. This allows you to have, for example, a JSON field that can accept a name or number.",
"type": "string",
"format": "int-or-string"
},
"io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta": { "io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta": {
"description": "ObjectMeta is metadata that all persisted resources must have, which includes all objects users must create.", "description": "ObjectMeta is metadata that all persisted resources must have, which includes all objects users must create.",
"properties": { "properties": {
@ -184,8 +224,8 @@
} }
} }
}, },
"io.k8s.api.extensions.v1beta1.ReplicaSet": { "io.k8s.api.apps.v1.ReplicaSet": {
"description": "DEPRECATED - This group version of ReplicaSet is deprecated by apps/v1beta2/ReplicaSet. See the release notes for more information. ReplicaSet represents the configuration of a ReplicaSet.", "description": "ReplicaSet ensures that a specified number of pod replicas are running at any given time.",
"properties": { "properties": {
"apiVersion": { "apiVersion": {
"description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources",
@ -201,21 +241,22 @@
}, },
"spec": { "spec": {
"description": "Spec defines the specification of the desired behavior of the ReplicaSet. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status", "description": "Spec defines the specification of the desired behavior of the ReplicaSet. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status",
"$ref": "#/definitions/io.k8s.api.extensions.v1beta1.ReplicaSetSpec", "$ref": "#/definitions/io.k8s.api.apps.v1.ReplicaSetSpec"
"x-kubernetes-patch-strategy": "replace"
} }
}, },
"x-kubernetes-group-version-kind": [ "x-kubernetes-group-version-kind": [
{ {
"group": "extensions", "group": "apps",
"kind": "ReplicaSet", "kind": "ReplicaSet",
"version": "v1beta1" "version": "v1"
} }
] ]
}, },
"io.k8s.api.extensions.v1beta1.ReplicaSetSpec": { "io.k8s.api.apps.v1.ReplicaSetSpec": {
"description": "ReplicaSetSpec is the specification of a ReplicaSet.", "description": "ReplicaSetSpec is the specification of a ReplicaSet.",
"required": [
"selector"
],
"properties": { "properties": {
"minReadySeconds": { "minReadySeconds": {
"description": "Minimum number of seconds for which a newly created pod should be ready without any of its container crashing, for it to be considered available. Defaults to 0 (pod will be considered available as soon as it is ready)", "description": "Minimum number of seconds for which a newly created pod should be ready without any of its container crashing, for it to be considered available. Defaults to 0 (pod will be considered available as soon as it is ready)",
@ -227,24 +268,73 @@
"type": "integer", "type": "integer",
"format": "int32" "format": "int32"
}, },
"selector": {
"description": "Selector is a label query over pods that should match the replica count. Label keys and values that must match in order to be controlled by this replica set. It must match the pod template's labels. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors",
"$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector"
},
"template": { "template": {
"description": "Template is the object that describes the pod that will be created if insufficient replicas are detected. More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller#pod-template", "description": "Template is the object that describes the pod that will be created if insufficient replicas are detected. More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller#pod-template",
"$ref": "#/definitions/io.k8s.api.core.v1.PodTemplateSpec" "$ref": "#/definitions/io.k8s.api.core.v1.PodTemplateSpec"
} }
} }
},
"io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector": {
"description": "A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.",
"properties": {
"matchExpressions": {
"description": "matchExpressions is a list of label selector requirements. The requirements are ANDed.",
"type": "array",
"items": {
"$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelectorRequirement"
}
},
"matchLabels": {
"description": "matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is \"key\", the operator is \"In\", and the values array contains only \"value\". The requirements are ANDed.",
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
},
"io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelectorRequirement": {
"description": "A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values.",
"required": [
"key",
"operator"
],
"properties": {
"key": {
"description": "key is the label key that the selector applies to.",
"type": "string",
"x-kubernetes-patch-merge-key": "key",
"x-kubernetes-patch-strategy": "merge"
},
"operator": {
"description": "operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist.",
"type": "string"
},
"values": {
"description": "values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch.",
"type": "array",
"items": {
"type": "string"
}
}
}
} }
}, },
"securityDefinitions": { "securityDefinitions": {
"BearerToken": { "BearerToken": {
"description": "Bearer Token authentication", "description": "Bearer Token authentication",
"type": "apiKey", "type": "apiKey",
"name": "authorization", "name": "authorization",
"in": "header" "in": "header"
} }
}, },
"security": [ "security": [
{ {
"BearerToken": [] "BearerToken": []
} }
] ]
} }

View File

@ -32,8 +32,8 @@ import (
"github.com/googleapis/gnostic/OpenAPIv2" "github.com/googleapis/gnostic/OpenAPIv2"
"github.com/spf13/cobra" "github.com/spf13/cobra"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1"
extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
kubeerr "k8s.io/apimachinery/pkg/api/errors" kubeerr "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
@ -876,7 +876,7 @@ const (
func readDeploymentFromFile(t *testing.T, file string) []byte { func readDeploymentFromFile(t *testing.T, file string) []byte {
raw := readBytesFromFile(t, file) raw := readBytesFromFile(t, file)
obj := &extensionsv1beta1.Deployment{} obj := &appsv1.Deployment{}
if err := runtime.DecodeInto(codec, raw, obj); err != nil { if err := runtime.DecodeInto(codec, raw, obj); err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -948,7 +948,7 @@ func TestApplyNULLPreservation(t *testing.T) {
cmd.Run(cmd, []string{}) cmd.Run(cmd, []string{})
expected := "deployment.extensions/" + deploymentName + "\n" expected := "deployment.apps/" + deploymentName + "\n"
if buf.String() != expected { if buf.String() != expected {
t.Fatalf("unexpected output: %s\nexpected: %s", buf.String(), expected) t.Fatalf("unexpected output: %s\nexpected: %s", buf.String(), expected)
} }

View File

@ -401,7 +401,7 @@ func (o *DrainOptions) daemonsetFilter(pod corev1.Pod) (bool, *warning, *fatal)
return true, nil, nil 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 // remove orphaned pods with a warning if --force is used
if apierrors.IsNotFound(err) && o.Force { if apierrors.IsNotFound(err) && o.Force {
return true, &warning{err.Error()}, nil return true, &warning{err.Error()}, nil

View File

@ -33,9 +33,9 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions" "k8s.io/cli-runtime/pkg/genericclioptions"
appsv1 "k8s.io/api/apps/v1"
batchv1 "k8s.io/api/batch/v1" batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1"
extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
policyv1beta1 "k8s.io/api/policy/v1beta1" policyv1beta1 "k8s.io/api/policy/v1beta1"
apierrors "k8s.io/apimachinery/pkg/api/errors" apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 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{ ObjectMeta: metav1.ObjectMeta{
Name: "ds", Name: "ds",
Namespace: "default", Namespace: "default",
CreationTimestamp: metav1.Time{Time: time.Now()}, CreationTimestamp: metav1.Time{Time: time.Now()},
}, },
Spec: extensionsv1beta1.DaemonSetSpec{ Spec: appsv1.DaemonSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: labels}, Selector: &metav1.LabelSelector{MatchLabels: labels},
}, },
} }
@ -313,7 +313,7 @@ func TestDrain(t *testing.T) {
Labels: labels, Labels: labels,
OwnerReferences: []metav1.OwnerReference{ OwnerReferences: []metav1.OwnerReference{
{ {
APIVersion: "extensions/v1beta1", APIVersion: "apps/v1",
Kind: "DaemonSet", Kind: "DaemonSet",
Name: "ds", Name: "ds",
BlockOwnerDeletion: boolptr(true), BlockOwnerDeletion: boolptr(true),
@ -334,7 +334,7 @@ func TestDrain(t *testing.T) {
Labels: labels, Labels: labels,
OwnerReferences: []metav1.OwnerReference{ OwnerReferences: []metav1.OwnerReference{
{ {
APIVersion: "extensions/v1beta1", APIVersion: "apps/v1",
Kind: "DaemonSet", Kind: "DaemonSet",
Name: "ds", Name: "ds",
BlockOwnerDeletion: boolptr(true), BlockOwnerDeletion: boolptr(true),
@ -358,7 +358,7 @@ func TestDrain(t *testing.T) {
Labels: labels, Labels: labels,
OwnerReferences: []metav1.OwnerReference{ OwnerReferences: []metav1.OwnerReference{
{ {
APIVersion: "extensions/v1beta1", APIVersion: "apps/v1",
Kind: "DaemonSet", Kind: "DaemonSet",
Name: "ds", Name: "ds",
BlockOwnerDeletion: boolptr(true), BlockOwnerDeletion: boolptr(true),
@ -457,14 +457,14 @@ func TestDrain(t *testing.T) {
}, },
} }
rs := extensionsv1beta1.ReplicaSet{ rs := appsv1.ReplicaSet{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "rs", Name: "rs",
Namespace: "default", Namespace: "default",
CreationTimestamp: metav1.Time{Time: time.Now()}, CreationTimestamp: metav1.Time{Time: time.Now()},
Labels: labels, Labels: labels,
}, },
Spec: extensionsv1beta1.ReplicaSetSpec{ Spec: appsv1.ReplicaSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: labels}, Selector: &metav1.LabelSelector{MatchLabels: labels},
}, },
} }
@ -546,7 +546,7 @@ func TestDrain(t *testing.T) {
expected *corev1.Node expected *corev1.Node
pods []corev1.Pod pods []corev1.Pod
rcs []corev1.ReplicationController rcs []corev1.ReplicationController
replicaSets []extensionsv1beta1.ReplicaSet replicaSets []appsv1.ReplicaSet
args []string args []string
expectWarning string expectWarning string
expectFatal bool expectFatal bool
@ -648,7 +648,7 @@ func TestDrain(t *testing.T) {
node: node, node: node,
expected: cordonedNode, expected: cordonedNode,
pods: []corev1.Pod{rsPod}, pods: []corev1.Pod{rsPod},
replicaSets: []extensionsv1beta1.ReplicaSet{rs}, replicaSets: []appsv1.ReplicaSet{rs},
args: []string{"node"}, args: []string{"node"},
expectFatal: false, expectFatal: false,
expectDelete: true, expectDelete: true,
@ -776,7 +776,7 @@ func TestDrain(t *testing.T) {
case m.isFor("GET", "/namespaces/default/daemonsets/ds"): case m.isFor("GET", "/namespaces/default/daemonsets/ds"):
return &http.Response{StatusCode: 200, Header: cmdtesting.DefaultHeader(), Body: cmdtesting.ObjBody(codec, &ds)}, nil return &http.Response{StatusCode: 200, Header: cmdtesting.DefaultHeader(), Body: cmdtesting.ObjBody(codec, &ds)}, nil
case m.isFor("GET", "/namespaces/default/daemonsets/missing-ds"): 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"): case m.isFor("GET", "/namespaces/default/jobs/job"):
return &http.Response{StatusCode: 200, Header: cmdtesting.DefaultHeader(), Body: cmdtesting.ObjBody(codec, &job)}, nil return &http.Response{StatusCode: 200, Header: cmdtesting.DefaultHeader(), Body: cmdtesting.ObjBody(codec, &job)}, nil
case m.isFor("GET", "/namespaces/default/replicasets/rs"): 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 || return method == req.Method && (req.URL.Path == path ||
req.URL.Path == strings.Join([]string{"/api/v1", 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}, "")) req.URL.Path == strings.Join([]string{"/apis/batch/v1", path}, ""))
} }

View File

@ -421,6 +421,7 @@ func (f *TestFactory) KubernetesClientSet() (*kubernetes.Clientset, error) {
clientset.StorageV1beta1().RESTClient().(*restclient.RESTClient).Client = fakeClient.Client clientset.StorageV1beta1().RESTClient().(*restclient.RESTClient).Client = fakeClient.Client
clientset.AppsV1beta1().RESTClient().(*restclient.RESTClient).Client = fakeClient.Client clientset.AppsV1beta1().RESTClient().(*restclient.RESTClient).Client = fakeClient.Client
clientset.AppsV1beta2().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.PolicyV1beta1().RESTClient().(*restclient.RESTClient).Client = fakeClient.Client
clientset.DiscoveryClient.RESTClient().(*restclient.RESTClient).Client = fakeClient.Client clientset.DiscoveryClient.RESTClient().(*restclient.RESTClient).Client = fakeClient.Client

View File

@ -24,6 +24,7 @@ import (
utilerrors "k8s.io/apimachinery/pkg/util/errors" utilerrors "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/kube-openapi/pkg/util/proto/validation" "k8s.io/kube-openapi/pkg/util/proto/validation"
// This dependency is needed to register API types. // This dependency is needed to register API types.
"k8s.io/kube-openapi/pkg/util/proto/testing" "k8s.io/kube-openapi/pkg/util/proto/testing"
"k8s.io/kubernetes/pkg/kubectl/cmd/util/openapi" "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() { It("finds Deployment in Schema and validates it", func() {
err := validator.ValidateBytes([]byte(` err := validator.ValidateBytes([]byte(`
apiVersion: extensions/v1beta1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
labels: labels:
@ -52,6 +53,9 @@ metadata:
name: name name: name
spec: spec:
replicas: 1 replicas: 1
selector:
matchLabels:
app: redis
template: template:
metadata: metadata:
labels: labels:

View File

@ -382,6 +382,92 @@ func TestMapBasedSelectorForObject(t *testing.T) {
expectErr: true, expectErr: true,
}, },
// Node can not be exposed -- error // 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{}, object: &corev1.Node{},
expectErr: true, expectErr: true,

View File

@ -21,8 +21,8 @@ import (
"strings" "strings"
"testing" "testing"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1"
extensionv1beta1 "k8s.io/api/extensions/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "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{ APIResources: []metav1.APIResource{
{Name: "daemonsets", Namespaced: true, Kind: "DaemonSet"}, {Name: "daemonsets", Namespaced: true, Kind: "DaemonSet"},
}, },
@ -372,13 +372,13 @@ func TestBlockOwnerDeletionAdmission(t *testing.T) {
Name: "rc2", Name: "rc2",
} }
blockDS1 := metav1.OwnerReference{ blockDS1 := metav1.OwnerReference{
APIVersion: "extensions/v1beta1", APIVersion: "apps/v1",
Kind: "DaemonSet", Kind: "DaemonSet",
Name: "ds1", Name: "ds1",
BlockOwnerDeletion: getTrueVar(), BlockOwnerDeletion: getTrueVar(),
} }
notBlockDS1 := metav1.OwnerReference{ notBlockDS1 := metav1.OwnerReference{
APIVersion: "extensions/v1beta1", APIVersion: "apps/v1",
Kind: "DaemonSet", Kind: "DaemonSet",
Name: "ds1", Name: "ds1",
BlockOwnerDeletion: getFalseVar(), BlockOwnerDeletion: getFalseVar(),

View File

@ -34,7 +34,7 @@ func TestGroupVersionUnmarshalJSON(t *testing.T) {
expect GroupVersion expect GroupVersion
}{ }{
{[]byte(`{"val": "v1"}`), GroupVersion{"", "v1"}}, {[]byte(`{"val": "v1"}`), GroupVersion{"", "v1"}},
{[]byte(`{"val": "extensions/v1beta1"}`), GroupVersion{"extensions", "v1beta1"}}, {[]byte(`{"val": "apps/v1"}`), GroupVersion{"apps", "v1"}},
} }
for _, c := range cases { for _, c := range cases {
@ -63,7 +63,7 @@ func TestGroupVersionMarshalJSON(t *testing.T) {
expect []byte expect []byte
}{ }{
{GroupVersion{"", "v1"}, []byte(`{"val":"v1"}`)}, {GroupVersion{"", "v1"}, []byte(`{"val":"v1"}`)},
{GroupVersion{"extensions", "v1beta1"}, []byte(`{"val":"extensions/v1beta1"}`)}, {GroupVersion{"apps", "v1"}, []byte(`{"val":"apps/v1"}`)},
} }
for _, c := range cases { for _, c := range cases {

View File

@ -66,7 +66,7 @@ func TestParseRuntimeConfig(t *testing.T) {
{ {
// version enabled by runtimeConfig override. // version enabled by runtimeConfig override.
runtimeConfig: map[string]string{ runtimeConfig: map[string]string{
"extensions/v1beta1": "", "apps/v1": "",
}, },
defaultResourceConfig: func() *serverstore.ResourceConfig { defaultResourceConfig: func() *serverstore.ResourceConfig {
config := newFakeAPIResourceConfigSource() config := newFakeAPIResourceConfigSource()

View File

@ -183,7 +183,7 @@ run_deployment_tests() {
# Post-Condition: Deployment "nginx" is created. # Post-Condition: Deployment "nginx" is created.
kube::test::get_object_assert 'deploy test-nginx-extensions' "{{$container_name_field}}" 'nginx' kube::test::get_object_assert 'deploy test-nginx-extensions' "{{$container_name_field}}" 'nginx'
# and old generator was used, iow. old defaults are applied # 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' kube::test::if_has_not_string "${output_message}" '2'
# Ensure we can interact with deployments through extensions and apps endpoints # 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[@]}") output_message=$(kubectl get deployment.extensions -o=jsonpath='{.items[0].apiVersion}' 2>&1 "${kube_flags[@]}")
@ -275,7 +275,7 @@ run_deployment_tests() {
# Clean up # Clean up
# Note that we should delete hpa first, otherwise it may fight with the deployment reaper. # Note that we should delete hpa first, otherwise it may fight with the deployment reaper.
kubectl delete hpa nginx-deployment "${kube_flags[@]}" 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 ### Rollback a deployment
# Pre-condition: no deployment exists # 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}:" kube::test::get_object_assert deployment "{{range.items}}{{$image_field0}}:{{end}}" "${IMAGE_DEPLOYMENT_R1}:"
# Update the deployment (revision 2) # Update the deployment (revision 2)
kubectl apply -f hack/testdata/deployment-revision2.yaml "${kube_flags[@]}" 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 # Rollback to revision 1 with dry-run - should be no-op
kubectl rollout undo deployment nginx --dry-run=true "${kube_flags[@]}" | grep "test-cmd" 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 # Rollback to revision 1
kubectl rollout undo deployment nginx --to-revision=1 "${kube_flags[@]}" kubectl rollout undo deployment nginx --to-revision=1 "${kube_flags[@]}"
sleep 1 sleep 1

View File

@ -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}}{{$id_field}}:{{end}}" 'nginx:'
kube::test::get_object_assert deployment "{{range.items}}{{$image_field0}}:{{end}}" "${IMAGE_DEPLOYMENT_R1}:" kube::test::get_object_assert deployment "{{range.items}}{{$image_field0}}:{{end}}" "${IMAGE_DEPLOYMENT_R1}:"
# Command # 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 # 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::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 # Clean up
kubectl delete deployment nginx "${kube_flags[@]}" kubectl delete deployment nginx "${kube_flags[@]}"

View File

@ -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.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.resources}}{{.}}:{{end}}{{end}}" 'pods:'
kube::test::get_object_assert clusterrole/pod-admin "{{range.rules}}{{range.apiGroups}}{{.}}:{{end}}{{end}}" ':' 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.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.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 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.verbs}}{{.}}:{{end}}{{end}}" 'get:list:'
kube::test::get_object_assert clusterrole/resourcename-reader "{{range.rules}}{{range.resources}}{{.}}:{{end}}{{end}}" 'pods:' 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) 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\"" kube::test::if_has_string "${output_message}" "the server doesn't have a resource type \"invalid-resource\""
# Create Role from command (resource + group) # 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.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.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) 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\"" 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) # 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.resources}}{{.}}:{{end}}{{end}}" 'pods/status:'
kube::test::get_object_assert role/subresource-reader "{{range.rules}}{{range.apiGroups}}{{.}}:{{end}}{{end}}" ':' kube::test::get_object_assert role/subresource-reader "{{range.rules}}{{range.apiGroups}}{{.}}:{{end}}{{end}}" ':'
# Create Role from command (resource + group / subresource) # 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.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.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) 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\"" 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) # 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.apiGroups}}{{.}}:{{end}}{{end}}" ':'
kube::test::get_object_assert role/resourcename-reader "{{range.rules}}{{range.resourceNames}}{{.}}:{{end}}{{end}}" 'foo:' kube::test::get_object_assert role/resourcename-reader "{{range.rules}}{{range.resourceNames}}{{.}}:{{end}}{{end}}" 'foo:'
# Create Role from command (multi-resources) # 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.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.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 nounset
set +o errexit set +o errexit

View File

@ -43,7 +43,7 @@ run_kubectl_run_tests() {
# Command # Command
kubectl run nginx-extensions "--image=$IMAGE_NGINX" "${kube_flags[@]}" kubectl run nginx-extensions "--image=$IMAGE_NGINX" "${kube_flags[@]}"
# Post-Condition: Deployment "nginx" is created # 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 # new generator was used
output_message=$(kubectl get deployment.apps/nginx-extensions -o jsonpath='{.spec.revisionHistoryLimit}') output_message=$(kubectl get deployment.apps/nginx-extensions -o jsonpath='{.spec.revisionHistoryLimit}')
kube::test::if_has_string "${output_message}" '10' kube::test::if_has_string "${output_message}" '10'

View File

@ -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))) By(fmt.Sprintf("expected %d pods, got %d pods", num, len(pods.Items)))
} }
case "Deployments": 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 { if err != nil {
return false, fmt.Errorf("failed to list deployments: %v", err) 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))) By(fmt.Sprintf("expected %d Deployments, got %d Deployments", num, len(deployments.Items)))
} }
case "ReplicaSets": 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 { if err != nil {
return false, fmt.Errorf("failed to list rs: %v", err) return false, fmt.Errorf("failed to list rs: %v", err)
} }

View File

@ -22,9 +22,9 @@ import (
"time" "time"
gcm "google.golang.org/api/monitoring/v3" gcm "google.golang.org/api/monitoring/v3"
appsv1 "k8s.io/api/apps/v1"
as "k8s.io/api/autoscaling/v2beta1" as "k8s.io/api/autoscaling/v2beta1"
corev1 "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1"
extensions "k8s.io/api/extensions/v1beta1"
"k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
@ -219,7 +219,7 @@ type CustomMetricTestCase struct {
framework *framework.Framework framework *framework.Framework
hpa *as.HorizontalPodAutoscaler hpa *as.HorizontalPodAutoscaler
kubeClient clientset.Interface kubeClient clientset.Interface
deployment *extensions.Deployment deployment *appsv1.Deployment
pod *corev1.Pod pod *corev1.Pod
initialReplicas int initialReplicas int
scaledReplicas 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) 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 { 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 { if err != nil {
return err return err
} }
@ -298,9 +298,9 @@ func createDeploymentToScale(f *framework.Framework, cs clientset.Interface, dep
return nil 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 { 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 { if pod != nil {
_ = cs.CoreV1().Pods(f.Namespace.ObjectMeta.Name).Delete(pod.ObjectMeta.Name, &metav1.DeleteOptions{}) _ = 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, MaxReplicas: 3,
MinReplicas: &minReplicas, MinReplicas: &minReplicas,
ScaleTargetRef: as.CrossVersionObjectReference{ ScaleTargetRef: as.CrossVersionObjectReference{
APIVersion: "extensions/v1beta1", APIVersion: "apps/v1",
Kind: "Deployment", Kind: "Deployment",
Name: deploymentName, Name: deploymentName,
}, },
@ -365,7 +365,7 @@ func objectHPA(namespace string, metricTarget int64) *as.HorizontalPodAutoscaler
MaxReplicas: 3, MaxReplicas: 3,
MinReplicas: &minReplicas, MinReplicas: &minReplicas,
ScaleTargetRef: as.CrossVersionObjectReference{ ScaleTargetRef: as.CrossVersionObjectReference{
APIVersion: "extensions/v1beta1", APIVersion: "apps/v1",
Kind: "Deployment", Kind: "Deployment",
Name: dummyDeploymentName, Name: dummyDeploymentName,
}, },
@ -424,7 +424,7 @@ func externalHPA(namespace string, metricTargets map[string]externalMetricTarget
MaxReplicas: 3, MaxReplicas: 3,
MinReplicas: &minReplicas, MinReplicas: &minReplicas,
ScaleTargetRef: as.CrossVersionObjectReference{ ScaleTargetRef: as.CrossVersionObjectReference{
APIVersion: "extensions/v1beta1", APIVersion: "apps/v1",
Kind: "Deployment", Kind: "Deployment",
Name: dummyDeploymentName, Name: dummyDeploymentName,
}, },

View File

@ -78,7 +78,7 @@ func PrivilegedPSP(name string) *policy.PodSecurityPolicy {
func IsPodSecurityPolicyEnabled(f *Framework) bool { func IsPodSecurityPolicyEnabled(f *Framework) bool {
isPSPEnabledOnce.Do(func() { isPSPEnabledOnce.Do(func() {
psps, err := f.ClientSet.ExtensionsV1beta1().PodSecurityPolicies().List(metav1.ListOptions{}) psps, err := f.ClientSet.PolicyV1beta1().PodSecurityPolicies().List(metav1.ListOptions{})
if err != nil { if err != nil {
Logf("Error listing PodSecurityPolicies; assuming PodSecurityPolicy is disabled: %v", err) Logf("Error listing PodSecurityPolicies; assuming PodSecurityPolicy is disabled: %v", err)
isPSPEnabled = false isPSPEnabled = false
@ -103,7 +103,7 @@ func CreatePrivilegedPSPBinding(f *Framework, namespace string) {
} }
// Create the privileged PSP & role // Create the privileged PSP & role
privilegedPSPOnce.Do(func() { privilegedPSPOnce.Do(func() {
_, err := f.ClientSet.ExtensionsV1beta1().PodSecurityPolicies().Get( _, err := f.ClientSet.PolicyV1beta1().PodSecurityPolicies().Get(
podSecurityPolicyPrivileged, metav1.GetOptions{}) podSecurityPolicyPrivileged, metav1.GetOptions{})
if !apierrs.IsNotFound(err) { if !apierrs.IsNotFound(err) {
// Privileged PSP was already created. // Privileged PSP was already created.

View File

@ -130,7 +130,7 @@ func NewReplicaSet(name, namespace string, replicas int32, podLabels map[string]
return &apps.ReplicaSet{ return &apps.ReplicaSet{
TypeMeta: metav1.TypeMeta{ TypeMeta: metav1.TypeMeta{
Kind: "ReplicaSet", Kind: "ReplicaSet",
APIVersion: "extensions/v1beta1", APIVersion: "apps/v1",
}, },
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Namespace: namespace, Namespace: namespace,

View File

@ -3110,10 +3110,16 @@ func getSelectorFromRuntimeObject(obj runtime.Object) (labels.Selector, error) {
return labels.SelectorFromSet(typed.Spec.Selector), nil return labels.SelectorFromSet(typed.Spec.Selector), nil
case *extensions.ReplicaSet: case *extensions.ReplicaSet:
return metav1.LabelSelectorAsSelector(typed.Spec.Selector) return metav1.LabelSelectorAsSelector(typed.Spec.Selector)
case *apps.ReplicaSet:
return metav1.LabelSelectorAsSelector(typed.Spec.Selector)
case *extensions.Deployment: case *extensions.Deployment:
return metav1.LabelSelectorAsSelector(typed.Spec.Selector) return metav1.LabelSelectorAsSelector(typed.Spec.Selector)
case *apps.Deployment:
return metav1.LabelSelectorAsSelector(typed.Spec.Selector)
case *extensions.DaemonSet: case *extensions.DaemonSet:
return metav1.LabelSelectorAsSelector(typed.Spec.Selector) return metav1.LabelSelectorAsSelector(typed.Spec.Selector)
case *apps.DaemonSet:
return metav1.LabelSelectorAsSelector(typed.Spec.Selector)
case *batch.Job: case *batch.Job:
return metav1.LabelSelectorAsSelector(typed.Spec.Selector) return metav1.LabelSelectorAsSelector(typed.Spec.Selector)
default: default:
@ -3133,13 +3139,25 @@ func getReplicasFromRuntimeObject(obj runtime.Object) (int32, error) {
return *typed.Spec.Replicas, nil return *typed.Spec.Replicas, nil
} }
return 0, nil return 0, nil
case *apps.ReplicaSet:
if typed.Spec.Replicas != nil {
return *typed.Spec.Replicas, nil
}
return 0, nil
case *extensions.Deployment: case *extensions.Deployment:
if typed.Spec.Replicas != nil { if typed.Spec.Replicas != nil {
return *typed.Spec.Replicas, nil return *typed.Spec.Replicas, nil
} }
return 0, nil return 0, nil
case *apps.Deployment:
if typed.Spec.Replicas != nil {
return *typed.Spec.Replicas, nil
}
return 0, nil
case *extensions.DaemonSet: case *extensions.DaemonSet:
return 0, nil return 0, nil
case *apps.DaemonSet:
return 0, nil
case *batch.Job: case *batch.Job:
// TODO: currently we use pause pods so that's OK. When we'll want to switch to Pods // 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. // that actually finish we need a better way to do this.

View File

@ -20,13 +20,14 @@ import (
"fmt" "fmt"
"strings" "strings"
"os/exec"
gcm "google.golang.org/api/monitoring/v3" gcm "google.golang.org/api/monitoring/v3"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1"
extensions "k8s.io/api/extensions/v1beta1"
rbac "k8s.io/api/rbac/v1" rbac "k8s.io/api/rbac/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/test/e2e/framework" "k8s.io/kubernetes/test/e2e/framework"
"os/exec"
) )
var ( var (
@ -71,7 +72,7 @@ type CustomMetricContainerSpec struct {
// SimpleStackdriverExporterDeployment is a Deployment of simple application that exports a metric of // SimpleStackdriverExporterDeployment is a Deployment of simple application that exports a metric of
// fixed value to Stackdriver in a loop. // 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, return StackdriverExporterDeployment(name, namespace, replicas,
[]CustomMetricContainerSpec{ []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 // an arbitrary amount of metrics of fixed value to Stackdriver in a loop. Each metric
// is exposed by a different container in one pod. // is exposed by a different container in one pod.
// The metric names and values are configured via the containers parameter. // 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{}} podSpec := corev1.PodSpec{Containers: []corev1.Container{}}
for _, containerSpec := range containers { for _, containerSpec := range containers {
podSpec.Containers = append(podSpec.Containers, stackdriverExporterContainerSpec(containerSpec.Name, namespace, containerSpec.MetricName, containerSpec.MetricValue)) podSpec.Containers = append(podSpec.Containers, stackdriverExporterContainerSpec(containerSpec.Name, namespace, containerSpec.MetricName, containerSpec.MetricValue))
} }
return &extensions.Deployment{ return &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: name, Name: name,
Namespace: namespace, Namespace: namespace,
}, },
Spec: extensions.DeploymentSpec{ Spec: appsv1.DeploymentSpec{
Selector: &metav1.LabelSelector{ Selector: &metav1.LabelSelector{
MatchLabels: map[string]string{"name": name}, 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 // PrometheusExporterDeployment is a Deployment of simple application with two containers
// one exposing a metric in prometheus format and second a prometheus-to-sd container // one exposing a metric in prometheus format and second a prometheus-to-sd container
// that scrapes the metric and pushes it to stackdriver. // that scrapes the metric and pushes it to stackdriver.
func PrometheusExporterDeployment(name, namespace string, replicas int32, metricValue int64) *extensions.Deployment { func PrometheusExporterDeployment(name, namespace string, replicas int32, metricValue int64) *appsv1.Deployment {
return &extensions.Deployment{ return &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: name, Name: name,
Namespace: namespace, Namespace: namespace,
}, },
Spec: extensions.DeploymentSpec{ Spec: appsv1.DeploymentSpec{
Selector: &metav1.LabelSelector{ Selector: &metav1.LabelSelector{
MatchLabels: map[string]string{"name": name}, MatchLabels: map[string]string{"name": name},
}, },

View File

@ -562,11 +562,11 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
It("should sync endpoints to NEG", func() { It("should sync endpoints to NEG", func() {
name := "hostname" name := "hostname"
scaleAndValidateNEG := func(num int) { 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()) Expect(err).NotTo(HaveOccurred())
if scale.Spec.Replicas != int32(num) { if scale.Spec.Replicas != int32(num) {
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()) Expect(err).NotTo(HaveOccurred())
} }
wait.Poll(10*time.Second, ingress.NEGUpdateTimeout, func() (bool, error) { wait.Poll(10*time.Second, ingress.NEGUpdateTimeout, func() (bool, error) {
@ -611,10 +611,10 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
Expect(usingNEG).To(BeTrue()) Expect(usingNEG).To(BeTrue())
By(fmt.Sprintf("Scale backend replicas to %d", replicas)) 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()) Expect(err).NotTo(HaveOccurred())
scale.Spec.Replicas = int32(replicas) 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()) Expect(err).NotTo(HaveOccurred())
wait.Poll(10*time.Second, framework.LoadBalancerPollTimeout, func() (bool, error) { wait.Poll(10*time.Second, framework.LoadBalancerPollTimeout, func() (bool, error) {
res, err := jig.GetDistinctResponseFromIngress() res, err := jig.GetDistinctResponseFromIngress()
@ -657,11 +657,11 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
expectedKeys := []int32{80, 443} expectedKeys := []int32{80, 443}
scaleAndValidateExposedNEG := func(num int) { 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()) Expect(err).NotTo(HaveOccurred())
if scale.Spec.Replicas != int32(num) { if scale.Spec.Replicas != int32(num) {
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()) Expect(err).NotTo(HaveOccurred())
} }
wait.Poll(10*time.Second, ingress.NEGUpdateTimeout, func() (bool, error) { wait.Poll(10*time.Second, ingress.NEGUpdateTimeout, func() (bool, error) {

View File

@ -20,8 +20,8 @@ import (
"fmt" "fmt"
"time" "time"
appsv1 "k8s.io/api/apps/v1"
"k8s.io/api/core/v1" "k8s.io/api/core/v1"
extensions "k8s.io/api/extensions/v1beta1"
"k8s.io/api/scheduling/v1beta1" "k8s.io/api/scheduling/v1beta1"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/api/resource"
@ -464,27 +464,27 @@ var _ = SIGDescribe("ResourceQuota", func() {
By("Ensuring resource quota status is calculated") By("Ensuring resource quota status is calculated")
usedResources := v1.ResourceList{} usedResources := v1.ResourceList{}
usedResources[v1.ResourceQuotas] = resource.MustParse("1") 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) err = waitForResourceQuota(f.ClientSet, f.Namespace.Name, quotaName, usedResources)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
By("Creating a ReplicaSet") By("Creating a ReplicaSet")
replicaSet := newTestReplicaSetForQuota("test-rs", "nginx", 0) 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()) Expect(err).NotTo(HaveOccurred())
By("Ensuring resource quota status captures replicaset creation") By("Ensuring resource quota status captures replicaset creation")
usedResources = v1.ResourceList{} 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) err = waitForResourceQuota(f.ClientSet, f.Namespace.Name, quotaName, usedResources)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
By("Deleting a ReplicaSet") 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()) Expect(err).NotTo(HaveOccurred())
By("Ensuring resource quota status released usage") 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) err = waitForResourceQuota(f.ClientSet, f.Namespace.Name, quotaName, usedResources)
Expect(err).NotTo(HaveOccurred()) 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.ResourcePersistentVolumeClaims)] = resource.MustParse("10")
hard[core.V1ResourceByStorageClass(classGold, v1.ResourceRequestsStorage)] = resource.MustParse("10Gi") hard[core.V1ResourceByStorageClass(classGold, v1.ResourceRequestsStorage)] = resource.MustParse("10Gi")
// test quota on discovered resource type // 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 // test quota on extended resource
hard[v1.ResourceName(v1.DefaultResourceRequestsPrefix+extendedResourceName)] = resource.MustParse("3") hard[v1.ResourceName(v1.DefaultResourceRequestsPrefix+extendedResourceName)] = resource.MustParse("3")
return &v1.ResourceQuota{ return &v1.ResourceQuota{
@ -1453,14 +1453,15 @@ func newTestReplicationControllerForQuota(name, image string, replicas int32) *v
} }
// newTestReplicaSetForQuota returns a simple replica set // 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) zero := int64(0)
return &extensions.ReplicaSet{ return &appsv1.ReplicaSet{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: name, Name: name,
}, },
Spec: extensions.ReplicaSetSpec{ Spec: appsv1.ReplicaSetSpec{
Replicas: &replicas, Replicas: &replicas,
Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"name": name}},
Template: v1.PodTemplateSpec{ Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{"name": name}, Labels: map[string]string{"name": name},

View File

@ -1629,7 +1629,7 @@ func createProvisionerDaemonset(config *localTestConfig) {
provisioner := &appsv1.DaemonSet{ provisioner := &appsv1.DaemonSet{
TypeMeta: metav1.TypeMeta{ TypeMeta: metav1.TypeMeta{
Kind: "DaemonSet", Kind: "DaemonSet",
APIVersion: "extensions/v1beta1", APIVersion: "apps/v1",
}, },
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: daemonSetName, Name: daemonSetName,

View File

@ -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) { func TestDeploymentRollingUpdate(t *testing.T) {
s, closeFn, rm, dc, informers, c := dcSetup(t) s, closeFn, rm, dc, informers, c := dcSetup(t)
defer closeFn() defer closeFn()
@ -239,6 +241,7 @@ func TestDeploymentSelectorImmutability(t *testing.T) {
} }
// test to ensure extensions/v1beta1 selector is mutable // 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"} newSelectorLabels := map[string]string{"name_extensions_v1beta1": "test_extensions_v1beta1"}
deploymentExtensionsV1beta1, err := c.ExtensionsV1beta1().Deployments(ns.Name).Get(name, metav1.GetOptions{}) deploymentExtensionsV1beta1, err := c.ExtensionsV1beta1().Deployments(ns.Name).Get(name, metav1.GetOptions{})
if err != nil { if err != nil {
@ -553,6 +556,7 @@ func TestDeploymentHashCollision(t *testing.T) {
} }
// Deployment supports rollback even when there's old replica set without revision. // 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) { func TestRollbackDeploymentRSNoRevision(t *testing.T) {
s, closeFn, rm, dc, informers, c := dcSetup(t) s, closeFn, rm, dc, informers, c := dcSetup(t)
defer closeFn() defer closeFn()

View File

@ -105,7 +105,7 @@ func newReplicaSet(name, ns string, replicas int32) *apps.ReplicaSet {
return &apps.ReplicaSet{ return &apps.ReplicaSet{
TypeMeta: metav1.TypeMeta{ TypeMeta: metav1.TypeMeta{
Kind: "ReplicaSet", Kind: "ReplicaSet",
APIVersion: "extensions/v1beta1", APIVersion: "apps/v1",
}, },
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Namespace: ns, Namespace: ns,

View File

@ -24,6 +24,7 @@ import (
"net" "net"
"net/http" "net/http"
"os" "os"
"path"
"strconv" "strconv"
"strings" "strings"
"sync" "sync"
@ -47,7 +48,6 @@ import (
clientsetv1 "k8s.io/client-go/kubernetes" clientsetv1 "k8s.io/client-go/kubernetes"
clienttypedv1 "k8s.io/client-go/kubernetes/typed/core/v1" clienttypedv1 "k8s.io/client-go/kubernetes/typed/core/v1"
restclient "k8s.io/client-go/rest" restclient "k8s.io/client-go/rest"
"k8s.io/kubernetes/pkg/api/testapi"
api "k8s.io/kubernetes/pkg/apis/core" api "k8s.io/kubernetes/pkg/apis/core"
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/kubernetes/pkg/master" "k8s.io/kubernetes/pkg/master"
@ -298,7 +298,7 @@ func TestObjectSizeResponses(t *testing.T) {
_, s, closeFn := framework.RunAMaster(nil) _, s, closeFn := framework.RunAMaster(nil)
defer closeFn() 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 DeploymentMegabyteSize = 100000
const DeploymentTwoMegabyteSize = 1000000 const DeploymentTwoMegabyteSize = 1000000
@ -403,7 +403,7 @@ var deploymentExtensions string = `
var deploymentApps string = ` var deploymentApps string = `
{ {
"apiVersion": "apps/v1beta1", "apiVersion": "apps/v1",
"kind": "Deployment", "kind": "Deployment",
"metadata": { "metadata": {
"name": "test-deployment2", "name": "test-deployment2",
@ -411,6 +411,11 @@ var deploymentApps string = `
}, },
"spec": { "spec": {
"replicas": 1, "replicas": 1,
"selector": {
"matchLabels": {
"app": "nginx0"
}
},
"template": { "template": {
"metadata": { "metadata": {
"labels": { "labels": {
@ -429,19 +434,31 @@ var deploymentApps string = `
` `
func autoscalingPath(resource, namespace, name string) 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 { 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 { 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 { 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) { func TestAutoscalingGroupBackwardCompatibility(t *testing.T) {
@ -457,7 +474,7 @@ func TestAutoscalingGroupBackwardCompatibility(t *testing.T) {
expectedVersion string expectedVersion string
}{ }{
{"POST", autoscalingPath("horizontalpodautoscalers", metav1.NamespaceDefault, ""), hpaV1, integration.Code201, ""}, {"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 { 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 to extensions endpoint and get back from both: extensions and apps
{"POST", extensionsPath("deployments", metav1.NamespaceDefault, ""), deploymentExtensions, integration.Code201, ""}, {"POST", extensionsPath("deployments", metav1.NamespaceDefault, ""), deploymentExtensions, integration.Code201, ""},
{"GET", 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, testapi.Apps.GroupVersion().String()}, {"GET", appsPath("deployments", metav1.NamespaceDefault, "test-deployment1"), "", integration.Code200, "apps/v1"},
{"DELETE", extensionsPath("deployments", metav1.NamespaceDefault, "test-deployment1"), "", integration.Code200, testapi.Extensions.GroupVersion().String()}, {"DELETE", extensionsPath("deployments", metav1.NamespaceDefault, "test-deployment1"), "", integration.Code200, "extensions/v1beta1"},
// Post to apps endpoint and get back from both: apps and extensions // Post to apps endpoint and get back from both: apps and extensions
{"POST", appsPath("deployments", metav1.NamespaceDefault, ""), deploymentApps, integration.Code201, ""}, {"POST", appsPath("deployments", metav1.NamespaceDefault, ""), deploymentApps, integration.Code201, ""},
{"GET", 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, testapi.Extensions.GroupVersion().String()}, {"GET", extensionsPath("deployments", metav1.NamespaceDefault, "test-deployment2"), "", integration.Code200, "extensions/v1beta1"},
{"DELETE", appsPath("deployments", metav1.NamespaceDefault, "test-deployment2"), "", integration.Code200, testapi.Apps.GroupVersion().String()}, // 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 { for _, r := range requests {
@ -624,7 +642,7 @@ func TestMasterService(t *testing.T) {
_, s, closeFn := framework.RunAMaster(framework.NewIntegrationTestMasterConfig()) _, s, closeFn := framework.RunAMaster(framework.NewIntegrationTestMasterConfig())
defer closeFn() 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) { err := wait.Poll(time.Second, time.Minute, func() (bool, error) {
svcList, err := client.Core().Services(metav1.NamespaceDefault).List(metav1.ListOptions{}) svcList, err := client.Core().Services(metav1.NamespaceDefault).List(metav1.ListOptions{})
@ -666,7 +684,7 @@ func TestServiceAlloc(t *testing.T) {
_, s, closeFn := framework.RunAMaster(cfg) _, s, closeFn := framework.RunAMaster(cfg)
defer closeFn() 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 { svc := func(i int) *api.Service {
return &api.Service{ return &api.Service{

View File

@ -471,6 +471,7 @@ func TestRSSelectorImmutability(t *testing.T) {
createRSsPods(t, clientSet, []*apps.ReplicaSet{rs}, []*v1.Pod{}) createRSsPods(t, clientSet, []*apps.ReplicaSet{rs}, []*v1.Pod{})
// test to ensure extensions/v1beta1 selector is mutable // 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"} newSelectorLabels := map[string]string{"changed_name_extensions_v1beta1": "changed_test_extensions_v1beta1"}
rsExt, err := clientSet.ExtensionsV1beta1().ReplicaSets(ns.Name).Get(rs.Name, metav1.GetOptions{}) rsExt, err := clientSet.ExtensionsV1beta1().ReplicaSets(ns.Name).Get(rs.Name, metav1.GetOptions{})
if err != nil { if err != nil {