vendor updates

This commit is contained in:
Serguei Bezverkhi
2018-03-06 17:33:18 -05:00
parent 4b3ebc171b
commit e9033989a0
5854 changed files with 248382 additions and 119809 deletions

View File

@ -9,7 +9,6 @@ reviewers:
- saad-ali
- ncdc
- tallclair
- timothysc
- dims
- errordeveloper
- mml

View File

@ -38,7 +38,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r
if err := announced.NewGroupMetaFactory(
&announced.GroupMetaFactoryArgs{
GroupName: apps.GroupName,
VersionPreferenceOrder: []string{v1beta1.SchemeGroupVersion.Version, v1beta2.SchemeGroupVersion.Version, v1.SchemeGroupVersion.Version},
VersionPreferenceOrder: []string{v1.SchemeGroupVersion.Version, v1beta2.SchemeGroupVersion.Version, v1beta1.SchemeGroupVersion.Version},
AddInternalObjectsToScheme: apps.AddToScheme,
},
announced.VersionToSchemeFunc{

View File

@ -33,7 +33,6 @@ go_test(
"conversion_test.go",
"defaults_test.go",
],
importpath = "k8s.io/kubernetes/pkg/apis/apps/v1_test",
deps = [
":go_default_library",
"//pkg/api/legacyscheme:go_default_library",
@ -42,6 +41,7 @@ go_test(
"//pkg/apis/core:go_default_library",
"//pkg/apis/core/install:go_default_library",
"//pkg/apis/extensions:go_default_library",
"//pkg/util/pointer:go_default_library",
"//vendor/k8s.io/api/apps/v1:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/equality:go_default_library",

View File

@ -28,10 +28,11 @@ import (
"k8s.io/kubernetes/pkg/apis/apps"
api "k8s.io/kubernetes/pkg/apis/core"
"k8s.io/kubernetes/pkg/apis/extensions"
utilpointer "k8s.io/kubernetes/pkg/util/pointer"
)
func TestV12StatefulSetSpecConversion(t *testing.T) {
replicas := newInt32(2)
replicas := utilpointer.Int32Ptr(2)
selector := &metav1.LabelSelector{MatchLabels: map[string]string{"foo": "bar"}}
appsv1Template := v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{Name: "foo"},
@ -177,7 +178,7 @@ func TestV1StatefulSetStatusConversion(t *testing.T) {
}
func TestV1StatefulSetUpdateStrategyConversion(t *testing.T) {
partition := newInt32(2)
partition := utilpointer.Int32Ptr(2)
appsv1rollingUpdate := new(appsv1.RollingUpdateStatefulSetStrategy)
appsv1rollingUpdate.Partition = partition
appsrollingUpdate := new(apps.RollingUpdateStatefulSetStrategy)
@ -258,7 +259,7 @@ func TestV1RollingUpdateDaemonSetConversion(t *testing.T) {
}
func TestV1DeploymentConversion(t *testing.T) {
replica := newInt32(2)
replica := utilpointer.Int32Ptr(2)
rollbackTo := new(extensions.RollbackConfig)
rollbackTo.Revision = int64(2)
testcases := map[string]struct {
@ -337,9 +338,9 @@ func TestV1DeploymentConversion(t *testing.T) {
}
func TestV1DeploymentSpecConversion(t *testing.T) {
replica := newInt32(2)
revisionHistoryLimit := newInt32(2)
progressDeadlineSeconds := newInt32(2)
replica := utilpointer.Int32Ptr(2)
revisionHistoryLimit := utilpointer.Int32Ptr(2)
progressDeadlineSeconds := utilpointer.Int32Ptr(2)
testcases := map[string]struct {
deploymentSpec1 *extensions.DeploymentSpec

View File

@ -32,6 +32,7 @@ import (
. "k8s.io/kubernetes/pkg/apis/apps/v1"
api "k8s.io/kubernetes/pkg/apis/core"
_ "k8s.io/kubernetes/pkg/apis/core/install"
utilpointer "k8s.io/kubernetes/pkg/util/pointer"
)
func TestSetDefaultDaemonSetSpec(t *testing.T) {
@ -81,7 +82,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
MaxUnavailable: &maxUnavailable,
},
},
RevisionHistoryLimit: newInt32(10),
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
},
},
},
@ -94,7 +95,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
},
Spec: appsv1.DaemonSetSpec{
Template: defaultTemplate,
RevisionHistoryLimit: newInt32(1),
RevisionHistoryLimit: utilpointer.Int32Ptr(1),
},
},
expected: &appsv1.DaemonSet{
@ -111,7 +112,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
MaxUnavailable: &maxUnavailable,
},
},
RevisionHistoryLimit: newInt32(1),
RevisionHistoryLimit: utilpointer.Int32Ptr(1),
},
},
},
@ -130,7 +131,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
UpdateStrategy: appsv1.DaemonSetUpdateStrategy{
Type: appsv1.OnDeleteDaemonSetStrategyType,
},
RevisionHistoryLimit: newInt32(10),
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
},
},
},
@ -147,7 +148,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
MaxUnavailable: &maxUnavailable,
},
},
RevisionHistoryLimit: newInt32(10),
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
},
},
},
@ -211,7 +212,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
Partition: &defaultPartition,
},
},
RevisionHistoryLimit: newInt32(10),
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
},
},
},
@ -235,7 +236,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
UpdateStrategy: appsv1.StatefulSetUpdateStrategy{
Type: appsv1.OnDeleteStatefulSetStrategyType,
},
RevisionHistoryLimit: newInt32(10),
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
},
},
},
@ -260,7 +261,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
Partition: &defaultPartition,
},
},
RevisionHistoryLimit: newInt32(10),
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
},
},
},
@ -302,7 +303,7 @@ func TestSetDefaultDeployment(t *testing.T) {
original: &appsv1.Deployment{},
expected: &appsv1.Deployment{
Spec: appsv1.DeploymentSpec{
Replicas: newInt32(1),
Replicas: utilpointer.Int32Ptr(1),
Strategy: appsv1.DeploymentStrategy{
Type: appsv1.RollingUpdateDeploymentStrategyType,
RollingUpdate: &appsv1.RollingUpdateDeployment{
@ -310,8 +311,8 @@ func TestSetDefaultDeployment(t *testing.T) {
MaxUnavailable: &defaultIntOrString,
},
},
RevisionHistoryLimit: newInt32(10),
ProgressDeadlineSeconds: newInt32(600),
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
ProgressDeadlineSeconds: utilpointer.Int32Ptr(600),
Template: defaultTemplate,
},
},
@ -319,7 +320,7 @@ func TestSetDefaultDeployment(t *testing.T) {
{
original: &appsv1.Deployment{
Spec: appsv1.DeploymentSpec{
Replicas: newInt32(5),
Replicas: utilpointer.Int32Ptr(5),
Strategy: appsv1.DeploymentStrategy{
RollingUpdate: &appsv1.RollingUpdateDeployment{
MaxSurge: &differentIntOrString,
@ -329,7 +330,7 @@ func TestSetDefaultDeployment(t *testing.T) {
},
expected: &appsv1.Deployment{
Spec: appsv1.DeploymentSpec{
Replicas: newInt32(5),
Replicas: utilpointer.Int32Ptr(5),
Strategy: appsv1.DeploymentStrategy{
Type: appsv1.RollingUpdateDeploymentStrategyType,
RollingUpdate: &appsv1.RollingUpdateDeployment{
@ -337,8 +338,8 @@ func TestSetDefaultDeployment(t *testing.T) {
MaxUnavailable: &defaultIntOrString,
},
},
RevisionHistoryLimit: newInt32(10),
ProgressDeadlineSeconds: newInt32(600),
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
ProgressDeadlineSeconds: utilpointer.Int32Ptr(600),
Template: defaultTemplate,
},
},
@ -346,7 +347,7 @@ func TestSetDefaultDeployment(t *testing.T) {
{
original: &appsv1.Deployment{
Spec: appsv1.DeploymentSpec{
Replicas: newInt32(3),
Replicas: utilpointer.Int32Ptr(3),
Strategy: appsv1.DeploymentStrategy{
Type: appsv1.RollingUpdateDeploymentStrategyType,
RollingUpdate: nil,
@ -355,7 +356,7 @@ func TestSetDefaultDeployment(t *testing.T) {
},
expected: &appsv1.Deployment{
Spec: appsv1.DeploymentSpec{
Replicas: newInt32(3),
Replicas: utilpointer.Int32Ptr(3),
Strategy: appsv1.DeploymentStrategy{
Type: appsv1.RollingUpdateDeploymentStrategyType,
RollingUpdate: &appsv1.RollingUpdateDeployment{
@ -363,8 +364,8 @@ func TestSetDefaultDeployment(t *testing.T) {
MaxUnavailable: &defaultIntOrString,
},
},
RevisionHistoryLimit: newInt32(10),
ProgressDeadlineSeconds: newInt32(600),
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
ProgressDeadlineSeconds: utilpointer.Int32Ptr(600),
Template: defaultTemplate,
},
},
@ -372,21 +373,21 @@ func TestSetDefaultDeployment(t *testing.T) {
{
original: &appsv1.Deployment{
Spec: appsv1.DeploymentSpec{
Replicas: newInt32(5),
Replicas: utilpointer.Int32Ptr(5),
Strategy: appsv1.DeploymentStrategy{
Type: appsv1.RecreateDeploymentStrategyType,
},
RevisionHistoryLimit: newInt32(0),
RevisionHistoryLimit: utilpointer.Int32Ptr(0),
},
},
expected: &appsv1.Deployment{
Spec: appsv1.DeploymentSpec{
Replicas: newInt32(5),
Replicas: utilpointer.Int32Ptr(5),
Strategy: appsv1.DeploymentStrategy{
Type: appsv1.RecreateDeploymentStrategyType,
},
RevisionHistoryLimit: newInt32(0),
ProgressDeadlineSeconds: newInt32(600),
RevisionHistoryLimit: utilpointer.Int32Ptr(0),
ProgressDeadlineSeconds: utilpointer.Int32Ptr(600),
Template: defaultTemplate,
},
},
@ -394,22 +395,22 @@ func TestSetDefaultDeployment(t *testing.T) {
{
original: &appsv1.Deployment{
Spec: appsv1.DeploymentSpec{
Replicas: newInt32(5),
Replicas: utilpointer.Int32Ptr(5),
Strategy: appsv1.DeploymentStrategy{
Type: appsv1.RecreateDeploymentStrategyType,
},
ProgressDeadlineSeconds: newInt32(30),
RevisionHistoryLimit: newInt32(2),
ProgressDeadlineSeconds: utilpointer.Int32Ptr(30),
RevisionHistoryLimit: utilpointer.Int32Ptr(2),
},
},
expected: &appsv1.Deployment{
Spec: appsv1.DeploymentSpec{
Replicas: newInt32(5),
Replicas: utilpointer.Int32Ptr(5),
Strategy: appsv1.DeploymentStrategy{
Type: appsv1.RecreateDeploymentStrategyType,
},
ProgressDeadlineSeconds: newInt32(30),
RevisionHistoryLimit: newInt32(2),
ProgressDeadlineSeconds: utilpointer.Int32Ptr(30),
RevisionHistoryLimit: utilpointer.Int32Ptr(2),
Template: defaultTemplate,
},
},
@ -466,7 +467,7 @@ func TestSetDefaultReplicaSetReplicas(t *testing.T) {
{
rs: appsv1.ReplicaSet{
Spec: appsv1.ReplicaSetSpec{
Replicas: newInt32(0),
Replicas: utilpointer.Int32Ptr(0),
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
@ -481,7 +482,7 @@ func TestSetDefaultReplicaSetReplicas(t *testing.T) {
{
rs: appsv1.ReplicaSet{
Spec: appsv1.ReplicaSetSpec{
Replicas: newInt32(3),
Replicas: utilpointer.Int32Ptr(3),
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
@ -524,7 +525,7 @@ func TestDefaultRequestIsNotSetForReplicaSet(t *testing.T) {
}
rs := &appsv1.ReplicaSet{
Spec: appsv1.ReplicaSetSpec{
Replicas: newInt32(3),
Replicas: utilpointer.Int32Ptr(3),
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
@ -563,9 +564,3 @@ func roundTrip(t *testing.T, obj runtime.Object) runtime.Object {
}
return obj3
}
func newInt32(val int32) *int32 {
p := new(int32)
*p = val
return p
}

View File

@ -16,11 +16,13 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was autogenerated by conversion-gen. Do not edit it manually!
// Code generated by conversion-gen. DO NOT EDIT.
package v1
import (
unsafe "unsafe"
v1 "k8s.io/api/apps/v1"
core_v1 "k8s.io/api/core/v1"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -30,7 +32,6 @@ import (
core "k8s.io/kubernetes/pkg/apis/core"
apis_core_v1 "k8s.io/kubernetes/pkg/apis/core/v1"
extensions "k8s.io/kubernetes/pkg/apis/extensions"
unsafe "unsafe"
)
func init() {
@ -889,7 +890,9 @@ func autoConvert_apps_StatefulSetSpec_To_v1_StatefulSetSpec(in *apps.StatefulSet
}
func autoConvert_v1_StatefulSetStatus_To_apps_StatefulSetStatus(in *v1.StatefulSetStatus, out *apps.StatefulSetStatus, s conversion.Scope) error {
// WARNING: in.ObservedGeneration requires manual conversion: inconvertible types (int64 vs *int64)
if err := meta_v1.Convert_int64_To_Pointer_int64(&in.ObservedGeneration, &out.ObservedGeneration, s); err != nil {
return err
}
out.Replicas = in.Replicas
out.ReadyReplicas = in.ReadyReplicas
out.CurrentReplicas = in.CurrentReplicas
@ -902,7 +905,9 @@ func autoConvert_v1_StatefulSetStatus_To_apps_StatefulSetStatus(in *v1.StatefulS
}
func autoConvert_apps_StatefulSetStatus_To_v1_StatefulSetStatus(in *apps.StatefulSetStatus, out *v1.StatefulSetStatus, s conversion.Scope) error {
// WARNING: in.ObservedGeneration requires manual conversion: inconvertible types (*int64 vs int64)
if err := meta_v1.Convert_Pointer_int64_To_int64(&in.ObservedGeneration, &out.ObservedGeneration, s); err != nil {
return err
}
out.Replicas = in.Replicas
out.ReadyReplicas = in.ReadyReplicas
out.CurrentReplicas = in.CurrentReplicas

View File

@ -16,7 +16,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was autogenerated by defaulter-gen. Do not edit it manually!
// Code generated by defaulter-gen. DO NOT EDIT.
package v1

View File

@ -50,13 +50,13 @@ filegroup(
go_test(
name = "go_default_xtest",
srcs = ["defaults_test.go"],
importpath = "k8s.io/kubernetes/pkg/apis/apps/v1beta1_test",
deps = [
":go_default_library",
"//pkg/api/legacyscheme:go_default_library",
"//pkg/apis/apps/install:go_default_library",
"//pkg/apis/core:go_default_library",
"//pkg/apis/core/install:go_default_library",
"//pkg/util/pointer:go_default_library",
"//vendor/k8s.io/api/apps/v1beta1:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/equality:go_default_library",

View File

@ -31,6 +31,7 @@ import (
. "k8s.io/kubernetes/pkg/apis/apps/v1beta1"
api "k8s.io/kubernetes/pkg/apis/core"
_ "k8s.io/kubernetes/pkg/apis/core/install"
utilpointer "k8s.io/kubernetes/pkg/util/pointer"
)
func TestSetDefaultDeployment(t *testing.T) {
@ -54,7 +55,7 @@ func TestSetDefaultDeployment(t *testing.T) {
original: &appsv1beta1.Deployment{},
expected: &appsv1beta1.Deployment{
Spec: appsv1beta1.DeploymentSpec{
Replicas: newInt32(1),
Replicas: utilpointer.Int32Ptr(1),
Strategy: appsv1beta1.DeploymentStrategy{
Type: appsv1beta1.RollingUpdateDeploymentStrategyType,
RollingUpdate: &appsv1beta1.RollingUpdateDeployment{
@ -62,8 +63,8 @@ func TestSetDefaultDeployment(t *testing.T) {
MaxUnavailable: &defaultIntOrString,
},
},
RevisionHistoryLimit: newInt32(2),
ProgressDeadlineSeconds: newInt32(600),
RevisionHistoryLimit: utilpointer.Int32Ptr(2),
ProgressDeadlineSeconds: utilpointer.Int32Ptr(600),
Template: defaultTemplate,
},
},
@ -71,7 +72,7 @@ func TestSetDefaultDeployment(t *testing.T) {
{
original: &appsv1beta1.Deployment{
Spec: appsv1beta1.DeploymentSpec{
Replicas: newInt32(5),
Replicas: utilpointer.Int32Ptr(5),
Strategy: appsv1beta1.DeploymentStrategy{
RollingUpdate: &appsv1beta1.RollingUpdateDeployment{
MaxSurge: &differentIntOrString,
@ -81,7 +82,7 @@ func TestSetDefaultDeployment(t *testing.T) {
},
expected: &appsv1beta1.Deployment{
Spec: appsv1beta1.DeploymentSpec{
Replicas: newInt32(5),
Replicas: utilpointer.Int32Ptr(5),
Strategy: appsv1beta1.DeploymentStrategy{
Type: appsv1beta1.RollingUpdateDeploymentStrategyType,
RollingUpdate: &appsv1beta1.RollingUpdateDeployment{
@ -89,8 +90,8 @@ func TestSetDefaultDeployment(t *testing.T) {
MaxUnavailable: &defaultIntOrString,
},
},
RevisionHistoryLimit: newInt32(2),
ProgressDeadlineSeconds: newInt32(600),
RevisionHistoryLimit: utilpointer.Int32Ptr(2),
ProgressDeadlineSeconds: utilpointer.Int32Ptr(600),
Template: defaultTemplate,
},
},
@ -98,7 +99,7 @@ func TestSetDefaultDeployment(t *testing.T) {
{
original: &appsv1beta1.Deployment{
Spec: appsv1beta1.DeploymentSpec{
Replicas: newInt32(3),
Replicas: utilpointer.Int32Ptr(3),
Strategy: appsv1beta1.DeploymentStrategy{
Type: appsv1beta1.RollingUpdateDeploymentStrategyType,
RollingUpdate: nil,
@ -107,7 +108,7 @@ func TestSetDefaultDeployment(t *testing.T) {
},
expected: &appsv1beta1.Deployment{
Spec: appsv1beta1.DeploymentSpec{
Replicas: newInt32(3),
Replicas: utilpointer.Int32Ptr(3),
Strategy: appsv1beta1.DeploymentStrategy{
Type: appsv1beta1.RollingUpdateDeploymentStrategyType,
RollingUpdate: &appsv1beta1.RollingUpdateDeployment{
@ -115,8 +116,8 @@ func TestSetDefaultDeployment(t *testing.T) {
MaxUnavailable: &defaultIntOrString,
},
},
RevisionHistoryLimit: newInt32(2),
ProgressDeadlineSeconds: newInt32(600),
RevisionHistoryLimit: utilpointer.Int32Ptr(2),
ProgressDeadlineSeconds: utilpointer.Int32Ptr(600),
Template: defaultTemplate,
},
},
@ -124,21 +125,21 @@ func TestSetDefaultDeployment(t *testing.T) {
{
original: &appsv1beta1.Deployment{
Spec: appsv1beta1.DeploymentSpec{
Replicas: newInt32(5),
Replicas: utilpointer.Int32Ptr(5),
Strategy: appsv1beta1.DeploymentStrategy{
Type: appsv1beta1.RecreateDeploymentStrategyType,
},
RevisionHistoryLimit: newInt32(0),
RevisionHistoryLimit: utilpointer.Int32Ptr(0),
},
},
expected: &appsv1beta1.Deployment{
Spec: appsv1beta1.DeploymentSpec{
Replicas: newInt32(5),
Replicas: utilpointer.Int32Ptr(5),
Strategy: appsv1beta1.DeploymentStrategy{
Type: appsv1beta1.RecreateDeploymentStrategyType,
},
RevisionHistoryLimit: newInt32(0),
ProgressDeadlineSeconds: newInt32(600),
RevisionHistoryLimit: utilpointer.Int32Ptr(0),
ProgressDeadlineSeconds: utilpointer.Int32Ptr(600),
Template: defaultTemplate,
},
},
@ -146,22 +147,22 @@ func TestSetDefaultDeployment(t *testing.T) {
{
original: &appsv1beta1.Deployment{
Spec: appsv1beta1.DeploymentSpec{
Replicas: newInt32(5),
Replicas: utilpointer.Int32Ptr(5),
Strategy: appsv1beta1.DeploymentStrategy{
Type: appsv1beta1.RecreateDeploymentStrategyType,
},
ProgressDeadlineSeconds: newInt32(30),
RevisionHistoryLimit: newInt32(2),
ProgressDeadlineSeconds: utilpointer.Int32Ptr(30),
RevisionHistoryLimit: utilpointer.Int32Ptr(2),
},
},
expected: &appsv1beta1.Deployment{
Spec: appsv1beta1.DeploymentSpec{
Replicas: newInt32(5),
Replicas: utilpointer.Int32Ptr(5),
Strategy: appsv1beta1.DeploymentStrategy{
Type: appsv1beta1.RecreateDeploymentStrategyType,
},
ProgressDeadlineSeconds: newInt32(30),
RevisionHistoryLimit: newInt32(2),
ProgressDeadlineSeconds: utilpointer.Int32Ptr(30),
RevisionHistoryLimit: utilpointer.Int32Ptr(2),
Template: defaultTemplate,
},
},
@ -215,9 +216,3 @@ func roundTrip(t *testing.T, obj runtime.Object) runtime.Object {
}
return obj3
}
func newInt32(val int32) *int32 {
p := new(int32)
*p = val
return p
}

View File

@ -16,11 +16,13 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was autogenerated by conversion-gen. Do not edit it manually!
// Code generated by conversion-gen. DO NOT EDIT.
package v1beta1
import (
unsafe "unsafe"
v1beta1 "k8s.io/api/apps/v1beta1"
v1 "k8s.io/api/core/v1"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -31,7 +33,6 @@ import (
core "k8s.io/kubernetes/pkg/apis/core"
core_v1 "k8s.io/kubernetes/pkg/apis/core/v1"
extensions "k8s.io/kubernetes/pkg/apis/extensions"
unsafe "unsafe"
)
func init() {

View File

@ -16,7 +16,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was autogenerated by defaulter-gen. Do not edit it manually!
// Code generated by defaulter-gen. DO NOT EDIT.
package v1beta1

View File

@ -53,7 +53,6 @@ go_test(
"conversion_test.go",
"defaults_test.go",
],
importpath = "k8s.io/kubernetes/pkg/apis/apps/v1beta2_test",
deps = [
":go_default_library",
"//pkg/api/legacyscheme:go_default_library",
@ -63,6 +62,7 @@ go_test(
"//pkg/apis/core:go_default_library",
"//pkg/apis/core/install:go_default_library",
"//pkg/apis/extensions:go_default_library",
"//pkg/util/pointer:go_default_library",
"//vendor/k8s.io/api/apps/v1beta2:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/equality:go_default_library",

View File

@ -30,10 +30,11 @@ import (
apiequality "k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
utilpointer "k8s.io/kubernetes/pkg/util/pointer"
)
func TestV1beta2StatefulSetSpecConversion(t *testing.T) {
replicas := newInt32(2)
replicas := utilpointer.Int32Ptr(2)
selector := &metav1.LabelSelector{MatchLabels: map[string]string{"foo": "bar"}}
v1beta2Template := v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{Name: "foo"},
@ -104,7 +105,7 @@ func TestV1beta2StatefulSetSpecConversion(t *testing.T) {
}
func TestV1beta2StatefulSetUpdateStrategyConversion(t *testing.T) {
partition := newInt32(2)
partition := utilpointer.Int32Ptr(2)
v1beta2rollingUpdate := new(v1beta2.RollingUpdateStatefulSetStrategy)
v1beta2rollingUpdate.Partition = partition
appsrollingUpdate := new(apps.RollingUpdateStatefulSetStrategy)
@ -260,7 +261,7 @@ func TestV1beta2StatefulSetStatusConversion(t *testing.T) {
}
func TestV1beta2DeploymentConversion(t *testing.T) {
replica := newInt32(2)
replica := utilpointer.Int32Ptr(2)
rollbackTo := new(extensions.RollbackConfig)
rollbackTo.Revision = int64(2)
testcases := map[string]struct {
@ -390,9 +391,9 @@ func TestV1beta2ScaleStatusConversion(t *testing.T) {
}
func TestV1beta2DeploymentSpecConversion(t *testing.T) {
replica := newInt32(2)
revisionHistoryLimit := newInt32(2)
progressDeadlineSeconds := newInt32(2)
replica := utilpointer.Int32Ptr(2)
revisionHistoryLimit := utilpointer.Int32Ptr(2)
progressDeadlineSeconds := utilpointer.Int32Ptr(2)
testcases := map[string]struct {
deploymentSpec1 *extensions.DeploymentSpec

View File

@ -32,6 +32,7 @@ import (
. "k8s.io/kubernetes/pkg/apis/apps/v1beta2"
api "k8s.io/kubernetes/pkg/apis/core"
_ "k8s.io/kubernetes/pkg/apis/core/install"
utilpointer "k8s.io/kubernetes/pkg/util/pointer"
)
func TestSetDefaultDaemonSetSpec(t *testing.T) {
@ -81,7 +82,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
MaxUnavailable: &maxUnavailable,
},
},
RevisionHistoryLimit: newInt32(10),
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
},
},
},
@ -94,7 +95,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
},
Spec: appsv1beta2.DaemonSetSpec{
Template: defaultTemplate,
RevisionHistoryLimit: newInt32(1),
RevisionHistoryLimit: utilpointer.Int32Ptr(1),
},
},
expected: &appsv1beta2.DaemonSet{
@ -111,7 +112,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
MaxUnavailable: &maxUnavailable,
},
},
RevisionHistoryLimit: newInt32(1),
RevisionHistoryLimit: utilpointer.Int32Ptr(1),
},
},
},
@ -130,7 +131,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
UpdateStrategy: appsv1beta2.DaemonSetUpdateStrategy{
Type: appsv1beta2.OnDeleteDaemonSetStrategyType,
},
RevisionHistoryLimit: newInt32(10),
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
},
},
},
@ -147,7 +148,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
MaxUnavailable: &maxUnavailable,
},
},
RevisionHistoryLimit: newInt32(10),
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
},
},
},
@ -211,7 +212,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
Partition: &defaultPartition,
},
},
RevisionHistoryLimit: newInt32(10),
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
},
},
},
@ -235,7 +236,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
UpdateStrategy: appsv1beta2.StatefulSetUpdateStrategy{
Type: appsv1beta2.OnDeleteStatefulSetStrategyType,
},
RevisionHistoryLimit: newInt32(10),
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
},
},
},
@ -260,7 +261,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
Partition: &defaultPartition,
},
},
RevisionHistoryLimit: newInt32(10),
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
},
},
},
@ -302,7 +303,7 @@ func TestSetDefaultDeployment(t *testing.T) {
original: &appsv1beta2.Deployment{},
expected: &appsv1beta2.Deployment{
Spec: appsv1beta2.DeploymentSpec{
Replicas: newInt32(1),
Replicas: utilpointer.Int32Ptr(1),
Strategy: appsv1beta2.DeploymentStrategy{
Type: appsv1beta2.RollingUpdateDeploymentStrategyType,
RollingUpdate: &appsv1beta2.RollingUpdateDeployment{
@ -310,8 +311,8 @@ func TestSetDefaultDeployment(t *testing.T) {
MaxUnavailable: &defaultIntOrString,
},
},
RevisionHistoryLimit: newInt32(10),
ProgressDeadlineSeconds: newInt32(600),
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
ProgressDeadlineSeconds: utilpointer.Int32Ptr(600),
Template: defaultTemplate,
},
},
@ -319,7 +320,7 @@ func TestSetDefaultDeployment(t *testing.T) {
{
original: &appsv1beta2.Deployment{
Spec: appsv1beta2.DeploymentSpec{
Replicas: newInt32(5),
Replicas: utilpointer.Int32Ptr(5),
Strategy: appsv1beta2.DeploymentStrategy{
RollingUpdate: &appsv1beta2.RollingUpdateDeployment{
MaxSurge: &differentIntOrString,
@ -329,7 +330,7 @@ func TestSetDefaultDeployment(t *testing.T) {
},
expected: &appsv1beta2.Deployment{
Spec: appsv1beta2.DeploymentSpec{
Replicas: newInt32(5),
Replicas: utilpointer.Int32Ptr(5),
Strategy: appsv1beta2.DeploymentStrategy{
Type: appsv1beta2.RollingUpdateDeploymentStrategyType,
RollingUpdate: &appsv1beta2.RollingUpdateDeployment{
@ -337,8 +338,8 @@ func TestSetDefaultDeployment(t *testing.T) {
MaxUnavailable: &defaultIntOrString,
},
},
RevisionHistoryLimit: newInt32(10),
ProgressDeadlineSeconds: newInt32(600),
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
ProgressDeadlineSeconds: utilpointer.Int32Ptr(600),
Template: defaultTemplate,
},
},
@ -346,7 +347,7 @@ func TestSetDefaultDeployment(t *testing.T) {
{
original: &appsv1beta2.Deployment{
Spec: appsv1beta2.DeploymentSpec{
Replicas: newInt32(3),
Replicas: utilpointer.Int32Ptr(3),
Strategy: appsv1beta2.DeploymentStrategy{
Type: appsv1beta2.RollingUpdateDeploymentStrategyType,
RollingUpdate: nil,
@ -355,7 +356,7 @@ func TestSetDefaultDeployment(t *testing.T) {
},
expected: &appsv1beta2.Deployment{
Spec: appsv1beta2.DeploymentSpec{
Replicas: newInt32(3),
Replicas: utilpointer.Int32Ptr(3),
Strategy: appsv1beta2.DeploymentStrategy{
Type: appsv1beta2.RollingUpdateDeploymentStrategyType,
RollingUpdate: &appsv1beta2.RollingUpdateDeployment{
@ -363,8 +364,8 @@ func TestSetDefaultDeployment(t *testing.T) {
MaxUnavailable: &defaultIntOrString,
},
},
RevisionHistoryLimit: newInt32(10),
ProgressDeadlineSeconds: newInt32(600),
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
ProgressDeadlineSeconds: utilpointer.Int32Ptr(600),
Template: defaultTemplate,
},
},
@ -372,21 +373,21 @@ func TestSetDefaultDeployment(t *testing.T) {
{
original: &appsv1beta2.Deployment{
Spec: appsv1beta2.DeploymentSpec{
Replicas: newInt32(5),
Replicas: utilpointer.Int32Ptr(5),
Strategy: appsv1beta2.DeploymentStrategy{
Type: appsv1beta2.RecreateDeploymentStrategyType,
},
RevisionHistoryLimit: newInt32(0),
RevisionHistoryLimit: utilpointer.Int32Ptr(0),
},
},
expected: &appsv1beta2.Deployment{
Spec: appsv1beta2.DeploymentSpec{
Replicas: newInt32(5),
Replicas: utilpointer.Int32Ptr(5),
Strategy: appsv1beta2.DeploymentStrategy{
Type: appsv1beta2.RecreateDeploymentStrategyType,
},
RevisionHistoryLimit: newInt32(0),
ProgressDeadlineSeconds: newInt32(600),
RevisionHistoryLimit: utilpointer.Int32Ptr(0),
ProgressDeadlineSeconds: utilpointer.Int32Ptr(600),
Template: defaultTemplate,
},
},
@ -394,22 +395,22 @@ func TestSetDefaultDeployment(t *testing.T) {
{
original: &appsv1beta2.Deployment{
Spec: appsv1beta2.DeploymentSpec{
Replicas: newInt32(5),
Replicas: utilpointer.Int32Ptr(5),
Strategy: appsv1beta2.DeploymentStrategy{
Type: appsv1beta2.RecreateDeploymentStrategyType,
},
ProgressDeadlineSeconds: newInt32(30),
RevisionHistoryLimit: newInt32(2),
ProgressDeadlineSeconds: utilpointer.Int32Ptr(30),
RevisionHistoryLimit: utilpointer.Int32Ptr(2),
},
},
expected: &appsv1beta2.Deployment{
Spec: appsv1beta2.DeploymentSpec{
Replicas: newInt32(5),
Replicas: utilpointer.Int32Ptr(5),
Strategy: appsv1beta2.DeploymentStrategy{
Type: appsv1beta2.RecreateDeploymentStrategyType,
},
ProgressDeadlineSeconds: newInt32(30),
RevisionHistoryLimit: newInt32(2),
ProgressDeadlineSeconds: utilpointer.Int32Ptr(30),
RevisionHistoryLimit: utilpointer.Int32Ptr(2),
Template: defaultTemplate,
},
},
@ -466,7 +467,7 @@ func TestSetDefaultReplicaSetReplicas(t *testing.T) {
{
rs: appsv1beta2.ReplicaSet{
Spec: appsv1beta2.ReplicaSetSpec{
Replicas: newInt32(0),
Replicas: utilpointer.Int32Ptr(0),
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
@ -481,7 +482,7 @@ func TestSetDefaultReplicaSetReplicas(t *testing.T) {
{
rs: appsv1beta2.ReplicaSet{
Spec: appsv1beta2.ReplicaSetSpec{
Replicas: newInt32(3),
Replicas: utilpointer.Int32Ptr(3),
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
@ -524,7 +525,7 @@ func TestDefaultRequestIsNotSetForReplicaSet(t *testing.T) {
}
rs := &appsv1beta2.ReplicaSet{
Spec: appsv1beta2.ReplicaSetSpec{
Replicas: newInt32(3),
Replicas: utilpointer.Int32Ptr(3),
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
@ -563,9 +564,3 @@ func roundTrip(t *testing.T, obj runtime.Object) runtime.Object {
}
return obj3
}
func newInt32(val int32) *int32 {
p := new(int32)
*p = val
return p
}

View File

@ -16,11 +16,13 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was autogenerated by conversion-gen. Do not edit it manually!
// Code generated by conversion-gen. DO NOT EDIT.
package v1beta2
import (
unsafe "unsafe"
v1beta2 "k8s.io/api/apps/v1beta2"
v1 "k8s.io/api/core/v1"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -31,7 +33,6 @@ import (
core "k8s.io/kubernetes/pkg/apis/core"
core_v1 "k8s.io/kubernetes/pkg/apis/core/v1"
extensions "k8s.io/kubernetes/pkg/apis/extensions"
unsafe "unsafe"
)
func init() {
@ -961,7 +962,9 @@ func autoConvert_apps_StatefulSetSpec_To_v1beta2_StatefulSetSpec(in *apps.Statef
}
func autoConvert_v1beta2_StatefulSetStatus_To_apps_StatefulSetStatus(in *v1beta2.StatefulSetStatus, out *apps.StatefulSetStatus, s conversion.Scope) error {
// WARNING: in.ObservedGeneration requires manual conversion: inconvertible types (int64 vs *int64)
if err := meta_v1.Convert_int64_To_Pointer_int64(&in.ObservedGeneration, &out.ObservedGeneration, s); err != nil {
return err
}
out.Replicas = in.Replicas
out.ReadyReplicas = in.ReadyReplicas
out.CurrentReplicas = in.CurrentReplicas
@ -974,7 +977,9 @@ func autoConvert_v1beta2_StatefulSetStatus_To_apps_StatefulSetStatus(in *v1beta2
}
func autoConvert_apps_StatefulSetStatus_To_v1beta2_StatefulSetStatus(in *apps.StatefulSetStatus, out *v1beta2.StatefulSetStatus, s conversion.Scope) error {
// WARNING: in.ObservedGeneration requires manual conversion: inconvertible types (*int64 vs int64)
if err := meta_v1.Convert_Pointer_int64_To_int64(&in.ObservedGeneration, &out.ObservedGeneration, s); err != nil {
return err
}
out.Replicas = in.Replicas
out.ReadyReplicas = in.ReadyReplicas
out.CurrentReplicas = in.CurrentReplicas

View File

@ -16,7 +16,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was autogenerated by defaulter-gen. Do not edit it manually!
// Code generated by defaulter-gen. DO NOT EDIT.
package v1beta2

View File

@ -24,8 +24,7 @@ go_library(
go_test(
name = "go_default_test",
srcs = ["validation_test.go"],
importpath = "k8s.io/kubernetes/pkg/apis/apps/validation",
library = ":go_default_library",
embed = [":go_default_library"],
deps = [
"//pkg/apis/apps:go_default_library",
"//pkg/apis/core:go_default_library",

View File

@ -94,7 +94,6 @@ func ValidateStatefulSetSpec(spec *apps.StatefulSetSpec, fldPath *field.Path) fi
int64(spec.UpdateStrategy.RollingUpdate.Partition),
fldPath.Child("updateStrategy").Child("rollingUpdate").Child("partition"))...)
}
default:
allErrs = append(allErrs,
field.Invalid(fldPath.Child("updateStrategy"), spec.UpdateStrategy,
@ -124,7 +123,7 @@ func ValidateStatefulSetSpec(spec *apps.StatefulSetSpec, fldPath *field.Path) fi
allErrs = append(allErrs, field.NotSupported(fldPath.Child("template", "spec", "restartPolicy"), spec.Template.Spec.RestartPolicy, []string{string(api.RestartPolicyAlways)}))
}
if spec.Template.Spec.ActiveDeadlineSeconds != nil {
allErrs = append(allErrs, field.Invalid(fldPath.Child("spec", "activeDeadlineSeconds"), spec.Template.Spec.ActiveDeadlineSeconds, "must not be specified"))
allErrs = append(allErrs, field.Invalid(fldPath.Child("template", "spec", "activeDeadlineSeconds"), spec.Template.Spec.ActiveDeadlineSeconds, "must not be specified"))
}
return allErrs
@ -196,6 +195,13 @@ func ValidateStatefulSetStatusUpdate(statefulSet, oldStatefulSet *apps.StatefulS
allErrs = append(allErrs, ValidateStatefulSetStatus(&statefulSet.Status, field.NewPath("status"))...)
allErrs = append(allErrs, apivalidation.ValidateObjectMetaUpdate(&statefulSet.ObjectMeta, &oldStatefulSet.ObjectMeta, field.NewPath("metadata"))...)
// TODO: Validate status.
if apivalidation.IsDecremented(statefulSet.Status.CollisionCount, oldStatefulSet.Status.CollisionCount) {
value := int32(0)
if statefulSet.Status.CollisionCount != nil {
value = *statefulSet.Status.CollisionCount
}
allErrs = append(allErrs, field.Invalid(field.NewPath("status").Child("collisionCount"), value, "cannot be decremented"))
}
return allErrs
}

View File

@ -17,6 +17,7 @@ limitations under the License.
package validation
import (
"strconv"
"strings"
"testing"
@ -41,6 +42,7 @@ func TestValidateStatefulSet(t *testing.T) {
},
},
}
invalidLabels := map[string]string{"NoUppercaseOrSpecialCharsLike=Equals": "b"}
invalidPodTemplate := api.PodTemplate{
Template: api.PodTemplateSpec{
@ -53,6 +55,21 @@ func TestValidateStatefulSet(t *testing.T) {
},
},
}
invalidTime := int64(60)
invalidPodTemplate2 := api.PodTemplate{
Template: api.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{"foo": "bar"},
},
Spec: api.PodSpec{
RestartPolicy: api.RestartPolicyOnFailure,
DNSPolicy: api.DNSClusterFirst,
ActiveDeadlineSeconds: &invalidTime,
},
},
}
successCases := []apps.StatefulSet{
{
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
@ -105,10 +122,13 @@ func TestValidateStatefulSet(t *testing.T) {
},
},
}
for _, successCase := range successCases {
if errs := ValidateStatefulSet(&successCase); len(errs) != 0 {
t.Errorf("expected success: %v", errs)
}
for i, successCase := range successCases {
t.Run("success case "+strconv.Itoa(i), func(t *testing.T) {
if errs := ValidateStatefulSet(&successCase); len(errs) != 0 {
t.Errorf("expected success: %v", errs)
}
})
}
errorCases := map[string]apps.StatefulSet{
@ -250,7 +270,7 @@ func TestValidateStatefulSet(t *testing.T) {
UpdateStrategy: apps.StatefulSetUpdateStrategy{Type: apps.RollingUpdateStatefulSetStrategyType},
},
},
"invalid udpate strategy": {
"invalid update strategy": {
ObjectMeta: metav1.ObjectMeta{Name: "abc-123", Namespace: metav1.NamespaceDefault},
Spec: apps.StatefulSetSpec{
PodManagementPolicy: apps.OrderedReadyPodManagement,
@ -260,6 +280,29 @@ func TestValidateStatefulSet(t *testing.T) {
UpdateStrategy: apps.StatefulSetUpdateStrategy{Type: "foo"},
},
},
"empty update strategy": {
ObjectMeta: metav1.ObjectMeta{Name: "abc-123", Namespace: metav1.NamespaceDefault},
Spec: apps.StatefulSetSpec{
PodManagementPolicy: apps.OrderedReadyPodManagement,
Selector: &metav1.LabelSelector{MatchLabels: validLabels},
Template: validPodTemplate.Template,
Replicas: 3,
UpdateStrategy: apps.StatefulSetUpdateStrategy{Type: ""},
},
},
"invalid rolling update": {
ObjectMeta: metav1.ObjectMeta{Name: "abc-123", Namespace: metav1.NamespaceDefault},
Spec: apps.StatefulSetSpec{
PodManagementPolicy: apps.OrderedReadyPodManagement,
Selector: &metav1.LabelSelector{MatchLabels: validLabels},
Template: validPodTemplate.Template,
Replicas: 3,
UpdateStrategy: apps.StatefulSetUpdateStrategy{Type: apps.OnDeleteStatefulSetStrategyType,
RollingUpdate: func() *apps.RollingUpdateStatefulSetStrategy {
return &apps.RollingUpdateStatefulSetStrategy{Partition: 1}
}()},
},
},
"negative parition": {
ObjectMeta: metav1.ObjectMeta{Name: "abc-123", Namespace: metav1.NamespaceDefault},
Spec: apps.StatefulSetSpec{
@ -273,31 +316,67 @@ func TestValidateStatefulSet(t *testing.T) {
}()},
},
},
"empty pod management policy": {
ObjectMeta: metav1.ObjectMeta{Name: "abc-123", Namespace: metav1.NamespaceDefault},
Spec: apps.StatefulSetSpec{
PodManagementPolicy: "",
Selector: &metav1.LabelSelector{MatchLabels: validLabels},
Template: validPodTemplate.Template,
Replicas: 3,
UpdateStrategy: apps.StatefulSetUpdateStrategy{Type: apps.RollingUpdateStatefulSetStrategyType},
},
},
"invalid pod management policy": {
ObjectMeta: metav1.ObjectMeta{Name: "abc-123", Namespace: metav1.NamespaceDefault},
Spec: apps.StatefulSetSpec{
PodManagementPolicy: "foo",
Selector: &metav1.LabelSelector{MatchLabels: validLabels},
Template: validPodTemplate.Template,
Replicas: 3,
UpdateStrategy: apps.StatefulSetUpdateStrategy{Type: apps.RollingUpdateStatefulSetStrategyType},
},
},
"set active deadline seconds": {
ObjectMeta: metav1.ObjectMeta{Name: "abc-123", Namespace: metav1.NamespaceDefault},
Spec: apps.StatefulSetSpec{
PodManagementPolicy: "foo",
Selector: &metav1.LabelSelector{MatchLabels: validLabels},
Template: invalidPodTemplate2.Template,
Replicas: 3,
UpdateStrategy: apps.StatefulSetUpdateStrategy{Type: apps.RollingUpdateStatefulSetStrategyType},
},
},
}
for k, v := range errorCases {
errs := ValidateStatefulSet(&v)
if len(errs) == 0 {
t.Errorf("expected failure for %s", k)
}
for i := range errs {
field := errs[i].Field
if !strings.HasPrefix(field, "spec.template.") &&
field != "metadata.name" &&
field != "metadata.namespace" &&
field != "spec.selector" &&
field != "spec.template" &&
field != "GCEPersistentDisk.ReadOnly" &&
field != "spec.replicas" &&
field != "spec.template.labels" &&
field != "metadata.annotations" &&
field != "metadata.labels" &&
field != "status.replicas" &&
field != "spec.updateStrategy" &&
field != "spec.updateStrategy.rollingUpdate" &&
field != "spec.updateStrategy.rollingUpdate.partition" {
t.Errorf("%s: missing prefix for: %v", k, errs[i])
t.Run(k, func(t *testing.T) {
errs := ValidateStatefulSet(&v)
if len(errs) == 0 {
t.Errorf("expected failure for %s", k)
}
}
for i := range errs {
field := errs[i].Field
if !strings.HasPrefix(field, "spec.template.") &&
field != "metadata.name" &&
field != "metadata.namespace" &&
field != "spec.selector" &&
field != "spec.template" &&
field != "GCEPersistentDisk.ReadOnly" &&
field != "spec.replicas" &&
field != "spec.template.labels" &&
field != "metadata.annotations" &&
field != "metadata.labels" &&
field != "status.replicas" &&
field != "spec.updateStrategy" &&
field != "spec.updateStrategy.rollingUpdate" &&
field != "spec.updateStrategy.rollingUpdate.partition" &&
field != "spec.podManagementPolicy" &&
field != "spec.template.spec.activeDeadlineSeconds" {
t.Errorf("%s: missing prefix for: %v", k, errs[i])
}
}
})
}
}
@ -399,19 +478,21 @@ func TestValidateStatefulSetStatus(t *testing.T) {
}
for _, test := range tests {
status := apps.StatefulSetStatus{
Replicas: test.replicas,
ReadyReplicas: test.readyReplicas,
CurrentReplicas: test.currentReplicas,
UpdatedReplicas: test.updatedReplicas,
ObservedGeneration: test.observedGeneration,
CollisionCount: test.collisionCount,
}
t.Run(test.name, func(t *testing.T) {
status := apps.StatefulSetStatus{
Replicas: test.replicas,
ReadyReplicas: test.readyReplicas,
CurrentReplicas: test.currentReplicas,
UpdatedReplicas: test.updatedReplicas,
ObservedGeneration: test.observedGeneration,
CollisionCount: test.collisionCount,
}
errs := ValidateStatefulSetStatus(&status, field.NewPath("status"))
if hasErr := len(errs) > 0; hasErr != test.expectedErr {
t.Errorf("%s: expected error: %t, got error: %t\nerrors: %s", test.name, test.expectedErr, hasErr, errs.ToAggregate().Error())
}
errs := ValidateStatefulSetStatus(&status, field.NewPath("status"))
if hasErr := len(errs) > 0; hasErr != test.expectedErr {
t.Errorf("%s: expected error: %t, got error: %t\nerrors: %s", test.name, test.expectedErr, hasErr, errs.ToAggregate().Error())
}
})
}
}
@ -462,6 +543,7 @@ func TestValidateStatefulSetUpdate(t *testing.T) {
},
},
}
type psUpdateTest struct {
old apps.StatefulSet
update apps.StatefulSet
@ -529,13 +611,17 @@ func TestValidateStatefulSetUpdate(t *testing.T) {
},
},
}
for _, successCase := range successCases {
successCase.old.ObjectMeta.ResourceVersion = "1"
successCase.update.ObjectMeta.ResourceVersion = "1"
if errs := ValidateStatefulSetUpdate(&successCase.update, &successCase.old); len(errs) != 0 {
t.Errorf("expected success: %v", errs)
}
for i, successCase := range successCases {
t.Run("success case "+strconv.Itoa(i), func(t *testing.T) {
successCase.old.ObjectMeta.ResourceVersion = "1"
successCase.update.ObjectMeta.ResourceVersion = "1"
if errs := ValidateStatefulSetUpdate(&successCase.update, &successCase.old); len(errs) != 0 {
t.Errorf("expected success: %v", errs)
}
})
}
errorCases := map[string]psUpdateTest{
"more than one read/write": {
old: apps.StatefulSet{
@ -656,10 +742,13 @@ func TestValidateStatefulSetUpdate(t *testing.T) {
},
},
}
for testName, errorCase := range errorCases {
if errs := ValidateStatefulSetUpdate(&errorCase.update, &errorCase.old); len(errs) == 0 {
t.Errorf("expected failure: %s", testName)
}
t.Run(testName, func(t *testing.T) {
if errs := ValidateStatefulSetUpdate(&errorCase.update, &errorCase.old); len(errs) == 0 {
t.Errorf("expected failure: %s", testName)
}
})
}
}
@ -715,13 +804,15 @@ func TestValidateControllerRevision(t *testing.T) {
}
for name, tc := range tests {
errs := ValidateControllerRevision(&tc.history)
if tc.isValid && len(errs) > 0 {
t.Errorf("%v: unexpected error: %v", name, errs)
}
if !tc.isValid && len(errs) == 0 {
t.Errorf("%v: unexpected non-error", name)
}
t.Run(name, func(t *testing.T) {
errs := ValidateControllerRevision(&tc.history)
if tc.isValid && len(errs) > 0 {
t.Errorf("%v: unexpected error: %v", name, errs)
}
if !tc.isValid && len(errs) == 0 {
t.Errorf("%v: unexpected non-error", name)
}
})
}
}
@ -809,12 +900,14 @@ func TestValidateControllerRevisionUpdate(t *testing.T) {
}
for _, tc := range cases {
errs := ValidateControllerRevisionUpdate(&tc.newHistory, &tc.oldHistory)
if tc.isValid && len(errs) > 0 {
t.Errorf("%v: unexpected error: %v", tc.name, errs)
}
if !tc.isValid && len(errs) == 0 {
t.Errorf("%v: unexpected non-error", tc.name)
}
t.Run(tc.name, func(t *testing.T) {
errs := ValidateControllerRevisionUpdate(&tc.newHistory, &tc.oldHistory)
if tc.isValid && len(errs) > 0 {
t.Errorf("%v: unexpected error: %v", tc.name, errs)
}
if !tc.isValid && len(errs) == 0 {
t.Errorf("%v: unexpected non-error", tc.name)
}
})
}
}

View File

@ -16,7 +16,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was autogenerated by deepcopy-gen. Do not edit it manually!
// Code generated by deepcopy-gen. DO NOT EDIT.
package apps
@ -53,9 +53,8 @@ func (in *ControllerRevision) DeepCopy() *ControllerRevision {
func (in *ControllerRevision) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
} else {
return nil
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
@ -87,9 +86,8 @@ func (in *ControllerRevisionList) DeepCopy() *ControllerRevisionList {
func (in *ControllerRevisionList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
} else {
return nil
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
@ -132,9 +130,8 @@ func (in *StatefulSet) DeepCopy() *StatefulSet {
func (in *StatefulSet) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
} else {
return nil
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
@ -183,9 +180,8 @@ func (in *StatefulSetList) DeepCopy() *StatefulSetList {
func (in *StatefulSetList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
} else {
return nil
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.