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

@ -33,7 +33,6 @@ reviewers:
- yifan-gu
- eparis
- mwielgus
- timothysc
- feiskyer
- soltysh
- piosz

View File

@ -28,7 +28,6 @@ go_library(
go_test(
name = "go_default_xtest",
srcs = ["conversion_test.go"],
importpath = "k8s.io/kubernetes/pkg/apis/abac/v0_test",
deps = [
":go_default_library",
"//pkg/apis/abac:go_default_library",

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 v0
@ -45,7 +45,6 @@ func (in *Policy) DeepCopy() *Policy {
func (in *Policy) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
} else {
return nil
}
return nil
}

View File

@ -30,7 +30,6 @@ go_library(
go_test(
name = "go_default_xtest",
srcs = ["conversion_test.go"],
importpath = "k8s.io/kubernetes/pkg/apis/abac/v1beta1_test",
deps = [
":go_default_library",
"//pkg/apis/abac:go_default_library",

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 conversion-gen. Do not edit it manually!
// Code generated by conversion-gen. DO NOT EDIT.
package v1beta1

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 v1beta1
@ -46,9 +46,8 @@ func (in *Policy) DeepCopy() *Policy {
func (in *Policy) 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.

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

@ -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 abac
@ -46,9 +46,8 @@ func (in *Policy) DeepCopy() *Policy {
func (in *Policy) 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.

View File

@ -16,18 +16,19 @@ 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/admission/v1beta1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
conversion "k8s.io/apimachinery/pkg/conversion"
runtime "k8s.io/apimachinery/pkg/runtime"
types "k8s.io/apimachinery/pkg/types"
admission "k8s.io/kubernetes/pkg/apis/admission"
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

@ -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 admission
@ -132,7 +132,6 @@ func (in *AdmissionReview) DeepCopy() *AdmissionReview {
func (in *AdmissionReview) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
} else {
return nil
}
return nil
}

View File

@ -106,11 +106,9 @@ type Rule struct {
type FailurePolicyType string
const (
// Ignore means the initializer is removed from the initializers list of an
// object if the initializer is timed out.
// Ignore means that an error calling the webhook is ignored.
Ignore FailurePolicyType = "Ignore"
// For 1.7, only "Ignore" is allowed. "Fail" will be allowed when the
// extensible admission feature is beta.
// Fail means that an error calling the webhook causes the admission to fail.
Fail FailurePolicyType = "Fail"
)
@ -195,8 +193,8 @@ type Webhook struct {
// NamespaceSelector decides whether to run the webhook on an object based
// on whether the namespace for that object matches the selector. If the
// object itself is a namespace, the matching is performed on
// object.metadata.labels. If the object is other cluster scoped resource,
// it is not subjected to the webhook.
// object.metadata.labels. If the object is another cluster scoped resource,
// it never skips the webhook.
//
// For example, to run the webhook on any objects whose namespace is not
// associated with "runlevel" of "0" or "1"; you will set the selector as

View File

@ -16,16 +16,17 @@ 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 v1alpha1
import (
unsafe "unsafe"
v1alpha1 "k8s.io/api/admissionregistration/v1alpha1"
conversion "k8s.io/apimachinery/pkg/conversion"
runtime "k8s.io/apimachinery/pkg/runtime"
admissionregistration "k8s.io/kubernetes/pkg/apis/admissionregistration"
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 v1alpha1

View File

@ -16,17 +16,18 @@ 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/admissionregistration/v1beta1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
conversion "k8s.io/apimachinery/pkg/conversion"
runtime "k8s.io/apimachinery/pkg/runtime"
admissionregistration "k8s.io/kubernetes/pkg/apis/admissionregistration"
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

@ -9,8 +9,7 @@ load(
go_test(
name = "go_default_test",
srcs = ["validation_test.go"],
importpath = "k8s.io/kubernetes/pkg/apis/admissionregistration/validation",
library = ":go_default_library",
embed = [":go_default_library"],
deps = [
"//pkg/apis/admissionregistration:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",

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 admissionregistration
@ -77,9 +77,8 @@ func (in *InitializerConfiguration) DeepCopy() *InitializerConfiguration {
func (in *InitializerConfiguration) 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.
@ -111,9 +110,8 @@ func (in *InitializerConfigurationList) DeepCopy() *InitializerConfigurationList
func (in *InitializerConfigurationList) 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.
@ -145,9 +143,8 @@ func (in *MutatingWebhookConfiguration) DeepCopy() *MutatingWebhookConfiguration
func (in *MutatingWebhookConfiguration) 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.
@ -179,9 +176,8 @@ func (in *MutatingWebhookConfigurationList) DeepCopy() *MutatingWebhookConfigura
func (in *MutatingWebhookConfigurationList) 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.
@ -291,9 +287,8 @@ func (in *ValidatingWebhookConfiguration) DeepCopy() *ValidatingWebhookConfigura
func (in *ValidatingWebhookConfiguration) 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.
@ -325,9 +320,8 @@ func (in *ValidatingWebhookConfigurationList) DeepCopy() *ValidatingWebhookConfi
func (in *ValidatingWebhookConfigurationList) 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.

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.

View File

@ -18,6 +18,7 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
],
)

View File

@ -4,7 +4,6 @@ reviewers:
- wojtek-t
- deads2k
- sttts
- timothysc
- mbohlool
- jianhuiz
- enj

View File

@ -45,6 +45,7 @@ var (
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&TokenReview{},
&TokenRequest{},
)
return nil
}

View File

@ -18,6 +18,7 @@ package authentication
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
)
const (
@ -88,3 +89,57 @@ type UserInfo struct {
// ExtraValue masks the value so protobuf can generate
type ExtraValue []string
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// TokenRequest requests a token for a given service account.
type TokenRequest struct {
metav1.TypeMeta
// ObjectMeta fulfills the metav1.ObjectMetaAccessor interface so that the stock
// REST handler paths work
metav1.ObjectMeta
Spec TokenRequestSpec
Status TokenRequestStatus
}
// TokenRequestSpec contains client provided parameters of a token request.
type TokenRequestSpec struct {
// Audiences are the intendend audiences of the token. A recipient of a
// token must identitfy themself with an identifier in the list of
// audiences of the token, and otherwise should reject the token. A
// token issued for multiple audiences may be used to authenticate
// against any of the audiences listed but implies a high degree of
// trust between the target audiences.
Audiences []string
// ExpirationSeconds is the requested duration of validity of the request. The
// token issuer may return a token with a different validity duration so a
// client needs to check the 'expiration' field in a response.
ExpirationSeconds int64
// BoundObjectRef is a reference to an object that the token will be bound to.
// The token will only be valid for as long as the bound objet exists.
BoundObjectRef *BoundObjectReference
}
// TokenRequestStatus is the result of a token request.
type TokenRequestStatus struct {
// Token is the opaque bearer token.
Token string
// ExpirationTimestamp is the time of expiration of the returned token.
ExpirationTimestamp metav1.Time
}
// BoundObjectReference is a reference to an object that a token is bound to.
type BoundObjectReference struct {
// Kind of the referent. Valid kinds are 'Pod' and 'Secret'.
Kind string
// API version of the referent.
APIVersion string
// Name of the referent.
Name string
// UID of the referent.
UID types.UID
}

View File

@ -19,9 +19,11 @@ go_library(
deps = [
"//pkg/apis/authentication:go_default_library",
"//vendor/k8s.io/api/authentication/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/conversion:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
],
)

View File

@ -17,9 +17,17 @@ limitations under the License.
package v1
import (
authenticationv1 "k8s.io/api/authentication/v1"
"k8s.io/apimachinery/pkg/runtime"
)
func addDefaultingFuncs(scheme *runtime.Scheme) error {
return RegisterDefaults(scheme)
}
func SetDefaults_TokenRequestSpec(obj *authenticationv1.TokenRequestSpec) {
if obj.ExpirationSeconds == nil {
hour := int64(60 * 60)
obj.ExpirationSeconds = &hour
}
}

View File

@ -16,16 +16,19 @@ 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/authentication/v1"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
conversion "k8s.io/apimachinery/pkg/conversion"
runtime "k8s.io/apimachinery/pkg/runtime"
types "k8s.io/apimachinery/pkg/types"
authentication "k8s.io/kubernetes/pkg/apis/authentication"
unsafe "unsafe"
)
func init() {
@ -36,6 +39,14 @@ func init() {
// Public to allow building arbitrary schemes.
func RegisterConversions(scheme *runtime.Scheme) error {
return scheme.AddGeneratedConversionFuncs(
Convert_v1_BoundObjectReference_To_authentication_BoundObjectReference,
Convert_authentication_BoundObjectReference_To_v1_BoundObjectReference,
Convert_v1_TokenRequest_To_authentication_TokenRequest,
Convert_authentication_TokenRequest_To_v1_TokenRequest,
Convert_v1_TokenRequestSpec_To_authentication_TokenRequestSpec,
Convert_authentication_TokenRequestSpec_To_v1_TokenRequestSpec,
Convert_v1_TokenRequestStatus_To_authentication_TokenRequestStatus,
Convert_authentication_TokenRequestStatus_To_v1_TokenRequestStatus,
Convert_v1_TokenReview_To_authentication_TokenReview,
Convert_authentication_TokenReview_To_v1_TokenReview,
Convert_v1_TokenReviewSpec_To_authentication_TokenReviewSpec,
@ -47,6 +58,114 @@ func RegisterConversions(scheme *runtime.Scheme) error {
)
}
func autoConvert_v1_BoundObjectReference_To_authentication_BoundObjectReference(in *v1.BoundObjectReference, out *authentication.BoundObjectReference, s conversion.Scope) error {
out.Kind = in.Kind
out.APIVersion = in.APIVersion
out.Name = in.Name
out.UID = types.UID(in.UID)
return nil
}
// Convert_v1_BoundObjectReference_To_authentication_BoundObjectReference is an autogenerated conversion function.
func Convert_v1_BoundObjectReference_To_authentication_BoundObjectReference(in *v1.BoundObjectReference, out *authentication.BoundObjectReference, s conversion.Scope) error {
return autoConvert_v1_BoundObjectReference_To_authentication_BoundObjectReference(in, out, s)
}
func autoConvert_authentication_BoundObjectReference_To_v1_BoundObjectReference(in *authentication.BoundObjectReference, out *v1.BoundObjectReference, s conversion.Scope) error {
out.Kind = in.Kind
out.APIVersion = in.APIVersion
out.Name = in.Name
out.UID = types.UID(in.UID)
return nil
}
// Convert_authentication_BoundObjectReference_To_v1_BoundObjectReference is an autogenerated conversion function.
func Convert_authentication_BoundObjectReference_To_v1_BoundObjectReference(in *authentication.BoundObjectReference, out *v1.BoundObjectReference, s conversion.Scope) error {
return autoConvert_authentication_BoundObjectReference_To_v1_BoundObjectReference(in, out, s)
}
func autoConvert_v1_TokenRequest_To_authentication_TokenRequest(in *v1.TokenRequest, out *authentication.TokenRequest, s conversion.Scope) error {
out.ObjectMeta = in.ObjectMeta
if err := Convert_v1_TokenRequestSpec_To_authentication_TokenRequestSpec(&in.Spec, &out.Spec, s); err != nil {
return err
}
if err := Convert_v1_TokenRequestStatus_To_authentication_TokenRequestStatus(&in.Status, &out.Status, s); err != nil {
return err
}
return nil
}
// Convert_v1_TokenRequest_To_authentication_TokenRequest is an autogenerated conversion function.
func Convert_v1_TokenRequest_To_authentication_TokenRequest(in *v1.TokenRequest, out *authentication.TokenRequest, s conversion.Scope) error {
return autoConvert_v1_TokenRequest_To_authentication_TokenRequest(in, out, s)
}
func autoConvert_authentication_TokenRequest_To_v1_TokenRequest(in *authentication.TokenRequest, out *v1.TokenRequest, s conversion.Scope) error {
out.ObjectMeta = in.ObjectMeta
if err := Convert_authentication_TokenRequestSpec_To_v1_TokenRequestSpec(&in.Spec, &out.Spec, s); err != nil {
return err
}
if err := Convert_authentication_TokenRequestStatus_To_v1_TokenRequestStatus(&in.Status, &out.Status, s); err != nil {
return err
}
return nil
}
// Convert_authentication_TokenRequest_To_v1_TokenRequest is an autogenerated conversion function.
func Convert_authentication_TokenRequest_To_v1_TokenRequest(in *authentication.TokenRequest, out *v1.TokenRequest, s conversion.Scope) error {
return autoConvert_authentication_TokenRequest_To_v1_TokenRequest(in, out, s)
}
func autoConvert_v1_TokenRequestSpec_To_authentication_TokenRequestSpec(in *v1.TokenRequestSpec, out *authentication.TokenRequestSpec, s conversion.Scope) error {
out.Audiences = *(*[]string)(unsafe.Pointer(&in.Audiences))
if err := meta_v1.Convert_Pointer_int64_To_int64(&in.ExpirationSeconds, &out.ExpirationSeconds, s); err != nil {
return err
}
out.BoundObjectRef = (*authentication.BoundObjectReference)(unsafe.Pointer(in.BoundObjectRef))
return nil
}
// Convert_v1_TokenRequestSpec_To_authentication_TokenRequestSpec is an autogenerated conversion function.
func Convert_v1_TokenRequestSpec_To_authentication_TokenRequestSpec(in *v1.TokenRequestSpec, out *authentication.TokenRequestSpec, s conversion.Scope) error {
return autoConvert_v1_TokenRequestSpec_To_authentication_TokenRequestSpec(in, out, s)
}
func autoConvert_authentication_TokenRequestSpec_To_v1_TokenRequestSpec(in *authentication.TokenRequestSpec, out *v1.TokenRequestSpec, s conversion.Scope) error {
out.Audiences = *(*[]string)(unsafe.Pointer(&in.Audiences))
if err := meta_v1.Convert_int64_To_Pointer_int64(&in.ExpirationSeconds, &out.ExpirationSeconds, s); err != nil {
return err
}
out.BoundObjectRef = (*v1.BoundObjectReference)(unsafe.Pointer(in.BoundObjectRef))
return nil
}
// Convert_authentication_TokenRequestSpec_To_v1_TokenRequestSpec is an autogenerated conversion function.
func Convert_authentication_TokenRequestSpec_To_v1_TokenRequestSpec(in *authentication.TokenRequestSpec, out *v1.TokenRequestSpec, s conversion.Scope) error {
return autoConvert_authentication_TokenRequestSpec_To_v1_TokenRequestSpec(in, out, s)
}
func autoConvert_v1_TokenRequestStatus_To_authentication_TokenRequestStatus(in *v1.TokenRequestStatus, out *authentication.TokenRequestStatus, s conversion.Scope) error {
out.Token = in.Token
out.ExpirationTimestamp = in.ExpirationTimestamp
return nil
}
// Convert_v1_TokenRequestStatus_To_authentication_TokenRequestStatus is an autogenerated conversion function.
func Convert_v1_TokenRequestStatus_To_authentication_TokenRequestStatus(in *v1.TokenRequestStatus, out *authentication.TokenRequestStatus, s conversion.Scope) error {
return autoConvert_v1_TokenRequestStatus_To_authentication_TokenRequestStatus(in, out, s)
}
func autoConvert_authentication_TokenRequestStatus_To_v1_TokenRequestStatus(in *authentication.TokenRequestStatus, out *v1.TokenRequestStatus, s conversion.Scope) error {
out.Token = in.Token
out.ExpirationTimestamp = in.ExpirationTimestamp
return nil
}
// Convert_authentication_TokenRequestStatus_To_v1_TokenRequestStatus is an autogenerated conversion function.
func Convert_authentication_TokenRequestStatus_To_v1_TokenRequestStatus(in *authentication.TokenRequestStatus, out *v1.TokenRequestStatus, s conversion.Scope) error {
return autoConvert_authentication_TokenRequestStatus_To_v1_TokenRequestStatus(in, out, s)
}
func autoConvert_v1_TokenReview_To_authentication_TokenReview(in *v1.TokenReview, out *authentication.TokenReview, s conversion.Scope) error {
out.ObjectMeta = in.ObjectMeta
if err := Convert_v1_TokenReviewSpec_To_authentication_TokenReviewSpec(&in.Spec, &out.Spec, s); err != nil {

View File

@ -16,11 +16,12 @@ 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
import (
v1 "k8s.io/api/authentication/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
)
@ -28,5 +29,10 @@ import (
// Public to allow building arbitrary schemes.
// All generated defaulters are covering - they call all nested defaulters.
func RegisterDefaults(scheme *runtime.Scheme) error {
scheme.AddTypeDefaultingFunc(&v1.TokenRequest{}, func(obj interface{}) { SetObjectDefaults_TokenRequest(obj.(*v1.TokenRequest)) })
return nil
}
func SetObjectDefaults_TokenRequest(in *v1.TokenRequest) {
SetDefaults_TokenRequestSpec(&in.Spec)
}

View File

@ -16,16 +16,17 @@ 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/authentication/v1beta1"
conversion "k8s.io/apimachinery/pkg/conversion"
runtime "k8s.io/apimachinery/pkg/runtime"
authentication "k8s.io/kubernetes/pkg/apis/authentication"
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

@ -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 authentication
@ -24,6 +24,117 @@ import (
runtime "k8s.io/apimachinery/pkg/runtime"
)
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *BoundObjectReference) DeepCopyInto(out *BoundObjectReference) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BoundObjectReference.
func (in *BoundObjectReference) DeepCopy() *BoundObjectReference {
if in == nil {
return nil
}
out := new(BoundObjectReference)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in ExtraValue) DeepCopyInto(out *ExtraValue) {
{
in := &in
*out = make(ExtraValue, len(*in))
copy(*out, *in)
return
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExtraValue.
func (in ExtraValue) DeepCopy() ExtraValue {
if in == nil {
return nil
}
out := new(ExtraValue)
in.DeepCopyInto(out)
return *out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *TokenRequest) DeepCopyInto(out *TokenRequest) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
in.Status.DeepCopyInto(&out.Status)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TokenRequest.
func (in *TokenRequest) DeepCopy() *TokenRequest {
if in == nil {
return nil
}
out := new(TokenRequest)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *TokenRequest) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *TokenRequestSpec) DeepCopyInto(out *TokenRequestSpec) {
*out = *in
if in.Audiences != nil {
in, out := &in.Audiences, &out.Audiences
*out = make([]string, len(*in))
copy(*out, *in)
}
if in.BoundObjectRef != nil {
in, out := &in.BoundObjectRef, &out.BoundObjectRef
if *in == nil {
*out = nil
} else {
*out = new(BoundObjectReference)
**out = **in
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TokenRequestSpec.
func (in *TokenRequestSpec) DeepCopy() *TokenRequestSpec {
if in == nil {
return nil
}
out := new(TokenRequestSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *TokenRequestStatus) DeepCopyInto(out *TokenRequestStatus) {
*out = *in
in.ExpirationTimestamp.DeepCopyInto(&out.ExpirationTimestamp)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TokenRequestStatus.
func (in *TokenRequestStatus) DeepCopy() *TokenRequestStatus {
if in == nil {
return nil
}
out := new(TokenRequestStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *TokenReview) DeepCopyInto(out *TokenReview) {
*out = *in
@ -48,9 +159,8 @@ func (in *TokenReview) DeepCopy() *TokenReview {
func (in *TokenReview) 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.
@ -98,8 +208,12 @@ func (in *UserInfo) DeepCopyInto(out *UserInfo) {
in, out := &in.Extra, &out.Extra
*out = make(map[string]ExtraValue, len(*in))
for key, val := range *in {
(*out)[key] = make(ExtraValue, len(val))
copy((*out)[key], val)
if val == nil {
(*out)[key] = nil
} else {
(*out)[key] = make([]string, len(val))
copy((*out)[key], val)
}
}
}
return

View File

@ -9,7 +9,6 @@ reviewers:
- erictune
- sttts
- ncdc
- timothysc
- dims
- mml
- mbohlool

View File

@ -16,16 +16,17 @@ 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/authorization/v1"
conversion "k8s.io/apimachinery/pkg/conversion"
runtime "k8s.io/apimachinery/pkg/runtime"
authorization "k8s.io/kubernetes/pkg/apis/authorization"
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 v1

View File

@ -16,16 +16,17 @@ 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/authorization/v1beta1"
conversion "k8s.io/apimachinery/pkg/conversion"
runtime "k8s.io/apimachinery/pkg/runtime"
authorization "k8s.io/kubernetes/pkg/apis/authorization"
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

@ -21,8 +21,7 @@ go_library(
go_test(
name = "go_default_test",
srcs = ["validation_test.go"],
importpath = "k8s.io/kubernetes/pkg/apis/authorization/validation",
library = ":go_default_library",
embed = [":go_default_library"],
deps = [
"//pkg/apis/authorization:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",

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 authorization
@ -24,6 +24,26 @@ import (
runtime "k8s.io/apimachinery/pkg/runtime"
)
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in ExtraValue) DeepCopyInto(out *ExtraValue) {
{
in := &in
*out = make(ExtraValue, len(*in))
copy(*out, *in)
return
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExtraValue.
func (in ExtraValue) DeepCopy() ExtraValue {
if in == nil {
return nil
}
out := new(ExtraValue)
in.DeepCopyInto(out)
return *out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *LocalSubjectAccessReview) DeepCopyInto(out *LocalSubjectAccessReview) {
*out = *in
@ -48,9 +68,8 @@ func (in *LocalSubjectAccessReview) DeepCopy() *LocalSubjectAccessReview {
func (in *LocalSubjectAccessReview) 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.
@ -171,9 +190,8 @@ func (in *SelfSubjectAccessReview) DeepCopy() *SelfSubjectAccessReview {
func (in *SelfSubjectAccessReview) 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.
@ -234,9 +252,8 @@ func (in *SelfSubjectRulesReview) DeepCopy() *SelfSubjectRulesReview {
func (in *SelfSubjectRulesReview) 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.
@ -279,9 +296,8 @@ func (in *SubjectAccessReview) DeepCopy() *SubjectAccessReview {
func (in *SubjectAccessReview) 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.
@ -314,8 +330,12 @@ func (in *SubjectAccessReviewSpec) DeepCopyInto(out *SubjectAccessReviewSpec) {
in, out := &in.Extra, &out.Extra
*out = make(map[string]ExtraValue, len(*in))
for key, val := range *in {
(*out)[key] = make(ExtraValue, len(val))
copy((*out)[key], val)
if val == nil {
(*out)[key] = nil
} else {
(*out)[key] = make([]string, len(val))
copy((*out)[key], val)
}
}
}
return

View File

@ -8,7 +8,6 @@ reviewers:
- erictune
- sttts
- ncdc
- timothysc
- piosz
- dims
- errordeveloper

View File

@ -111,12 +111,19 @@ var (
// Kubernetes, and have special scaling options on top of those available
// to normal per-pod metrics (the "pods" source).
ResourceMetricSourceType MetricSourceType = "Resource"
// ExternalMetricSourceType is a global metric that is not associated
// with any Kubernetes object. It allows autoscaling based on information
// coming from components running outside of cluster
// (for example length of queue in cloud messaging service, or
// QPS from loadbalancer running outside of cluster).
ExternalMetricSourceType MetricSourceType = "External"
)
// MetricSpec specifies how to scale based on a single metric
// (only `type` and one other matching field should be set at once).
type MetricSpec struct {
// Type is the type of metric source. It should match one of the fields below.
// Type is the type of metric source. It should be one of "Object",
// "Pods" or "Resource", each mapping to a matching field in the object.
Type MetricSourceType
// Object refers to a metric describing a single kubernetes object
@ -135,6 +142,13 @@ type MetricSpec struct {
// to normal per-pod metrics using the "pods" source.
// +optional
Resource *ResourceMetricSource
// External refers to a global metric that is not associated
// with any Kubernetes object. It allows autoscaling based on information
// coming from components running outside of cluster
// (for example length of queue in cloud messaging service, or
// QPS from loadbalancer running outside of cluster).
// +optional
External *ExternalMetricSource
}
// ObjectMetricSource indicates how to scale on a metric describing a
@ -183,6 +197,26 @@ type ResourceMetricSource struct {
TargetAverageValue *resource.Quantity
}
// ExternalMetricSource indicates how to scale on a metric not associated with
// any Kubernetes object (for example length of queue in cloud
// messaging service, or QPS from loadbalancer running outside of cluster).
type ExternalMetricSource struct {
// metricName is the name of the metric in question.
MetricName string
// MetricSelector is used to identify a specific time series
// within a given metric.
// +optional
MetricSelector *metav1.LabelSelector
// TargetValue is the target value of the metric (as a quantity).
// Mutually exclusive with TargetAverageValue.
// +optional
TargetValue *resource.Quantity
// TargetAverageValue is the target per-pod value of global metric (as a quantity).
// Mutually exclusive with TargetValue.
// +optional
TargetAverageValue *resource.Quantity
}
// HorizontalPodAutoscalerStatus describes the current status of a horizontal pod autoscaler.
type HorizontalPodAutoscalerStatus struct {
// ObservedGeneration is the most recent generation observed by this autoscaler.
@ -261,7 +295,8 @@ type HorizontalPodAutoscalerCondition struct {
// MetricStatus describes the last-read state of a single metric.
type MetricStatus struct {
// Type is the type of metric source. It will match one of the fields below.
// Type is the type of metric source. It will be one of "Object",
// "Pods" or "Resource", each corresponds to a matching field in the object.
Type MetricSourceType
// Object refers to a metric describing a single kubernetes object
@ -280,6 +315,13 @@ type MetricStatus struct {
// to normal per-pod metrics using the "pods" source.
// +optional
Resource *ResourceMetricStatus
// External refers to a global metric that is not associated
// with any Kubernetes object. It allows autoscaling based on information
// coming from components running outside of cluster
// (for example length of queue in cloud messaging service, or
// QPS from loadbalancer running outside of cluster).
// +optional
External *ExternalMetricStatus
}
// ObjectMetricStatus indicates the current value of a metric describing a
@ -326,6 +368,23 @@ type ResourceMetricStatus struct {
CurrentAverageValue resource.Quantity
}
// ExternalMetricStatus indicates the current value of a global metric
// not associated with any Kubernetes object.
type ExternalMetricStatus struct {
// MetricName is the name of a metric used for autoscaling in
// metric system.
MetricName string
// MetricSelector is used to identify a specific time series
// within a given metric.
// +optional
MetricSelector *metav1.LabelSelector
// CurrentValue is the current value of the metric (as a quantity)
CurrentValue resource.Quantity
// CurrentAverageValue is the current value of metric averaged over autoscaled pods.
// +optional
CurrentAverageValue *resource.Quantity
}
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

View File

@ -33,12 +33,12 @@ go_library(
go_test(
name = "go_default_xtest",
srcs = ["defaults_test.go"],
importpath = "k8s.io/kubernetes/pkg/apis/autoscaling/v1_test",
deps = [
":go_default_library",
"//pkg/api/legacyscheme:go_default_library",
"//pkg/apis/autoscaling/install:go_default_library",
"//pkg/apis/core/install:go_default_library",
"//pkg/util/pointer:go_default_library",
"//vendor/k8s.io/api/autoscaling/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
],

View File

@ -27,6 +27,7 @@ import (
_ "k8s.io/kubernetes/pkg/apis/autoscaling/install"
. "k8s.io/kubernetes/pkg/apis/autoscaling/v1"
_ "k8s.io/kubernetes/pkg/apis/core/install"
utilpointer "k8s.io/kubernetes/pkg/util/pointer"
)
func TestSetDefaultHPA(t *testing.T) {
@ -43,7 +44,7 @@ func TestSetDefaultHPA(t *testing.T) {
{
hpa: autoscalingv1.HorizontalPodAutoscaler{
Spec: autoscalingv1.HorizontalPodAutoscalerSpec{
MinReplicas: newInt32(3),
MinReplicas: utilpointer.Int32Ptr(3),
},
},
expectReplicas: 3,
@ -85,9 +86,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/autoscaling/v1"
core_v1 "k8s.io/api/core/v1"
resource "k8s.io/apimachinery/pkg/api/resource"
@ -29,7 +31,6 @@ import (
runtime "k8s.io/apimachinery/pkg/runtime"
autoscaling "k8s.io/kubernetes/pkg/apis/autoscaling"
core "k8s.io/kubernetes/pkg/apis/core"
unsafe "unsafe"
)
func init() {
@ -42,6 +43,10 @@ func RegisterConversions(scheme *runtime.Scheme) error {
return scheme.AddGeneratedConversionFuncs(
Convert_v1_CrossVersionObjectReference_To_autoscaling_CrossVersionObjectReference,
Convert_autoscaling_CrossVersionObjectReference_To_v1_CrossVersionObjectReference,
Convert_v1_ExternalMetricSource_To_autoscaling_ExternalMetricSource,
Convert_autoscaling_ExternalMetricSource_To_v1_ExternalMetricSource,
Convert_v1_ExternalMetricStatus_To_autoscaling_ExternalMetricStatus,
Convert_autoscaling_ExternalMetricStatus_To_v1_ExternalMetricStatus,
Convert_v1_HorizontalPodAutoscaler_To_autoscaling_HorizontalPodAutoscaler,
Convert_autoscaling_HorizontalPodAutoscaler_To_v1_HorizontalPodAutoscaler,
Convert_v1_HorizontalPodAutoscalerCondition_To_autoscaling_HorizontalPodAutoscalerCondition,
@ -101,6 +106,58 @@ func Convert_autoscaling_CrossVersionObjectReference_To_v1_CrossVersionObjectRef
return autoConvert_autoscaling_CrossVersionObjectReference_To_v1_CrossVersionObjectReference(in, out, s)
}
func autoConvert_v1_ExternalMetricSource_To_autoscaling_ExternalMetricSource(in *v1.ExternalMetricSource, out *autoscaling.ExternalMetricSource, s conversion.Scope) error {
out.MetricName = in.MetricName
out.MetricSelector = (*meta_v1.LabelSelector)(unsafe.Pointer(in.MetricSelector))
out.TargetValue = (*resource.Quantity)(unsafe.Pointer(in.TargetValue))
out.TargetAverageValue = (*resource.Quantity)(unsafe.Pointer(in.TargetAverageValue))
return nil
}
// Convert_v1_ExternalMetricSource_To_autoscaling_ExternalMetricSource is an autogenerated conversion function.
func Convert_v1_ExternalMetricSource_To_autoscaling_ExternalMetricSource(in *v1.ExternalMetricSource, out *autoscaling.ExternalMetricSource, s conversion.Scope) error {
return autoConvert_v1_ExternalMetricSource_To_autoscaling_ExternalMetricSource(in, out, s)
}
func autoConvert_autoscaling_ExternalMetricSource_To_v1_ExternalMetricSource(in *autoscaling.ExternalMetricSource, out *v1.ExternalMetricSource, s conversion.Scope) error {
out.MetricName = in.MetricName
out.MetricSelector = (*meta_v1.LabelSelector)(unsafe.Pointer(in.MetricSelector))
out.TargetValue = (*resource.Quantity)(unsafe.Pointer(in.TargetValue))
out.TargetAverageValue = (*resource.Quantity)(unsafe.Pointer(in.TargetAverageValue))
return nil
}
// Convert_autoscaling_ExternalMetricSource_To_v1_ExternalMetricSource is an autogenerated conversion function.
func Convert_autoscaling_ExternalMetricSource_To_v1_ExternalMetricSource(in *autoscaling.ExternalMetricSource, out *v1.ExternalMetricSource, s conversion.Scope) error {
return autoConvert_autoscaling_ExternalMetricSource_To_v1_ExternalMetricSource(in, out, s)
}
func autoConvert_v1_ExternalMetricStatus_To_autoscaling_ExternalMetricStatus(in *v1.ExternalMetricStatus, out *autoscaling.ExternalMetricStatus, s conversion.Scope) error {
out.MetricName = in.MetricName
out.MetricSelector = (*meta_v1.LabelSelector)(unsafe.Pointer(in.MetricSelector))
out.CurrentValue = in.CurrentValue
out.CurrentAverageValue = (*resource.Quantity)(unsafe.Pointer(in.CurrentAverageValue))
return nil
}
// Convert_v1_ExternalMetricStatus_To_autoscaling_ExternalMetricStatus is an autogenerated conversion function.
func Convert_v1_ExternalMetricStatus_To_autoscaling_ExternalMetricStatus(in *v1.ExternalMetricStatus, out *autoscaling.ExternalMetricStatus, s conversion.Scope) error {
return autoConvert_v1_ExternalMetricStatus_To_autoscaling_ExternalMetricStatus(in, out, s)
}
func autoConvert_autoscaling_ExternalMetricStatus_To_v1_ExternalMetricStatus(in *autoscaling.ExternalMetricStatus, out *v1.ExternalMetricStatus, s conversion.Scope) error {
out.MetricName = in.MetricName
out.MetricSelector = (*meta_v1.LabelSelector)(unsafe.Pointer(in.MetricSelector))
out.CurrentValue = in.CurrentValue
out.CurrentAverageValue = (*resource.Quantity)(unsafe.Pointer(in.CurrentAverageValue))
return nil
}
// Convert_autoscaling_ExternalMetricStatus_To_v1_ExternalMetricStatus is an autogenerated conversion function.
func Convert_autoscaling_ExternalMetricStatus_To_v1_ExternalMetricStatus(in *autoscaling.ExternalMetricStatus, out *v1.ExternalMetricStatus, s conversion.Scope) error {
return autoConvert_autoscaling_ExternalMetricStatus_To_v1_ExternalMetricStatus(in, out, s)
}
func autoConvert_v1_HorizontalPodAutoscaler_To_autoscaling_HorizontalPodAutoscaler(in *v1.HorizontalPodAutoscaler, out *autoscaling.HorizontalPodAutoscaler, s conversion.Scope) error {
out.ObjectMeta = in.ObjectMeta
if err := Convert_v1_HorizontalPodAutoscalerSpec_To_autoscaling_HorizontalPodAutoscalerSpec(&in.Spec, &out.Spec, s); err != nil {
@ -237,6 +294,7 @@ func autoConvert_v1_MetricSpec_To_autoscaling_MetricSpec(in *v1.MetricSpec, out
out.Object = (*autoscaling.ObjectMetricSource)(unsafe.Pointer(in.Object))
out.Pods = (*autoscaling.PodsMetricSource)(unsafe.Pointer(in.Pods))
out.Resource = (*autoscaling.ResourceMetricSource)(unsafe.Pointer(in.Resource))
out.External = (*autoscaling.ExternalMetricSource)(unsafe.Pointer(in.External))
return nil
}
@ -250,6 +308,7 @@ func autoConvert_autoscaling_MetricSpec_To_v1_MetricSpec(in *autoscaling.MetricS
out.Object = (*v1.ObjectMetricSource)(unsafe.Pointer(in.Object))
out.Pods = (*v1.PodsMetricSource)(unsafe.Pointer(in.Pods))
out.Resource = (*v1.ResourceMetricSource)(unsafe.Pointer(in.Resource))
out.External = (*v1.ExternalMetricSource)(unsafe.Pointer(in.External))
return nil
}
@ -263,6 +322,7 @@ func autoConvert_v1_MetricStatus_To_autoscaling_MetricStatus(in *v1.MetricStatus
out.Object = (*autoscaling.ObjectMetricStatus)(unsafe.Pointer(in.Object))
out.Pods = (*autoscaling.PodsMetricStatus)(unsafe.Pointer(in.Pods))
out.Resource = (*autoscaling.ResourceMetricStatus)(unsafe.Pointer(in.Resource))
out.External = (*autoscaling.ExternalMetricStatus)(unsafe.Pointer(in.External))
return nil
}
@ -276,6 +336,7 @@ func autoConvert_autoscaling_MetricStatus_To_v1_MetricStatus(in *autoscaling.Met
out.Object = (*v1.ObjectMetricStatus)(unsafe.Pointer(in.Object))
out.Pods = (*v1.PodsMetricStatus)(unsafe.Pointer(in.Pods))
out.Resource = (*v1.ResourceMetricStatus)(unsafe.Pointer(in.Resource))
out.External = (*v1.ExternalMetricStatus)(unsafe.Pointer(in.External))
return nil
}

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

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

View File

@ -29,11 +29,12 @@ import (
_ "k8s.io/kubernetes/pkg/apis/autoscaling/install"
. "k8s.io/kubernetes/pkg/apis/autoscaling/v2beta1"
_ "k8s.io/kubernetes/pkg/apis/core/install"
utilpointer "k8s.io/kubernetes/pkg/util/pointer"
)
func TestSetDefaultHPA(t *testing.T) {
utilizationDefaultVal := int32(autoscaling.DefaultCPUUtilization)
defaultReplicas := newInt32(1)
defaultReplicas := utilpointer.Int32Ptr(1)
defaultTemplate := []autoscalingv2beta1.MetricSpec{
{
Type: autoscalingv2beta1.ResourceMetricSourceType,
@ -64,13 +65,13 @@ func TestSetDefaultHPA(t *testing.T) {
{ // MinReplicas update
original: &autoscalingv2beta1.HorizontalPodAutoscaler{
Spec: autoscalingv2beta1.HorizontalPodAutoscalerSpec{
MinReplicas: newInt32(3),
MinReplicas: utilpointer.Int32Ptr(3),
Metrics: defaultTemplate,
},
},
expected: &autoscalingv2beta1.HorizontalPodAutoscaler{
Spec: autoscalingv2beta1.HorizontalPodAutoscalerSpec{
MinReplicas: newInt32(3),
MinReplicas: utilpointer.Int32Ptr(3),
Metrics: defaultTemplate,
},
},
@ -123,9 +124,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,20 +16,21 @@ 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 v2beta1
import (
unsafe "unsafe"
v2beta1 "k8s.io/api/autoscaling/v2beta1"
v1 "k8s.io/api/core/v1"
core_v1 "k8s.io/api/core/v1"
resource "k8s.io/apimachinery/pkg/api/resource"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
conversion "k8s.io/apimachinery/pkg/conversion"
runtime "k8s.io/apimachinery/pkg/runtime"
autoscaling "k8s.io/kubernetes/pkg/apis/autoscaling"
core "k8s.io/kubernetes/pkg/apis/core"
unsafe "unsafe"
)
func init() {
@ -42,6 +43,10 @@ func RegisterConversions(scheme *runtime.Scheme) error {
return scheme.AddGeneratedConversionFuncs(
Convert_v2beta1_CrossVersionObjectReference_To_autoscaling_CrossVersionObjectReference,
Convert_autoscaling_CrossVersionObjectReference_To_v2beta1_CrossVersionObjectReference,
Convert_v2beta1_ExternalMetricSource_To_autoscaling_ExternalMetricSource,
Convert_autoscaling_ExternalMetricSource_To_v2beta1_ExternalMetricSource,
Convert_v2beta1_ExternalMetricStatus_To_autoscaling_ExternalMetricStatus,
Convert_autoscaling_ExternalMetricStatus_To_v2beta1_ExternalMetricStatus,
Convert_v2beta1_HorizontalPodAutoscaler_To_autoscaling_HorizontalPodAutoscaler,
Convert_autoscaling_HorizontalPodAutoscaler_To_v2beta1_HorizontalPodAutoscaler,
Convert_v2beta1_HorizontalPodAutoscalerCondition_To_autoscaling_HorizontalPodAutoscalerCondition,
@ -95,6 +100,58 @@ func Convert_autoscaling_CrossVersionObjectReference_To_v2beta1_CrossVersionObje
return autoConvert_autoscaling_CrossVersionObjectReference_To_v2beta1_CrossVersionObjectReference(in, out, s)
}
func autoConvert_v2beta1_ExternalMetricSource_To_autoscaling_ExternalMetricSource(in *v2beta1.ExternalMetricSource, out *autoscaling.ExternalMetricSource, s conversion.Scope) error {
out.MetricName = in.MetricName
out.MetricSelector = (*v1.LabelSelector)(unsafe.Pointer(in.MetricSelector))
out.TargetValue = (*resource.Quantity)(unsafe.Pointer(in.TargetValue))
out.TargetAverageValue = (*resource.Quantity)(unsafe.Pointer(in.TargetAverageValue))
return nil
}
// Convert_v2beta1_ExternalMetricSource_To_autoscaling_ExternalMetricSource is an autogenerated conversion function.
func Convert_v2beta1_ExternalMetricSource_To_autoscaling_ExternalMetricSource(in *v2beta1.ExternalMetricSource, out *autoscaling.ExternalMetricSource, s conversion.Scope) error {
return autoConvert_v2beta1_ExternalMetricSource_To_autoscaling_ExternalMetricSource(in, out, s)
}
func autoConvert_autoscaling_ExternalMetricSource_To_v2beta1_ExternalMetricSource(in *autoscaling.ExternalMetricSource, out *v2beta1.ExternalMetricSource, s conversion.Scope) error {
out.MetricName = in.MetricName
out.MetricSelector = (*v1.LabelSelector)(unsafe.Pointer(in.MetricSelector))
out.TargetValue = (*resource.Quantity)(unsafe.Pointer(in.TargetValue))
out.TargetAverageValue = (*resource.Quantity)(unsafe.Pointer(in.TargetAverageValue))
return nil
}
// Convert_autoscaling_ExternalMetricSource_To_v2beta1_ExternalMetricSource is an autogenerated conversion function.
func Convert_autoscaling_ExternalMetricSource_To_v2beta1_ExternalMetricSource(in *autoscaling.ExternalMetricSource, out *v2beta1.ExternalMetricSource, s conversion.Scope) error {
return autoConvert_autoscaling_ExternalMetricSource_To_v2beta1_ExternalMetricSource(in, out, s)
}
func autoConvert_v2beta1_ExternalMetricStatus_To_autoscaling_ExternalMetricStatus(in *v2beta1.ExternalMetricStatus, out *autoscaling.ExternalMetricStatus, s conversion.Scope) error {
out.MetricName = in.MetricName
out.MetricSelector = (*v1.LabelSelector)(unsafe.Pointer(in.MetricSelector))
out.CurrentValue = in.CurrentValue
out.CurrentAverageValue = (*resource.Quantity)(unsafe.Pointer(in.CurrentAverageValue))
return nil
}
// Convert_v2beta1_ExternalMetricStatus_To_autoscaling_ExternalMetricStatus is an autogenerated conversion function.
func Convert_v2beta1_ExternalMetricStatus_To_autoscaling_ExternalMetricStatus(in *v2beta1.ExternalMetricStatus, out *autoscaling.ExternalMetricStatus, s conversion.Scope) error {
return autoConvert_v2beta1_ExternalMetricStatus_To_autoscaling_ExternalMetricStatus(in, out, s)
}
func autoConvert_autoscaling_ExternalMetricStatus_To_v2beta1_ExternalMetricStatus(in *autoscaling.ExternalMetricStatus, out *v2beta1.ExternalMetricStatus, s conversion.Scope) error {
out.MetricName = in.MetricName
out.MetricSelector = (*v1.LabelSelector)(unsafe.Pointer(in.MetricSelector))
out.CurrentValue = in.CurrentValue
out.CurrentAverageValue = (*resource.Quantity)(unsafe.Pointer(in.CurrentAverageValue))
return nil
}
// Convert_autoscaling_ExternalMetricStatus_To_v2beta1_ExternalMetricStatus is an autogenerated conversion function.
func Convert_autoscaling_ExternalMetricStatus_To_v2beta1_ExternalMetricStatus(in *autoscaling.ExternalMetricStatus, out *v2beta1.ExternalMetricStatus, s conversion.Scope) error {
return autoConvert_autoscaling_ExternalMetricStatus_To_v2beta1_ExternalMetricStatus(in, out, s)
}
func autoConvert_v2beta1_HorizontalPodAutoscaler_To_autoscaling_HorizontalPodAutoscaler(in *v2beta1.HorizontalPodAutoscaler, out *autoscaling.HorizontalPodAutoscaler, s conversion.Scope) error {
out.ObjectMeta = in.ObjectMeta
if err := Convert_v2beta1_HorizontalPodAutoscalerSpec_To_autoscaling_HorizontalPodAutoscalerSpec(&in.Spec, &out.Spec, s); err != nil {
@ -143,7 +200,7 @@ func Convert_v2beta1_HorizontalPodAutoscalerCondition_To_autoscaling_HorizontalP
func autoConvert_autoscaling_HorizontalPodAutoscalerCondition_To_v2beta1_HorizontalPodAutoscalerCondition(in *autoscaling.HorizontalPodAutoscalerCondition, out *v2beta1.HorizontalPodAutoscalerCondition, s conversion.Scope) error {
out.Type = v2beta1.HorizontalPodAutoscalerConditionType(in.Type)
out.Status = v1.ConditionStatus(in.Status)
out.Status = core_v1.ConditionStatus(in.Status)
out.LastTransitionTime = in.LastTransitionTime
out.Reason = in.Reason
out.Message = in.Message
@ -209,7 +266,7 @@ func Convert_autoscaling_HorizontalPodAutoscalerSpec_To_v2beta1_HorizontalPodAut
func autoConvert_v2beta1_HorizontalPodAutoscalerStatus_To_autoscaling_HorizontalPodAutoscalerStatus(in *v2beta1.HorizontalPodAutoscalerStatus, out *autoscaling.HorizontalPodAutoscalerStatus, s conversion.Scope) error {
out.ObservedGeneration = (*int64)(unsafe.Pointer(in.ObservedGeneration))
out.LastScaleTime = (*meta_v1.Time)(unsafe.Pointer(in.LastScaleTime))
out.LastScaleTime = (*v1.Time)(unsafe.Pointer(in.LastScaleTime))
out.CurrentReplicas = in.CurrentReplicas
out.DesiredReplicas = in.DesiredReplicas
out.CurrentMetrics = *(*[]autoscaling.MetricStatus)(unsafe.Pointer(&in.CurrentMetrics))
@ -224,7 +281,7 @@ func Convert_v2beta1_HorizontalPodAutoscalerStatus_To_autoscaling_HorizontalPodA
func autoConvert_autoscaling_HorizontalPodAutoscalerStatus_To_v2beta1_HorizontalPodAutoscalerStatus(in *autoscaling.HorizontalPodAutoscalerStatus, out *v2beta1.HorizontalPodAutoscalerStatus, s conversion.Scope) error {
out.ObservedGeneration = (*int64)(unsafe.Pointer(in.ObservedGeneration))
out.LastScaleTime = (*meta_v1.Time)(unsafe.Pointer(in.LastScaleTime))
out.LastScaleTime = (*v1.Time)(unsafe.Pointer(in.LastScaleTime))
out.CurrentReplicas = in.CurrentReplicas
out.DesiredReplicas = in.DesiredReplicas
out.CurrentMetrics = *(*[]v2beta1.MetricStatus)(unsafe.Pointer(&in.CurrentMetrics))
@ -242,6 +299,7 @@ func autoConvert_v2beta1_MetricSpec_To_autoscaling_MetricSpec(in *v2beta1.Metric
out.Object = (*autoscaling.ObjectMetricSource)(unsafe.Pointer(in.Object))
out.Pods = (*autoscaling.PodsMetricSource)(unsafe.Pointer(in.Pods))
out.Resource = (*autoscaling.ResourceMetricSource)(unsafe.Pointer(in.Resource))
out.External = (*autoscaling.ExternalMetricSource)(unsafe.Pointer(in.External))
return nil
}
@ -255,6 +313,7 @@ func autoConvert_autoscaling_MetricSpec_To_v2beta1_MetricSpec(in *autoscaling.Me
out.Object = (*v2beta1.ObjectMetricSource)(unsafe.Pointer(in.Object))
out.Pods = (*v2beta1.PodsMetricSource)(unsafe.Pointer(in.Pods))
out.Resource = (*v2beta1.ResourceMetricSource)(unsafe.Pointer(in.Resource))
out.External = (*v2beta1.ExternalMetricSource)(unsafe.Pointer(in.External))
return nil
}
@ -268,6 +327,7 @@ func autoConvert_v2beta1_MetricStatus_To_autoscaling_MetricStatus(in *v2beta1.Me
out.Object = (*autoscaling.ObjectMetricStatus)(unsafe.Pointer(in.Object))
out.Pods = (*autoscaling.PodsMetricStatus)(unsafe.Pointer(in.Pods))
out.Resource = (*autoscaling.ResourceMetricStatus)(unsafe.Pointer(in.Resource))
out.External = (*autoscaling.ExternalMetricStatus)(unsafe.Pointer(in.External))
return nil
}
@ -281,6 +341,7 @@ func autoConvert_autoscaling_MetricStatus_To_v2beta1_MetricStatus(in *autoscalin
out.Object = (*v2beta1.ObjectMetricStatus)(unsafe.Pointer(in.Object))
out.Pods = (*v2beta1.PodsMetricStatus)(unsafe.Pointer(in.Pods))
out.Resource = (*v2beta1.ResourceMetricStatus)(unsafe.Pointer(in.Resource))
out.External = (*v2beta1.ExternalMetricStatus)(unsafe.Pointer(in.External))
return nil
}
@ -402,7 +463,7 @@ func Convert_v2beta1_ResourceMetricSource_To_autoscaling_ResourceMetricSource(in
}
func autoConvert_autoscaling_ResourceMetricSource_To_v2beta1_ResourceMetricSource(in *autoscaling.ResourceMetricSource, out *v2beta1.ResourceMetricSource, s conversion.Scope) error {
out.Name = v1.ResourceName(in.Name)
out.Name = core_v1.ResourceName(in.Name)
out.TargetAverageUtilization = (*int32)(unsafe.Pointer(in.TargetAverageUtilization))
out.TargetAverageValue = (*resource.Quantity)(unsafe.Pointer(in.TargetAverageValue))
return nil
@ -426,7 +487,7 @@ func Convert_v2beta1_ResourceMetricStatus_To_autoscaling_ResourceMetricStatus(in
}
func autoConvert_autoscaling_ResourceMetricStatus_To_v2beta1_ResourceMetricStatus(in *autoscaling.ResourceMetricStatus, out *v2beta1.ResourceMetricStatus, s conversion.Scope) error {
out.Name = v1.ResourceName(in.Name)
out.Name = core_v1.ResourceName(in.Name)
out.CurrentAverageUtilization = (*int32)(unsafe.Pointer(in.CurrentAverageUtilization))
out.CurrentAverageValue = in.CurrentAverageValue
return nil

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 v2beta1

View File

@ -22,11 +22,11 @@ go_library(
go_test(
name = "go_default_test",
srcs = ["validation_test.go"],
importpath = "k8s.io/kubernetes/pkg/apis/autoscaling/validation",
library = ":go_default_library",
embed = [":go_default_library"],
deps = [
"//pkg/apis/autoscaling:go_default_library",
"//pkg/apis/core:go_default_library",
"//pkg/util/pointer:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/resource:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
],

View File

@ -115,7 +115,7 @@ func validateMetrics(metrics []autoscaling.MetricSpec, fldPath *field.Path) fiel
return allErrs
}
var validMetricSourceTypes = sets.NewString(string(autoscaling.ObjectMetricSourceType), string(autoscaling.PodsMetricSourceType), string(autoscaling.ResourceMetricSourceType))
var validMetricSourceTypes = sets.NewString(string(autoscaling.ObjectMetricSourceType), string(autoscaling.PodsMetricSourceType), string(autoscaling.ResourceMetricSourceType), string(autoscaling.ExternalMetricSourceType))
var validMetricSourceTypesList = validMetricSourceTypes.List()
func validateMetricSpec(spec autoscaling.MetricSpec, fldPath *field.Path) field.ErrorList {
@ -137,6 +137,13 @@ func validateMetricSpec(spec autoscaling.MetricSpec, fldPath *field.Path) field.
}
}
if spec.External != nil {
typesPresent.Insert("external")
if typesPresent.Len() == 1 {
allErrs = append(allErrs, validateExternalSource(spec.External, fldPath.Child("external"))...)
}
}
if spec.Pods != nil {
typesPresent.Insert("pods")
if typesPresent.Len() == 1 {
@ -183,6 +190,36 @@ func validateObjectSource(src *autoscaling.ObjectMetricSource, fldPath *field.Pa
return allErrs
}
func validateExternalSource(src *autoscaling.ExternalMetricSource, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
if len(src.MetricName) == 0 {
allErrs = append(allErrs, field.Required(fldPath.Child("metricName"), "must specify a metric name"))
} else {
for _, msg := range pathvalidation.IsValidPathSegmentName(src.MetricName) {
allErrs = append(allErrs, field.Invalid(fldPath.Child("metricName"), src.MetricName, msg))
}
}
if src.TargetValue == nil && src.TargetAverageValue == nil {
allErrs = append(allErrs, field.Required(fldPath.Child("targetValue"), "must set either a target value for metric or a per-pod target"))
}
if src.TargetValue != nil && src.TargetAverageValue != nil {
allErrs = append(allErrs, field.Forbidden(fldPath.Child("targetValue"), "may not set both a target value for metric and a per-pod target"))
}
if src.TargetAverageValue != nil && src.TargetAverageValue.Sign() != 1 {
allErrs = append(allErrs, field.Invalid(fldPath.Child("targetAverageValue"), src.TargetAverageValue, "must be positive"))
}
if src.TargetValue != nil && src.TargetValue.Sign() != 1 {
allErrs = append(allErrs, field.Invalid(fldPath.Child("targetValue"), src.TargetValue, "must be positive"))
}
return allErrs
}
func validatePodsSource(src *autoscaling.PodsMetricSource, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}

View File

@ -24,6 +24,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/apis/autoscaling"
api "k8s.io/kubernetes/pkg/apis/core"
utilpointer "k8s.io/kubernetes/pkg/util/pointer"
)
func TestValidateScale(t *testing.T) {
@ -102,14 +103,14 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
Kind: "ReplicationController",
Name: "myrc",
},
MinReplicas: newInt32(1),
MinReplicas: utilpointer.Int32Ptr(1),
MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{
{
Type: autoscaling.ResourceMetricSourceType,
Resource: &autoscaling.ResourceMetricSource{
Name: api.ResourceCPU,
TargetAverageUtilization: newInt32(70),
TargetAverageUtilization: utilpointer.Int32Ptr(70),
},
},
},
@ -125,7 +126,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
Kind: "ReplicationController",
Name: "myrc",
},
MinReplicas: newInt32(1),
MinReplicas: utilpointer.Int32Ptr(1),
MaxReplicas: 5,
},
},
@ -139,7 +140,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
Kind: "ReplicationController",
Name: "myrc",
},
MinReplicas: newInt32(1),
MinReplicas: utilpointer.Int32Ptr(1),
MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{
{
@ -162,13 +163,13 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
Kind: "ReplicationController",
Name: "myrc",
},
MinReplicas: newInt32(1),
MinReplicas: utilpointer.Int32Ptr(1),
MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{
{
Type: autoscaling.PodsMetricSourceType,
Pods: &autoscaling.PodsMetricSource{
MetricName: "some/metric",
MetricName: "somemetric",
TargetAverageValue: *resource.NewMilliQuantity(300, resource.DecimalSI),
},
},
@ -185,7 +186,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
Kind: "ReplicationController",
Name: "myrc",
},
MinReplicas: newInt32(1),
MinReplicas: utilpointer.Int32Ptr(1),
MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{
{
@ -195,13 +196,69 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
Kind: "ReplicationController",
Name: "myrc",
},
MetricName: "some/metric",
MetricName: "somemetric",
TargetValue: *resource.NewMilliQuantity(300, resource.DecimalSI),
},
},
},
},
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "myautoscaler",
Namespace: metav1.NamespaceDefault,
},
Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{
Kind: "ReplicationController",
Name: "myrc",
},
MinReplicas: utilpointer.Int32Ptr(1),
MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{
{
Type: autoscaling.ExternalMetricSourceType,
External: &autoscaling.ExternalMetricSource{
MetricName: "somemetric",
MetricSelector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"label": "value",
},
},
TargetValue: resource.NewMilliQuantity(300, resource.DecimalSI),
},
},
},
},
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "myautoscaler",
Namespace: metav1.NamespaceDefault,
},
Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{
Kind: "ReplicationController",
Name: "myrc",
},
MinReplicas: utilpointer.Int32Ptr(1),
MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{
{
Type: autoscaling.ExternalMetricSourceType,
External: &autoscaling.ExternalMetricSource{
MetricName: "somemetric",
MetricSelector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"label": "value",
},
},
TargetAverageValue: resource.NewMilliQuantity(300, resource.DecimalSI),
},
},
},
},
},
}
for _, successCase := range successCases {
if errs := ValidateHorizontalPodAutoscaler(&successCase); len(errs) != 0 {
@ -218,14 +275,14 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc"},
MinReplicas: newInt32(1),
MinReplicas: utilpointer.Int32Ptr(1),
MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{
{
Type: autoscaling.ResourceMetricSourceType,
Resource: &autoscaling.ResourceMetricSource{
Name: api.ResourceCPU,
TargetAverageUtilization: newInt32(70),
TargetAverageUtilization: utilpointer.Int32Ptr(70),
},
},
},
@ -238,14 +295,14 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Kind: "..", Name: "myrc"},
MinReplicas: newInt32(1),
MinReplicas: utilpointer.Int32Ptr(1),
MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{
{
Type: autoscaling.ResourceMetricSourceType,
Resource: &autoscaling.ResourceMetricSource{
Name: api.ResourceCPU,
TargetAverageUtilization: newInt32(70),
TargetAverageUtilization: utilpointer.Int32Ptr(70),
},
},
},
@ -258,14 +315,14 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Kind: "ReplicationController"},
MinReplicas: newInt32(1),
MinReplicas: utilpointer.Int32Ptr(1),
MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{
{
Type: autoscaling.ResourceMetricSourceType,
Resource: &autoscaling.ResourceMetricSource{
Name: api.ResourceCPU,
TargetAverageUtilization: newInt32(70),
TargetAverageUtilization: utilpointer.Int32Ptr(70),
},
},
},
@ -278,14 +335,14 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Kind: "ReplicationController", Name: ".."},
MinReplicas: newInt32(1),
MinReplicas: utilpointer.Int32Ptr(1),
MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{
{
Type: autoscaling.ResourceMetricSourceType,
Resource: &autoscaling.ResourceMetricSource{
Name: api.ResourceCPU,
TargetAverageUtilization: newInt32(70),
TargetAverageUtilization: utilpointer.Int32Ptr(70),
},
},
},
@ -301,7 +358,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
},
Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{},
MinReplicas: newInt32(-1),
MinReplicas: utilpointer.Int32Ptr(-1),
MaxReplicas: 5,
},
},
@ -315,7 +372,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
},
Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{},
MinReplicas: newInt32(7),
MinReplicas: utilpointer.Int32Ptr(7),
MaxReplicas: 5,
},
},
@ -329,14 +386,14 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
},
Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: newInt32(1),
MinReplicas: utilpointer.Int32Ptr(1),
MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{
{
Type: autoscaling.ResourceMetricSourceType,
Resource: &autoscaling.ResourceMetricSource{
Name: api.ResourceCPU,
TargetAverageUtilization: newInt32(70),
TargetAverageUtilization: utilpointer.Int32Ptr(70),
TargetAverageValue: resource.NewMilliQuantity(300, resource.DecimalSI),
},
},
@ -350,13 +407,13 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: newInt32(1),
MinReplicas: utilpointer.Int32Ptr(1),
MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{
{
Type: autoscaling.ResourceMetricSourceType,
Resource: &autoscaling.ResourceMetricSource{
TargetAverageUtilization: newInt32(70),
TargetAverageUtilization: utilpointer.Int32Ptr(70),
},
},
},
@ -369,14 +426,14 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: newInt32(1),
MinReplicas: utilpointer.Int32Ptr(1),
MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{
{
Type: autoscaling.ResourceMetricSourceType,
Resource: &autoscaling.ResourceMetricSource{
Name: api.ResourceCPU,
TargetAverageUtilization: newInt32(-10),
TargetAverageUtilization: utilpointer.Int32Ptr(-10),
},
},
},
@ -389,7 +446,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: newInt32(1),
MinReplicas: utilpointer.Int32Ptr(1),
MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{
{
@ -408,7 +465,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: newInt32(1),
MinReplicas: utilpointer.Int32Ptr(1),
MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{
{
@ -427,13 +484,13 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: newInt32(1),
MinReplicas: utilpointer.Int32Ptr(1),
MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{
{
Type: autoscaling.PodsMetricSourceType,
Pods: &autoscaling.PodsMetricSource{
MetricName: "some/metric",
MetricName: "somemetric",
},
},
},
@ -446,7 +503,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: newInt32(1),
MinReplicas: utilpointer.Int32Ptr(1),
MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{
{
@ -455,7 +512,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
Target: autoscaling.CrossVersionObjectReference{
Name: "myrc",
},
MetricName: "some/metric",
MetricName: "somemetric",
TargetValue: *resource.NewMilliQuantity(100, resource.DecimalSI),
},
},
@ -469,7 +526,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: newInt32(1),
MinReplicas: utilpointer.Int32Ptr(1),
MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{
{
@ -492,7 +549,157 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: newInt32(1),
MinReplicas: utilpointer.Int32Ptr(1),
MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{
{
Type: autoscaling.ExternalMetricSourceType,
External: &autoscaling.ExternalMetricSource{
MetricSelector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"label": "value",
},
},
TargetValue: resource.NewMilliQuantity(300, resource.DecimalSI),
},
},
},
},
},
msg: "must specify a metric name",
},
{
horizontalPodAutoscaler: autoscaling.HorizontalPodAutoscaler{
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: utilpointer.Int32Ptr(1),
MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{
{
Type: autoscaling.ExternalMetricSourceType,
External: &autoscaling.ExternalMetricSource{
MetricName: "foo/../",
MetricSelector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"label": "value",
},
},
TargetValue: resource.NewMilliQuantity(300, resource.DecimalSI),
},
},
},
},
},
msg: "'/'",
},
{
horizontalPodAutoscaler: autoscaling.HorizontalPodAutoscaler{
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: utilpointer.Int32Ptr(1),
MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{
{
Type: autoscaling.ExternalMetricSourceType,
External: &autoscaling.ExternalMetricSource{
MetricName: "somemetric",
MetricSelector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"label": "value",
},
},
},
},
},
},
},
msg: "must set either a target value for metric or a per-pod target",
},
{
horizontalPodAutoscaler: autoscaling.HorizontalPodAutoscaler{
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: utilpointer.Int32Ptr(1),
MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{
{
Type: autoscaling.ExternalMetricSourceType,
External: &autoscaling.ExternalMetricSource{
MetricName: "somemetric",
MetricSelector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"label": "value",
},
},
TargetValue: resource.NewMilliQuantity(-300, resource.DecimalSI),
},
},
},
},
},
msg: "must be positive",
},
{
horizontalPodAutoscaler: autoscaling.HorizontalPodAutoscaler{
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: utilpointer.Int32Ptr(1),
MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{
{
Type: autoscaling.ExternalMetricSourceType,
External: &autoscaling.ExternalMetricSource{
MetricName: "somemetric",
MetricSelector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"label": "value",
},
},
TargetAverageValue: resource.NewMilliQuantity(-300, resource.DecimalSI),
},
},
},
},
},
msg: "must be positive",
},
{
horizontalPodAutoscaler: autoscaling.HorizontalPodAutoscaler{
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: utilpointer.Int32Ptr(1),
MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{
{
Type: autoscaling.ExternalMetricSourceType,
External: &autoscaling.ExternalMetricSource{
MetricName: "somemetric",
MetricSelector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"label": "value",
},
},
TargetValue: resource.NewMilliQuantity(300, resource.DecimalSI),
TargetAverageValue: resource.NewMilliQuantity(300, resource.DecimalSI),
},
},
},
},
},
msg: "may not set both a target value for metric and a per-pod target",
},
{
horizontalPodAutoscaler: autoscaling.HorizontalPodAutoscaler{
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: utilpointer.Int32Ptr(1),
MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{
{},
@ -506,7 +713,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: newInt32(1),
MinReplicas: utilpointer.Int32Ptr(1),
MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{
{
@ -522,7 +729,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: newInt32(1),
MinReplicas: utilpointer.Int32Ptr(1),
MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{
{
@ -532,7 +739,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
TargetAverageValue: resource.NewMilliQuantity(100, resource.DecimalSI),
},
Pods: &autoscaling.PodsMetricSource{
MetricName: "some/metric",
MetricName: "somemetric",
TargetAverageValue: *resource.NewMilliQuantity(100, resource.DecimalSI),
},
},
@ -561,7 +768,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
},
autoscaling.PodsMetricSourceType: {
Pods: &autoscaling.PodsMetricSource{
MetricName: "some/metric",
MetricName: "somemetric",
TargetAverageValue: *resource.NewMilliQuantity(100, resource.DecimalSI),
},
},
@ -571,7 +778,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
Kind: "ReplicationController",
Name: "myrc",
},
MetricName: "some/metric",
MetricName: "somemetric",
TargetValue: *resource.NewMilliQuantity(100, resource.DecimalSI),
},
},
@ -589,7 +796,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: newInt32(1),
MinReplicas: utilpointer.Int32Ptr(1),
MaxReplicas: 5, Metrics: []autoscaling.MetricSpec{spec},
},
})
@ -604,9 +811,3 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
}
}
}
func newInt32(val int32) *int32 {
p := new(int32)
*p = val
return p
}

View File

@ -16,12 +16,11 @@ 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 autoscaling
import (
resource "k8s.io/apimachinery/pkg/api/resource"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
)
@ -42,6 +41,84 @@ func (in *CrossVersionObjectReference) DeepCopy() *CrossVersionObjectReference {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ExternalMetricSource) DeepCopyInto(out *ExternalMetricSource) {
*out = *in
if in.MetricSelector != nil {
in, out := &in.MetricSelector, &out.MetricSelector
if *in == nil {
*out = nil
} else {
*out = new(v1.LabelSelector)
(*in).DeepCopyInto(*out)
}
}
if in.TargetValue != nil {
in, out := &in.TargetValue, &out.TargetValue
if *in == nil {
*out = nil
} else {
x := (*in).DeepCopy()
*out = &x
}
}
if in.TargetAverageValue != nil {
in, out := &in.TargetAverageValue, &out.TargetAverageValue
if *in == nil {
*out = nil
} else {
x := (*in).DeepCopy()
*out = &x
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExternalMetricSource.
func (in *ExternalMetricSource) DeepCopy() *ExternalMetricSource {
if in == nil {
return nil
}
out := new(ExternalMetricSource)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ExternalMetricStatus) DeepCopyInto(out *ExternalMetricStatus) {
*out = *in
if in.MetricSelector != nil {
in, out := &in.MetricSelector, &out.MetricSelector
if *in == nil {
*out = nil
} else {
*out = new(v1.LabelSelector)
(*in).DeepCopyInto(*out)
}
}
out.CurrentValue = in.CurrentValue.DeepCopy()
if in.CurrentAverageValue != nil {
in, out := &in.CurrentAverageValue, &out.CurrentAverageValue
if *in == nil {
*out = nil
} else {
x := (*in).DeepCopy()
*out = &x
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExternalMetricStatus.
func (in *ExternalMetricStatus) DeepCopy() *ExternalMetricStatus {
if in == nil {
return nil
}
out := new(ExternalMetricStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *HorizontalPodAutoscaler) DeepCopyInto(out *HorizontalPodAutoscaler) {
*out = *in
@ -66,9 +143,8 @@ func (in *HorizontalPodAutoscaler) DeepCopy() *HorizontalPodAutoscaler {
func (in *HorizontalPodAutoscaler) 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.
@ -117,9 +193,8 @@ func (in *HorizontalPodAutoscalerList) DeepCopy() *HorizontalPodAutoscalerList {
func (in *HorizontalPodAutoscalerList) 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.
@ -172,8 +247,7 @@ func (in *HorizontalPodAutoscalerStatus) DeepCopyInto(out *HorizontalPodAutoscal
if *in == nil {
*out = nil
} else {
*out = new(v1.Time)
(*in).DeepCopyInto(*out)
*out = (*in).DeepCopy()
}
}
if in.CurrentMetrics != nil {
@ -233,6 +307,15 @@ func (in *MetricSpec) DeepCopyInto(out *MetricSpec) {
(*in).DeepCopyInto(*out)
}
}
if in.External != nil {
in, out := &in.External, &out.External
if *in == nil {
*out = nil
} else {
*out = new(ExternalMetricSource)
(*in).DeepCopyInto(*out)
}
}
return
}
@ -276,6 +359,15 @@ func (in *MetricStatus) DeepCopyInto(out *MetricStatus) {
(*in).DeepCopyInto(*out)
}
}
if in.External != nil {
in, out := &in.External, &out.External
if *in == nil {
*out = nil
} else {
*out = new(ExternalMetricStatus)
(*in).DeepCopyInto(*out)
}
}
return
}
@ -376,8 +468,8 @@ func (in *ResourceMetricSource) DeepCopyInto(out *ResourceMetricSource) {
if *in == nil {
*out = nil
} else {
*out = new(resource.Quantity)
**out = (*in).DeepCopy()
x := (*in).DeepCopy()
*out = &x
}
}
return
@ -443,9 +535,8 @@ func (in *Scale) DeepCopy() *Scale {
func (in *Scale) 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.

View File

@ -9,7 +9,6 @@ reviewers:
- sttts
- saad-ali
- ncdc
- timothysc
- soltysh
- dims
- errordeveloper

View File

@ -33,12 +33,12 @@ go_library(
go_test(
name = "go_default_xtest",
srcs = ["defaults_test.go"],
importpath = "k8s.io/kubernetes/pkg/apis/batch/v1_test",
deps = [
":go_default_library",
"//pkg/api/legacyscheme:go_default_library",
"//pkg/apis/batch/install:go_default_library",
"//pkg/apis/core/install:go_default_library",
"//pkg/util/pointer:go_default_library",
"//vendor/k8s.io/api/batch/v1:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",

View File

@ -29,6 +29,7 @@ import (
_ "k8s.io/kubernetes/pkg/apis/batch/install"
. "k8s.io/kubernetes/pkg/apis/batch/v1"
_ "k8s.io/kubernetes/pkg/apis/core/install"
utilpointer "k8s.io/kubernetes/pkg/util/pointer"
)
func TestSetDefaultJob(t *testing.T) {
@ -48,9 +49,9 @@ func TestSetDefaultJob(t *testing.T) {
},
expected: &batchv1.Job{
Spec: batchv1.JobSpec{
Completions: newInt32(1),
Parallelism: newInt32(1),
BackoffLimit: newInt32(6),
Completions: utilpointer.Int32Ptr(1),
Parallelism: utilpointer.Int32Ptr(1),
BackoffLimit: utilpointer.Int32Ptr(6),
},
},
expectLabels: true,
@ -68,16 +69,16 @@ func TestSetDefaultJob(t *testing.T) {
},
expected: &batchv1.Job{
Spec: batchv1.JobSpec{
Completions: newInt32(1),
Parallelism: newInt32(1),
BackoffLimit: newInt32(6),
Completions: utilpointer.Int32Ptr(1),
Parallelism: utilpointer.Int32Ptr(1),
BackoffLimit: utilpointer.Int32Ptr(6),
},
},
},
"WQ: Parallelism explicitly 0 and completions unset -> BackoffLimit is defaulted": {
original: &batchv1.Job{
Spec: batchv1.JobSpec{
Parallelism: newInt32(0),
Parallelism: utilpointer.Int32Ptr(0),
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels},
},
@ -85,8 +86,8 @@ func TestSetDefaultJob(t *testing.T) {
},
expected: &batchv1.Job{
Spec: batchv1.JobSpec{
Parallelism: newInt32(0),
BackoffLimit: newInt32(6),
Parallelism: utilpointer.Int32Ptr(0),
BackoffLimit: utilpointer.Int32Ptr(6),
},
},
expectLabels: true,
@ -94,7 +95,7 @@ func TestSetDefaultJob(t *testing.T) {
"WQ: Parallelism explicitly 2 and completions unset -> BackoffLimit is defaulted": {
original: &batchv1.Job{
Spec: batchv1.JobSpec{
Parallelism: newInt32(2),
Parallelism: utilpointer.Int32Ptr(2),
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels},
},
@ -102,8 +103,8 @@ func TestSetDefaultJob(t *testing.T) {
},
expected: &batchv1.Job{
Spec: batchv1.JobSpec{
Parallelism: newInt32(2),
BackoffLimit: newInt32(6),
Parallelism: utilpointer.Int32Ptr(2),
BackoffLimit: utilpointer.Int32Ptr(6),
},
},
expectLabels: true,
@ -111,7 +112,7 @@ func TestSetDefaultJob(t *testing.T) {
"Completions explicitly 2 and others unset -> parallelism and BackoffLimit are defaulted": {
original: &batchv1.Job{
Spec: batchv1.JobSpec{
Completions: newInt32(2),
Completions: utilpointer.Int32Ptr(2),
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels},
},
@ -119,9 +120,9 @@ func TestSetDefaultJob(t *testing.T) {
},
expected: &batchv1.Job{
Spec: batchv1.JobSpec{
Completions: newInt32(2),
Parallelism: newInt32(1),
BackoffLimit: newInt32(6),
Completions: utilpointer.Int32Ptr(2),
Parallelism: utilpointer.Int32Ptr(1),
BackoffLimit: utilpointer.Int32Ptr(6),
},
},
expectLabels: true,
@ -129,7 +130,7 @@ func TestSetDefaultJob(t *testing.T) {
"BackoffLimit explicitly 5 and others unset -> parallelism and completions are defaulted": {
original: &batchv1.Job{
Spec: batchv1.JobSpec{
BackoffLimit: newInt32(5),
BackoffLimit: utilpointer.Int32Ptr(5),
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels},
},
@ -137,9 +138,9 @@ func TestSetDefaultJob(t *testing.T) {
},
expected: &batchv1.Job{
Spec: batchv1.JobSpec{
Completions: newInt32(1),
Parallelism: newInt32(1),
BackoffLimit: newInt32(5),
Completions: utilpointer.Int32Ptr(1),
Parallelism: utilpointer.Int32Ptr(1),
BackoffLimit: utilpointer.Int32Ptr(5),
},
},
expectLabels: true,
@ -147,9 +148,9 @@ func TestSetDefaultJob(t *testing.T) {
"All set -> no change": {
original: &batchv1.Job{
Spec: batchv1.JobSpec{
Completions: newInt32(8),
Parallelism: newInt32(9),
BackoffLimit: newInt32(10),
Completions: utilpointer.Int32Ptr(8),
Parallelism: utilpointer.Int32Ptr(9),
BackoffLimit: utilpointer.Int32Ptr(10),
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels},
},
@ -157,9 +158,9 @@ func TestSetDefaultJob(t *testing.T) {
},
expected: &batchv1.Job{
Spec: batchv1.JobSpec{
Completions: newInt32(8),
Parallelism: newInt32(9),
BackoffLimit: newInt32(10),
Completions: utilpointer.Int32Ptr(8),
Parallelism: utilpointer.Int32Ptr(9),
BackoffLimit: utilpointer.Int32Ptr(10),
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels},
},
@ -170,9 +171,9 @@ func TestSetDefaultJob(t *testing.T) {
"All set, flipped -> no change": {
original: &batchv1.Job{
Spec: batchv1.JobSpec{
Completions: newInt32(11),
Parallelism: newInt32(10),
BackoffLimit: newInt32(9),
Completions: utilpointer.Int32Ptr(11),
Parallelism: utilpointer.Int32Ptr(10),
BackoffLimit: utilpointer.Int32Ptr(9),
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels},
},
@ -180,9 +181,9 @@ func TestSetDefaultJob(t *testing.T) {
},
expected: &batchv1.Job{
Spec: batchv1.JobSpec{
Completions: newInt32(11),
Parallelism: newInt32(10),
BackoffLimit: newInt32(9),
Completions: utilpointer.Int32Ptr(11),
Parallelism: utilpointer.Int32Ptr(10),
BackoffLimit: utilpointer.Int32Ptr(9),
},
},
expectLabels: true,
@ -244,9 +245,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/batch/v1"
core_v1 "k8s.io/api/core/v1"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -29,7 +31,6 @@ import (
batch "k8s.io/kubernetes/pkg/apis/batch"
core "k8s.io/kubernetes/pkg/apis/core"
apis_core_v1 "k8s.io/kubernetes/pkg/apis/core/v1"
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 v1

View File

@ -34,12 +34,12 @@ go_library(
go_test(
name = "go_default_xtest",
srcs = ["defaults_test.go"],
importpath = "k8s.io/kubernetes/pkg/apis/batch/v1beta1_test",
deps = [
":go_default_library",
"//pkg/api/legacyscheme:go_default_library",
"//pkg/apis/batch/install:go_default_library",
"//pkg/apis/core/install:go_default_library",
"//pkg/util/pointer:go_default_library",
"//vendor/k8s.io/api/batch/v1beta1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
],

View File

@ -27,6 +27,7 @@ import (
_ "k8s.io/kubernetes/pkg/apis/batch/install"
. "k8s.io/kubernetes/pkg/apis/batch/v1beta1"
_ "k8s.io/kubernetes/pkg/apis/core/install"
utilpointer "k8s.io/kubernetes/pkg/util/pointer"
)
func TestSetDefaultCronJob(t *testing.T) {
@ -40,8 +41,8 @@ func TestSetDefaultCronJob(t *testing.T) {
Spec: batchv1beta1.CronJobSpec{
ConcurrencyPolicy: batchv1beta1.AllowConcurrent,
Suspend: newBool(false),
SuccessfulJobsHistoryLimit: newInt32(3),
FailedJobsHistoryLimit: newInt32(1),
SuccessfulJobsHistoryLimit: utilpointer.Int32Ptr(3),
FailedJobsHistoryLimit: utilpointer.Int32Ptr(1),
},
},
},
@ -50,16 +51,16 @@ func TestSetDefaultCronJob(t *testing.T) {
Spec: batchv1beta1.CronJobSpec{
ConcurrencyPolicy: batchv1beta1.ForbidConcurrent,
Suspend: newBool(true),
SuccessfulJobsHistoryLimit: newInt32(5),
FailedJobsHistoryLimit: newInt32(5),
SuccessfulJobsHistoryLimit: utilpointer.Int32Ptr(5),
FailedJobsHistoryLimit: utilpointer.Int32Ptr(5),
},
},
expected: &batchv1beta1.CronJob{
Spec: batchv1beta1.CronJobSpec{
ConcurrencyPolicy: batchv1beta1.ForbidConcurrent,
Suspend: newBool(true),
SuccessfulJobsHistoryLimit: newInt32(5),
FailedJobsHistoryLimit: newInt32(5),
SuccessfulJobsHistoryLimit: utilpointer.Int32Ptr(5),
FailedJobsHistoryLimit: utilpointer.Int32Ptr(5),
},
},
},
@ -114,9 +115,3 @@ func newBool(val bool) *bool {
*p = val
return p
}
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/batch/v1beta1"
core_v1 "k8s.io/api/core/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -29,7 +31,6 @@ import (
batch "k8s.io/kubernetes/pkg/apis/batch"
batch_v1 "k8s.io/kubernetes/pkg/apis/batch/v1"
core "k8s.io/kubernetes/pkg/apis/core"
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

@ -34,7 +34,6 @@ go_library(
go_test(
name = "go_default_xtest",
srcs = ["defaults_test.go"],
importpath = "k8s.io/kubernetes/pkg/apis/batch/v2alpha1_test",
deps = [
":go_default_library",
"//pkg/api/legacyscheme:go_default_library",

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 v2alpha1
import (
unsafe "unsafe"
v2alpha1 "k8s.io/api/batch/v2alpha1"
core_v1 "k8s.io/api/core/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -29,7 +31,6 @@ import (
batch "k8s.io/kubernetes/pkg/apis/batch"
batch_v1 "k8s.io/kubernetes/pkg/apis/batch/v1"
core "k8s.io/kubernetes/pkg/apis/core"
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 v2alpha1

View File

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

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 batch
@ -50,9 +50,8 @@ func (in *CronJob) DeepCopy() *CronJob {
func (in *CronJob) 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.
@ -84,9 +83,8 @@ func (in *CronJobList) DeepCopy() *CronJobList {
func (in *CronJobList) 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.
@ -155,8 +153,7 @@ func (in *CronJobStatus) DeepCopyInto(out *CronJobStatus) {
if *in == nil {
*out = nil
} else {
*out = new(v1.Time)
(*in).DeepCopyInto(*out)
*out = (*in).DeepCopy()
}
}
return
@ -196,9 +193,8 @@ func (in *Job) DeepCopy() *Job {
func (in *Job) 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.
@ -248,9 +244,8 @@ func (in *JobList) DeepCopy() *JobList {
func (in *JobList) 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.
@ -339,8 +334,7 @@ func (in *JobStatus) DeepCopyInto(out *JobStatus) {
if *in == nil {
*out = nil
} else {
*out = new(v1.Time)
(*in).DeepCopyInto(*out)
*out = (*in).DeepCopy()
}
}
if in.CompletionTime != nil {
@ -348,8 +342,7 @@ func (in *JobStatus) DeepCopyInto(out *JobStatus) {
if *in == nil {
*out = nil
} else {
*out = new(v1.Time)
(*in).DeepCopyInto(*out)
*out = (*in).DeepCopy()
}
}
return
@ -388,9 +381,8 @@ func (in *JobTemplate) DeepCopy() *JobTemplate {
func (in *JobTemplate) 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.

View File

@ -6,7 +6,6 @@ reviewers:
- caesarxuchao
- liggitt
- sttts
- timothysc
- dims
- errordeveloper
- mbohlool

View File

@ -122,7 +122,7 @@ type KeyUsage string
const (
UsageSigning KeyUsage = "signing"
UsageDigitalSignature KeyUsage = "digital signature"
UsageContentCommittment KeyUsage = "content committment"
UsageContentCommittment KeyUsage = "content commitment"
UsageKeyEncipherment KeyUsage = "key encipherment"
UsageKeyAgreement KeyUsage = "key agreement"
UsageDataEncipherment KeyUsage = "data encipherment"

View File

@ -16,16 +16,17 @@ 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/certificates/v1beta1"
conversion "k8s.io/apimachinery/pkg/conversion"
runtime "k8s.io/apimachinery/pkg/runtime"
certificates "k8s.io/kubernetes/pkg/apis/certificates"
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

@ -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 certificates
@ -48,9 +48,8 @@ func (in *CertificateSigningRequest) DeepCopy() *CertificateSigningRequest {
func (in *CertificateSigningRequest) 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.
@ -99,9 +98,8 @@ func (in *CertificateSigningRequestList) DeepCopy() *CertificateSigningRequestLi
func (in *CertificateSigningRequestList) 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.
@ -126,8 +124,12 @@ func (in *CertificateSigningRequestSpec) DeepCopyInto(out *CertificateSigningReq
in, out := &in.Extra, &out.Extra
*out = make(map[string]ExtraValue, len(*in))
for key, val := range *in {
(*out)[key] = make(ExtraValue, len(val))
copy((*out)[key], val)
if val == nil {
(*out)[key] = nil
} else {
(*out)[key] = make([]string, len(val))
copy((*out)[key], val)
}
}
}
return
@ -170,3 +172,23 @@ func (in *CertificateSigningRequestStatus) DeepCopy() *CertificateSigningRequest
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in ExtraValue) DeepCopyInto(out *ExtraValue) {
{
in := &in
*out = make(ExtraValue, len(*in))
copy(*out, *in)
return
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExtraValue.
func (in ExtraValue) DeepCopy() ExtraValue {
if in == nil {
return nil
}
out := new(ExtraValue)
in.DeepCopyInto(out)
return *out
}

View File

@ -28,8 +28,7 @@ go_library(
go_test(
name = "go_default_test",
srcs = ["helpers_test.go"],
importpath = "k8s.io/kubernetes/pkg/apis/componentconfig",
library = ":go_default_library",
embed = [":go_default_library"],
deps = ["//vendor/github.com/spf13/pflag:go_default_library"],
)

View File

@ -21,7 +21,6 @@ reviewers:
- ncdc
- yifan-gu
- mwielgus
- timothysc
- feiskyer
- dims
- errordeveloper

View File

@ -20,6 +20,7 @@ import (
"encoding/json"
"fmt"
"net"
"strconv"
"k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -61,6 +62,55 @@ func (v IPVar) Type() string {
return "ip"
}
// IPPortVar allows IP or IP:port formats.
type IPPortVar struct {
Val *string
}
func (v IPPortVar) Set(s string) error {
if len(s) == 0 {
v.Val = nil
return nil
}
if v.Val == nil {
// it's okay to panic here since this is programmer error
panic("the string pointer passed into IPPortVar should not be nil")
}
// Both IP and IP:port are valid.
// Attempt to parse into IP first.
if net.ParseIP(s) != nil {
*v.Val = s
return nil
}
// Can not parse into IP, now assume IP:port.
host, port, err := net.SplitHostPort(s)
if err != nil {
return fmt.Errorf("%q is not in a valid format (ip or ip:port): %v", s, err)
}
if net.ParseIP(host) == nil {
return fmt.Errorf("%q is not a valid IP address", host)
}
if _, err := strconv.Atoi(port); err != nil {
return fmt.Errorf("%q is not a valid number", port)
}
*v.Val = s
return nil
}
func (v IPPortVar) String() string {
if v.Val == nil {
return ""
}
return *v.Val
}
func (v IPPortVar) Type() string {
return "ipport"
}
type PortRangeVar struct {
Val *string
}

View File

@ -25,7 +25,7 @@ import (
func TestIPVar(t *testing.T) {
defaultIP := "0.0.0.0"
cases := []struct {
testCases := []struct {
argc string
expectErr bool
expectVal string
@ -41,7 +41,7 @@ func TestIPVar(t *testing.T) {
expectVal: defaultIP,
},
}
for _, c := range cases {
for _, tc := range testCases {
fs := pflag.NewFlagSet("blah", pflag.PanicOnError)
ip := defaultIP
fs.Var(IPVar{&ip}, "ip", "the ip")
@ -53,19 +53,113 @@ func TestIPVar(t *testing.T) {
err = r.(error)
}
}()
fs.Parse(strings.Split(c.argc, " "))
fs.Parse(strings.Split(tc.argc, " "))
}()
if c.expectErr && err == nil {
if tc.expectErr && err == nil {
t.Errorf("did not observe an expected error")
continue
}
if !c.expectErr && err != nil {
t.Errorf("observed an unexpected error")
if !tc.expectErr && err != nil {
t.Errorf("observed an unexpected error: %v", err)
continue
}
if c.expectVal != ip {
t.Errorf("unexpected ip: expected %q, saw %q", c.expectVal, ip)
if tc.expectVal != ip {
t.Errorf("unexpected ip: expected %q, saw %q", tc.expectVal, ip)
}
}
}
func TestIPPortVar(t *testing.T) {
defaultIPPort := "0.0.0.0:8080"
testCases := []struct {
desc string
argc string
expectErr bool
expectVal string
}{
{
desc: "valid ipv4 1",
argc: "blah --ipport=0.0.0.0",
expectVal: "0.0.0.0",
},
{
desc: "valid ipv4 2",
argc: "blah --ipport=127.0.0.1",
expectVal: "127.0.0.1",
},
{
desc: "invalid IP",
argc: "blah --ipport=invalidip",
expectErr: true,
expectVal: defaultIPPort,
},
{
desc: "valid ipv4 with port",
argc: "blah --ipport=0.0.0.0:8080",
expectVal: "0.0.0.0:8080",
},
{
desc: "invalid ipv4 with invalid port",
argc: "blah --ipport=0.0.0.0:invalidport",
expectErr: true,
expectVal: defaultIPPort,
},
{
desc: "invalid IP with port",
argc: "blah --ipport=invalidip:8080",
expectErr: true,
expectVal: defaultIPPort,
},
{
desc: "valid ipv6 1",
argc: "blah --ipport=::1",
expectVal: "::1",
},
{
desc: "valid ipv6 2",
argc: "blah --ipport=::",
expectVal: "::",
},
{
desc: "valid ipv6 with port",
argc: "blah --ipport=[::1]:8080",
expectVal: "[::1]:8080",
},
{
desc: "invalid ipv6 with port without bracket",
argc: "blah --ipport=fd00:f00d:600d:f00d:8080",
expectErr: true,
expectVal: defaultIPPort,
},
}
for _, tc := range testCases {
fs := pflag.NewFlagSet("blah", pflag.PanicOnError)
ipport := defaultIPPort
fs.Var(IPPortVar{&ipport}, "ipport", "the ip:port")
var err error
func() {
defer func() {
if r := recover(); r != nil {
err = r.(error)
}
}()
fs.Parse(strings.Split(tc.argc, " "))
}()
if tc.expectErr && err == nil {
t.Errorf("%q: Did not observe an expected error", tc.desc)
continue
}
if !tc.expectErr && err != nil {
t.Errorf("%q: Observed an unexpected error: %v", tc.desc, err)
continue
}
if tc.expectVal != ipport {
t.Errorf("%q: Unexpected ipport: expected %q, saw %q", tc.desc, tc.expectVal, ipport)
}
}
}

View File

@ -181,6 +181,9 @@ type KubeControllerManagerConfiguration struct {
CloudProvider string
// cloudConfigFile is the path to the cloud provider configuration file.
CloudConfigFile string
// externalCloudVolumePlugin specifies the plugin to use when cloudProvider is "external".
// It is currently used by the in repo cloud providers to handle node and volume control in the KCM.
ExternalCloudVolumePlugin string
// run with untagged cloud instances
AllowUntaggedCloud bool
// concurrentEndpointSyncs is the number of endpoint syncing operations
@ -223,9 +226,6 @@ type KubeControllerManagerConfiguration struct {
ConcurrentSATokenSyncs int32
// lookupCacheSizeForRC is the size of lookup cache for replication controllers.
// Larger number = more responsive replica management, but more MEM load.
// serviceSyncPeriod is the period for syncing services with their external
// load balancers.
ServiceSyncPeriod metav1.Duration
// nodeSyncPeriod is the period for syncing nodes from cloudprovider. Longer
// periods will result in fewer calls to cloud provider, but may delay addition
// of new nodes to cluster.

View File

@ -46,7 +46,6 @@ filegroup(
go_test(
name = "go_default_test",
srcs = ["defaults_test.go"],
importpath = "k8s.io/kubernetes/pkg/apis/componentconfig/v1alpha1",
library = ":go_default_library",
embed = [":go_default_library"],
deps = ["//pkg/apis/componentconfig:go_default_library"],
)

View File

@ -16,16 +16,17 @@ 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 v1alpha1
import (
unsafe "unsafe"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
conversion "k8s.io/apimachinery/pkg/conversion"
runtime "k8s.io/apimachinery/pkg/runtime"
componentconfig "k8s.io/kubernetes/pkg/apis/componentconfig"
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 deepcopy-gen. Do not edit it manually!
// Code generated by deepcopy-gen. DO NOT EDIT.
package v1alpha1
@ -64,9 +64,8 @@ func (in *KubeSchedulerConfiguration) DeepCopy() *KubeSchedulerConfiguration {
func (in *KubeSchedulerConfiguration) 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.

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 v1alpha1

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 componentconfig
@ -56,6 +56,31 @@ func (in *GroupResource) DeepCopy() *GroupResource {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *IPPortVar) DeepCopyInto(out *IPPortVar) {
*out = *in
if in.Val != nil {
in, out := &in.Val, &out.Val
if *in == nil {
*out = nil
} else {
*out = new(string)
**out = **in
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPPortVar.
func (in *IPPortVar) DeepCopy() *IPPortVar {
if in == nil {
return nil
}
out := new(IPPortVar)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *IPVar) DeepCopyInto(out *IPVar) {
*out = *in
@ -90,7 +115,6 @@ func (in *KubeControllerManagerConfiguration) DeepCopyInto(out *KubeControllerMa
*out = make([]string, len(*in))
copy(*out, *in)
}
out.ServiceSyncPeriod = in.ServiceSyncPeriod
out.NodeSyncPeriod = in.NodeSyncPeriod
out.RouteReconciliationPeriod = in.RouteReconciliationPeriod
out.ResourceQuotaSyncPeriod = in.ResourceQuotaSyncPeriod
@ -132,9 +156,8 @@ func (in *KubeControllerManagerConfiguration) DeepCopy() *KubeControllerManagerC
func (in *KubeControllerManagerConfiguration) 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.
@ -161,9 +184,8 @@ func (in *KubeSchedulerConfiguration) DeepCopy() *KubeSchedulerConfiguration {
func (in *KubeSchedulerConfiguration) 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.

View File

@ -32,9 +32,11 @@ go_library(
go_test(
name = "go_default_test",
srcs = ["taint_test.go"],
importpath = "k8s.io/kubernetes/pkg/apis/core",
library = ":go_default_library",
srcs = [
"taint_test.go",
"toleration_test.go",
],
embed = [":go_default_library"],
)
filegroup(

Some files were not shown because too many files have changed in this diff Show More