mirror of https://github.com/k3s-io/k3s
run pkg/api/v1/rewrite....sh, pkg/api/v1 (not including subdir) compile
parent
58edb6b485
commit
9f5f4ba729
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
package v1_test
|
||||
|
||||
import (
|
||||
"k8s.io/api/core/v1"
|
||||
"testing"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
|
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
package v1
|
||||
|
||||
import (
|
||||
"k8s.io/api/core/v1"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"reflect"
|
||||
|
@ -35,80 +36,80 @@ import (
|
|||
func addFastPathConversionFuncs(scheme *runtime.Scheme) error {
|
||||
scheme.AddGenericConversionFunc(func(objA, objB interface{}, s conversion.Scope) (bool, error) {
|
||||
switch a := objA.(type) {
|
||||
case *Pod:
|
||||
case *v1.Pod:
|
||||
switch b := objB.(type) {
|
||||
case *api.Pod:
|
||||
return true, Convert_v1_Pod_To_api_Pod(a, b, s)
|
||||
}
|
||||
case *api.Pod:
|
||||
switch b := objB.(type) {
|
||||
case *Pod:
|
||||
case *v1.Pod:
|
||||
return true, Convert_api_Pod_To_v1_Pod(a, b, s)
|
||||
}
|
||||
|
||||
case *Event:
|
||||
case *v1.Event:
|
||||
switch b := objB.(type) {
|
||||
case *api.Event:
|
||||
return true, Convert_v1_Event_To_api_Event(a, b, s)
|
||||
}
|
||||
case *api.Event:
|
||||
switch b := objB.(type) {
|
||||
case *Event:
|
||||
case *v1.Event:
|
||||
return true, Convert_api_Event_To_v1_Event(a, b, s)
|
||||
}
|
||||
|
||||
case *ReplicationController:
|
||||
case *v1.ReplicationController:
|
||||
switch b := objB.(type) {
|
||||
case *api.ReplicationController:
|
||||
return true, Convert_v1_ReplicationController_To_api_ReplicationController(a, b, s)
|
||||
}
|
||||
case *api.ReplicationController:
|
||||
switch b := objB.(type) {
|
||||
case *ReplicationController:
|
||||
case *v1.ReplicationController:
|
||||
return true, Convert_api_ReplicationController_To_v1_ReplicationController(a, b, s)
|
||||
}
|
||||
|
||||
case *Node:
|
||||
case *v1.Node:
|
||||
switch b := objB.(type) {
|
||||
case *api.Node:
|
||||
return true, Convert_v1_Node_To_api_Node(a, b, s)
|
||||
}
|
||||
case *api.Node:
|
||||
switch b := objB.(type) {
|
||||
case *Node:
|
||||
case *v1.Node:
|
||||
return true, Convert_api_Node_To_v1_Node(a, b, s)
|
||||
}
|
||||
|
||||
case *Namespace:
|
||||
case *v1.Namespace:
|
||||
switch b := objB.(type) {
|
||||
case *api.Namespace:
|
||||
return true, Convert_v1_Namespace_To_api_Namespace(a, b, s)
|
||||
}
|
||||
case *api.Namespace:
|
||||
switch b := objB.(type) {
|
||||
case *Namespace:
|
||||
case *v1.Namespace:
|
||||
return true, Convert_api_Namespace_To_v1_Namespace(a, b, s)
|
||||
}
|
||||
|
||||
case *Service:
|
||||
case *v1.Service:
|
||||
switch b := objB.(type) {
|
||||
case *api.Service:
|
||||
return true, Convert_v1_Service_To_api_Service(a, b, s)
|
||||
}
|
||||
case *api.Service:
|
||||
switch b := objB.(type) {
|
||||
case *Service:
|
||||
case *v1.Service:
|
||||
return true, Convert_api_Service_To_v1_Service(a, b, s)
|
||||
}
|
||||
|
||||
case *Endpoints:
|
||||
case *v1.Endpoints:
|
||||
switch b := objB.(type) {
|
||||
case *api.Endpoints:
|
||||
return true, Convert_v1_Endpoints_To_api_Endpoints(a, b, s)
|
||||
}
|
||||
case *api.Endpoints:
|
||||
switch b := objB.(type) {
|
||||
case *Endpoints:
|
||||
case *v1.Endpoints:
|
||||
return true, Convert_api_Endpoints_To_v1_Endpoints(a, b, s)
|
||||
}
|
||||
|
||||
|
@ -152,7 +153,7 @@ func addConversionFuncs(scheme *runtime.Scheme) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// Add field label conversions for kinds having selectable nothing but ObjectMeta fields.
|
||||
// Add field label conversions for kinds having selectable nothing but v1.ObjectMeta fields.
|
||||
for _, k := range []string{
|
||||
"Endpoints",
|
||||
"ResourceQuota",
|
||||
|
@ -258,7 +259,7 @@ func addConversionFuncs(scheme *runtime.Scheme) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func Convert_v1_ReplicationController_to_extensions_ReplicaSet(in *ReplicationController, out *extensions.ReplicaSet, s conversion.Scope) error {
|
||||
func Convert_v1_ReplicationController_to_extensions_ReplicaSet(in *v1.ReplicationController, out *extensions.ReplicaSet, s conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
if err := Convert_v1_ReplicationControllerSpec_to_extensions_ReplicaSetSpec(&in.Spec, &out.Spec, s); err != nil {
|
||||
return err
|
||||
|
@ -269,7 +270,7 @@ func Convert_v1_ReplicationController_to_extensions_ReplicaSet(in *ReplicationCo
|
|||
return nil
|
||||
}
|
||||
|
||||
func Convert_v1_ReplicationControllerSpec_to_extensions_ReplicaSetSpec(in *ReplicationControllerSpec, out *extensions.ReplicaSetSpec, s conversion.Scope) error {
|
||||
func Convert_v1_ReplicationControllerSpec_to_extensions_ReplicaSetSpec(in *v1.ReplicationControllerSpec, out *extensions.ReplicaSetSpec, s conversion.Scope) error {
|
||||
out.Replicas = *in.Replicas
|
||||
if in.Selector != nil {
|
||||
metav1.Convert_map_to_unversioned_LabelSelector(&in.Selector, out.Selector, s)
|
||||
|
@ -282,7 +283,7 @@ func Convert_v1_ReplicationControllerSpec_to_extensions_ReplicaSetSpec(in *Repli
|
|||
return nil
|
||||
}
|
||||
|
||||
func Convert_v1_ReplicationControllerStatus_to_extensions_ReplicaSetStatus(in *ReplicationControllerStatus, out *extensions.ReplicaSetStatus, s conversion.Scope) error {
|
||||
func Convert_v1_ReplicationControllerStatus_to_extensions_ReplicaSetStatus(in *v1.ReplicationControllerStatus, out *extensions.ReplicaSetStatus, s conversion.Scope) error {
|
||||
out.Replicas = in.Replicas
|
||||
out.FullyLabeledReplicas = in.FullyLabeledReplicas
|
||||
out.ReadyReplicas = in.ReadyReplicas
|
||||
|
@ -291,7 +292,7 @@ func Convert_v1_ReplicationControllerStatus_to_extensions_ReplicaSetStatus(in *R
|
|||
return nil
|
||||
}
|
||||
|
||||
func Convert_extensions_ReplicaSet_to_v1_ReplicationController(in *extensions.ReplicaSet, out *ReplicationController, s conversion.Scope) error {
|
||||
func Convert_extensions_ReplicaSet_to_v1_ReplicationController(in *extensions.ReplicaSet, out *v1.ReplicationController, s conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
if err := Convert_extensions_ReplicaSetSpec_to_v1_ReplicationControllerSpec(&in.Spec, &out.Spec, s); err != nil {
|
||||
fieldErr, ok := err.(*field.Error)
|
||||
|
@ -301,7 +302,7 @@ func Convert_extensions_ReplicaSet_to_v1_ReplicationController(in *extensions.Re
|
|||
if out.Annotations == nil {
|
||||
out.Annotations = make(map[string]string)
|
||||
}
|
||||
out.Annotations[NonConvertibleAnnotationPrefix+"/"+fieldErr.Field] = reflect.ValueOf(fieldErr.BadValue).String()
|
||||
out.Annotations[v1.NonConvertibleAnnotationPrefix+"/"+fieldErr.Field] = reflect.ValueOf(fieldErr.BadValue).String()
|
||||
}
|
||||
if err := Convert_extensions_ReplicaSetStatus_to_v1_ReplicationControllerStatus(&in.Status, &out.Status, s); err != nil {
|
||||
return err
|
||||
|
@ -309,7 +310,7 @@ func Convert_extensions_ReplicaSet_to_v1_ReplicationController(in *extensions.Re
|
|||
return nil
|
||||
}
|
||||
|
||||
func Convert_extensions_ReplicaSetSpec_to_v1_ReplicationControllerSpec(in *extensions.ReplicaSetSpec, out *ReplicationControllerSpec, s conversion.Scope) error {
|
||||
func Convert_extensions_ReplicaSetSpec_to_v1_ReplicationControllerSpec(in *extensions.ReplicaSetSpec, out *v1.ReplicationControllerSpec, s conversion.Scope) error {
|
||||
out.Replicas = new(int32)
|
||||
*out.Replicas = in.Replicas
|
||||
out.MinReadySeconds = in.MinReadySeconds
|
||||
|
@ -317,14 +318,14 @@ func Convert_extensions_ReplicaSetSpec_to_v1_ReplicationControllerSpec(in *exten
|
|||
if in.Selector != nil {
|
||||
invalidErr = metav1.Convert_unversioned_LabelSelector_to_map(in.Selector, &out.Selector, s)
|
||||
}
|
||||
out.Template = new(PodTemplateSpec)
|
||||
out.Template = new(v1.PodTemplateSpec)
|
||||
if err := Convert_api_PodTemplateSpec_To_v1_PodTemplateSpec(&in.Template, out.Template, s); err != nil {
|
||||
return err
|
||||
}
|
||||
return invalidErr
|
||||
}
|
||||
|
||||
func Convert_extensions_ReplicaSetStatus_to_v1_ReplicationControllerStatus(in *extensions.ReplicaSetStatus, out *ReplicationControllerStatus, s conversion.Scope) error {
|
||||
func Convert_extensions_ReplicaSetStatus_to_v1_ReplicationControllerStatus(in *extensions.ReplicaSetStatus, out *v1.ReplicationControllerStatus, s conversion.Scope) error {
|
||||
out.Replicas = in.Replicas
|
||||
out.FullyLabeledReplicas = in.FullyLabeledReplicas
|
||||
out.ReadyReplicas = in.ReadyReplicas
|
||||
|
@ -333,12 +334,12 @@ func Convert_extensions_ReplicaSetStatus_to_v1_ReplicationControllerStatus(in *e
|
|||
return nil
|
||||
}
|
||||
|
||||
func Convert_api_ReplicationControllerSpec_To_v1_ReplicationControllerSpec(in *api.ReplicationControllerSpec, out *ReplicationControllerSpec, s conversion.Scope) error {
|
||||
func Convert_api_ReplicationControllerSpec_To_v1_ReplicationControllerSpec(in *api.ReplicationControllerSpec, out *v1.ReplicationControllerSpec, s conversion.Scope) error {
|
||||
out.Replicas = &in.Replicas
|
||||
out.MinReadySeconds = in.MinReadySeconds
|
||||
out.Selector = in.Selector
|
||||
if in.Template != nil {
|
||||
out.Template = new(PodTemplateSpec)
|
||||
out.Template = new(v1.PodTemplateSpec)
|
||||
if err := Convert_api_PodTemplateSpec_To_v1_PodTemplateSpec(in.Template, out.Template, s); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -348,7 +349,7 @@ func Convert_api_ReplicationControllerSpec_To_v1_ReplicationControllerSpec(in *a
|
|||
return nil
|
||||
}
|
||||
|
||||
func Convert_v1_ReplicationControllerSpec_To_api_ReplicationControllerSpec(in *ReplicationControllerSpec, out *api.ReplicationControllerSpec, s conversion.Scope) error {
|
||||
func Convert_v1_ReplicationControllerSpec_To_api_ReplicationControllerSpec(in *v1.ReplicationControllerSpec, out *api.ReplicationControllerSpec, s conversion.Scope) error {
|
||||
if in.Replicas != nil {
|
||||
out.Replicas = *in.Replicas
|
||||
}
|
||||
|
@ -365,7 +366,7 @@ func Convert_v1_ReplicationControllerSpec_To_api_ReplicationControllerSpec(in *R
|
|||
return nil
|
||||
}
|
||||
|
||||
func Convert_api_PodStatusResult_To_v1_PodStatusResult(in *api.PodStatusResult, out *PodStatusResult, s conversion.Scope) error {
|
||||
func Convert_api_PodStatusResult_To_v1_PodStatusResult(in *api.PodStatusResult, out *v1.PodStatusResult, s conversion.Scope) error {
|
||||
if err := autoConvert_api_PodStatusResult_To_v1_PodStatusResult(in, out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -384,25 +385,25 @@ func Convert_api_PodStatusResult_To_v1_PodStatusResult(in *api.PodStatusResult,
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
out.Annotations[PodInitContainerStatusesAnnotationKey] = string(value)
|
||||
out.Annotations[PodInitContainerStatusesBetaAnnotationKey] = string(value)
|
||||
out.Annotations[v1.PodInitContainerStatusesAnnotationKey] = string(value)
|
||||
out.Annotations[v1.PodInitContainerStatusesBetaAnnotationKey] = string(value)
|
||||
} else {
|
||||
delete(out.Annotations, PodInitContainerStatusesAnnotationKey)
|
||||
delete(out.Annotations, PodInitContainerStatusesBetaAnnotationKey)
|
||||
delete(out.Annotations, v1.PodInitContainerStatusesAnnotationKey)
|
||||
delete(out.Annotations, v1.PodInitContainerStatusesBetaAnnotationKey)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_v1_PodStatusResult_To_api_PodStatusResult(in *PodStatusResult, out *api.PodStatusResult, s conversion.Scope) error {
|
||||
func Convert_v1_PodStatusResult_To_api_PodStatusResult(in *v1.PodStatusResult, out *api.PodStatusResult, s conversion.Scope) error {
|
||||
// TODO: sometime after we move init container to stable, remove these conversions
|
||||
// If there is a beta annotation, copy to alpha key.
|
||||
// See commit log for PR #31026 for why we do this.
|
||||
if valueBeta, okBeta := in.Annotations[PodInitContainerStatusesBetaAnnotationKey]; okBeta {
|
||||
in.Annotations[PodInitContainerStatusesAnnotationKey] = valueBeta
|
||||
if valueBeta, okBeta := in.Annotations[v1.PodInitContainerStatusesBetaAnnotationKey]; okBeta {
|
||||
in.Annotations[v1.PodInitContainerStatusesAnnotationKey] = valueBeta
|
||||
}
|
||||
// Move the annotation to the internal repr. field
|
||||
if value, ok := in.Annotations[PodInitContainerStatusesAnnotationKey]; ok {
|
||||
var values []ContainerStatus
|
||||
if value, ok := in.Annotations[v1.PodInitContainerStatusesAnnotationKey]; ok {
|
||||
var values []v1.ContainerStatus
|
||||
if err := json.Unmarshal([]byte(value), &values); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -424,13 +425,13 @@ func Convert_v1_PodStatusResult_To_api_PodStatusResult(in *PodStatusResult, out
|
|||
for k, v := range old {
|
||||
out.Annotations[k] = v
|
||||
}
|
||||
delete(out.Annotations, PodInitContainerStatusesAnnotationKey)
|
||||
delete(out.Annotations, PodInitContainerStatusesBetaAnnotationKey)
|
||||
delete(out.Annotations, v1.PodInitContainerStatusesAnnotationKey)
|
||||
delete(out.Annotations, v1.PodInitContainerStatusesBetaAnnotationKey)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_api_PodTemplateSpec_To_v1_PodTemplateSpec(in *api.PodTemplateSpec, out *PodTemplateSpec, s conversion.Scope) error {
|
||||
func Convert_api_PodTemplateSpec_To_v1_PodTemplateSpec(in *api.PodTemplateSpec, out *v1.PodTemplateSpec, s conversion.Scope) error {
|
||||
if err := autoConvert_api_PodTemplateSpec_To_v1_PodTemplateSpec(in, out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -450,25 +451,25 @@ func Convert_api_PodTemplateSpec_To_v1_PodTemplateSpec(in *api.PodTemplateSpec,
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
out.Annotations[PodInitContainersAnnotationKey] = string(value)
|
||||
out.Annotations[PodInitContainersBetaAnnotationKey] = string(value)
|
||||
out.Annotations[v1.PodInitContainersAnnotationKey] = string(value)
|
||||
out.Annotations[v1.PodInitContainersBetaAnnotationKey] = string(value)
|
||||
} else {
|
||||
delete(out.Annotations, PodInitContainersAnnotationKey)
|
||||
delete(out.Annotations, PodInitContainersBetaAnnotationKey)
|
||||
delete(out.Annotations, v1.PodInitContainersAnnotationKey)
|
||||
delete(out.Annotations, v1.PodInitContainersBetaAnnotationKey)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_v1_PodTemplateSpec_To_api_PodTemplateSpec(in *PodTemplateSpec, out *api.PodTemplateSpec, s conversion.Scope) error {
|
||||
func Convert_v1_PodTemplateSpec_To_api_PodTemplateSpec(in *v1.PodTemplateSpec, out *api.PodTemplateSpec, s conversion.Scope) error {
|
||||
// TODO: sometime after we move init container to stable, remove these conversions
|
||||
// If there is a beta annotation, copy to alpha key.
|
||||
// See commit log for PR #31026 for why we do this.
|
||||
if valueBeta, okBeta := in.Annotations[PodInitContainersBetaAnnotationKey]; okBeta {
|
||||
in.Annotations[PodInitContainersAnnotationKey] = valueBeta
|
||||
if valueBeta, okBeta := in.Annotations[v1.PodInitContainersBetaAnnotationKey]; okBeta {
|
||||
in.Annotations[v1.PodInitContainersAnnotationKey] = valueBeta
|
||||
}
|
||||
// Move the annotation to the internal repr. field
|
||||
if value, ok := in.Annotations[PodInitContainersAnnotationKey]; ok {
|
||||
var values []Container
|
||||
if value, ok := in.Annotations[v1.PodInitContainersAnnotationKey]; ok {
|
||||
var values []v1.Container
|
||||
if err := json.Unmarshal([]byte(value), &values); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -481,9 +482,9 @@ func Convert_v1_PodTemplateSpec_To_api_PodTemplateSpec(in *PodTemplateSpec, out
|
|||
in.Spec.InitContainers = values
|
||||
|
||||
// Call defaulters explicitly until annotations are removed
|
||||
tmpPodTemp := &PodTemplate{
|
||||
Template: PodTemplateSpec{
|
||||
Spec: PodSpec{
|
||||
tmpPodTemp := &v1.PodTemplate{
|
||||
Template: v1.PodTemplateSpec{
|
||||
Spec: v1.PodSpec{
|
||||
HostNetwork: in.Spec.HostNetwork,
|
||||
InitContainers: values,
|
||||
},
|
||||
|
@ -502,15 +503,15 @@ func Convert_v1_PodTemplateSpec_To_api_PodTemplateSpec(in *PodTemplateSpec, out
|
|||
for k, v := range old {
|
||||
out.Annotations[k] = v
|
||||
}
|
||||
delete(out.Annotations, PodInitContainersAnnotationKey)
|
||||
delete(out.Annotations, PodInitContainersBetaAnnotationKey)
|
||||
delete(out.Annotations, v1.PodInitContainersAnnotationKey)
|
||||
delete(out.Annotations, v1.PodInitContainersBetaAnnotationKey)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// The following two PodSpec conversions are done here to support ServiceAccount
|
||||
// The following two v1.PodSpec conversions are done here to support v1.ServiceAccount
|
||||
// as an alias for ServiceAccountName.
|
||||
func Convert_api_PodSpec_To_v1_PodSpec(in *api.PodSpec, out *PodSpec, s conversion.Scope) error {
|
||||
func Convert_api_PodSpec_To_v1_PodSpec(in *api.PodSpec, out *v1.PodSpec, s conversion.Scope) error {
|
||||
if err := autoConvert_api_PodSpec_To_v1_PodSpec(in, out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -529,7 +530,7 @@ func Convert_api_PodSpec_To_v1_PodSpec(in *api.PodSpec, out *PodSpec, s conversi
|
|||
return nil
|
||||
}
|
||||
|
||||
func Convert_v1_PodSpec_To_api_PodSpec(in *PodSpec, out *api.PodSpec, s conversion.Scope) error {
|
||||
func Convert_v1_PodSpec_To_api_PodSpec(in *v1.PodSpec, out *api.PodSpec, s conversion.Scope) error {
|
||||
if err := autoConvert_v1_PodSpec_To_api_PodSpec(in, out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -552,7 +553,7 @@ func Convert_v1_PodSpec_To_api_PodSpec(in *PodSpec, out *api.PodSpec, s conversi
|
|||
return nil
|
||||
}
|
||||
|
||||
func Convert_api_Pod_To_v1_Pod(in *api.Pod, out *Pod, s conversion.Scope) error {
|
||||
func Convert_api_Pod_To_v1_Pod(in *api.Pod, out *v1.Pod, s conversion.Scope) error {
|
||||
if err := autoConvert_api_Pod_To_v1_Pod(in, out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -564,41 +565,41 @@ func Convert_api_Pod_To_v1_Pod(in *api.Pod, out *Pod, s conversion.Scope) error
|
|||
for k, v := range old {
|
||||
out.Annotations[k] = v
|
||||
}
|
||||
delete(out.Annotations, PodInitContainersAnnotationKey)
|
||||
delete(out.Annotations, PodInitContainersBetaAnnotationKey)
|
||||
delete(out.Annotations, PodInitContainerStatusesAnnotationKey)
|
||||
delete(out.Annotations, PodInitContainerStatusesBetaAnnotationKey)
|
||||
delete(out.Annotations, v1.PodInitContainersAnnotationKey)
|
||||
delete(out.Annotations, v1.PodInitContainersBetaAnnotationKey)
|
||||
delete(out.Annotations, v1.PodInitContainerStatusesAnnotationKey)
|
||||
delete(out.Annotations, v1.PodInitContainerStatusesBetaAnnotationKey)
|
||||
}
|
||||
if len(out.Spec.InitContainers) > 0 {
|
||||
value, err := json.Marshal(out.Spec.InitContainers)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
out.Annotations[PodInitContainersAnnotationKey] = string(value)
|
||||
out.Annotations[PodInitContainersBetaAnnotationKey] = string(value)
|
||||
out.Annotations[v1.PodInitContainersAnnotationKey] = string(value)
|
||||
out.Annotations[v1.PodInitContainersBetaAnnotationKey] = string(value)
|
||||
}
|
||||
if len(out.Status.InitContainerStatuses) > 0 {
|
||||
value, err := json.Marshal(out.Status.InitContainerStatuses)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
out.Annotations[PodInitContainerStatusesAnnotationKey] = string(value)
|
||||
out.Annotations[PodInitContainerStatusesBetaAnnotationKey] = string(value)
|
||||
out.Annotations[v1.PodInitContainerStatusesAnnotationKey] = string(value)
|
||||
out.Annotations[v1.PodInitContainerStatusesBetaAnnotationKey] = string(value)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_v1_Pod_To_api_Pod(in *Pod, out *api.Pod, s conversion.Scope) error {
|
||||
func Convert_v1_Pod_To_api_Pod(in *v1.Pod, out *api.Pod, s conversion.Scope) error {
|
||||
// If there is a beta annotation, copy to alpha key.
|
||||
// See commit log for PR #31026 for why we do this.
|
||||
if valueBeta, okBeta := in.Annotations[PodInitContainersBetaAnnotationKey]; okBeta {
|
||||
in.Annotations[PodInitContainersAnnotationKey] = valueBeta
|
||||
if valueBeta, okBeta := in.Annotations[v1.PodInitContainersBetaAnnotationKey]; okBeta {
|
||||
in.Annotations[v1.PodInitContainersAnnotationKey] = valueBeta
|
||||
}
|
||||
// TODO: sometime after we move init container to stable, remove these conversions
|
||||
// Move the annotation to the internal repr. field
|
||||
if value, ok := in.Annotations[PodInitContainersAnnotationKey]; ok {
|
||||
var values []Container
|
||||
if value, ok := in.Annotations[v1.PodInitContainersAnnotationKey]; ok {
|
||||
var values []v1.Container
|
||||
if err := json.Unmarshal([]byte(value), &values); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -610,8 +611,8 @@ func Convert_v1_Pod_To_api_Pod(in *Pod, out *api.Pod, s conversion.Scope) error
|
|||
// back to the caller.
|
||||
in.Spec.InitContainers = values
|
||||
// Call defaulters explicitly until annotations are removed
|
||||
tmpPod := &Pod{
|
||||
Spec: PodSpec{
|
||||
tmpPod := &v1.Pod{
|
||||
Spec: v1.PodSpec{
|
||||
HostNetwork: in.Spec.HostNetwork,
|
||||
InitContainers: values,
|
||||
},
|
||||
|
@ -621,11 +622,11 @@ func Convert_v1_Pod_To_api_Pod(in *Pod, out *api.Pod, s conversion.Scope) error
|
|||
}
|
||||
// If there is a beta annotation, copy to alpha key.
|
||||
// See commit log for PR #31026 for why we do this.
|
||||
if valueBeta, okBeta := in.Annotations[PodInitContainerStatusesBetaAnnotationKey]; okBeta {
|
||||
in.Annotations[PodInitContainerStatusesAnnotationKey] = valueBeta
|
||||
if valueBeta, okBeta := in.Annotations[v1.PodInitContainerStatusesBetaAnnotationKey]; okBeta {
|
||||
in.Annotations[v1.PodInitContainerStatusesAnnotationKey] = valueBeta
|
||||
}
|
||||
if value, ok := in.Annotations[PodInitContainerStatusesAnnotationKey]; ok {
|
||||
var values []ContainerStatus
|
||||
if value, ok := in.Annotations[v1.PodInitContainerStatusesAnnotationKey]; ok {
|
||||
var values []v1.ContainerStatus
|
||||
if err := json.Unmarshal([]byte(value), &values); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -647,15 +648,15 @@ func Convert_v1_Pod_To_api_Pod(in *Pod, out *api.Pod, s conversion.Scope) error
|
|||
for k, v := range old {
|
||||
out.Annotations[k] = v
|
||||
}
|
||||
delete(out.Annotations, PodInitContainersAnnotationKey)
|
||||
delete(out.Annotations, PodInitContainersBetaAnnotationKey)
|
||||
delete(out.Annotations, PodInitContainerStatusesAnnotationKey)
|
||||
delete(out.Annotations, PodInitContainerStatusesBetaAnnotationKey)
|
||||
delete(out.Annotations, v1.PodInitContainersAnnotationKey)
|
||||
delete(out.Annotations, v1.PodInitContainersBetaAnnotationKey)
|
||||
delete(out.Annotations, v1.PodInitContainerStatusesAnnotationKey)
|
||||
delete(out.Annotations, v1.PodInitContainerStatusesBetaAnnotationKey)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_v1_Secret_To_api_Secret(in *Secret, out *api.Secret, s conversion.Scope) error {
|
||||
func Convert_v1_Secret_To_api_Secret(in *v1.Secret, out *api.Secret, s conversion.Scope) error {
|
||||
if err := autoConvert_v1_Secret_To_api_Secret(in, out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -673,10 +674,10 @@ func Convert_v1_Secret_To_api_Secret(in *Secret, out *api.Secret, s conversion.S
|
|||
return nil
|
||||
}
|
||||
|
||||
func Convert_api_PodSecurityContext_To_v1_PodSecurityContext(in *api.PodSecurityContext, out *PodSecurityContext, s conversion.Scope) error {
|
||||
func Convert_api_PodSecurityContext_To_v1_PodSecurityContext(in *api.PodSecurityContext, out *v1.PodSecurityContext, s conversion.Scope) error {
|
||||
out.SupplementalGroups = in.SupplementalGroups
|
||||
if in.SELinuxOptions != nil {
|
||||
out.SELinuxOptions = new(SELinuxOptions)
|
||||
out.SELinuxOptions = new(v1.SELinuxOptions)
|
||||
if err := Convert_api_SELinuxOptions_To_v1_SELinuxOptions(in.SELinuxOptions, out.SELinuxOptions, s); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -689,7 +690,7 @@ func Convert_api_PodSecurityContext_To_v1_PodSecurityContext(in *api.PodSecurity
|
|||
return nil
|
||||
}
|
||||
|
||||
func Convert_v1_PodSecurityContext_To_api_PodSecurityContext(in *PodSecurityContext, out *api.PodSecurityContext, s conversion.Scope) error {
|
||||
func Convert_v1_PodSecurityContext_To_api_PodSecurityContext(in *v1.PodSecurityContext, out *api.PodSecurityContext, s conversion.Scope) error {
|
||||
out.SupplementalGroups = in.SupplementalGroups
|
||||
if in.SELinuxOptions != nil {
|
||||
out.SELinuxOptions = new(api.SELinuxOptions)
|
||||
|
@ -706,7 +707,7 @@ func Convert_v1_PodSecurityContext_To_api_PodSecurityContext(in *PodSecurityCont
|
|||
}
|
||||
|
||||
// +k8s:conversion-fn=copy-only
|
||||
func Convert_v1_ResourceList_To_api_ResourceList(in *ResourceList, out *api.ResourceList, s conversion.Scope) error {
|
||||
func Convert_v1_ResourceList_To_api_ResourceList(in *v1.ResourceList, out *api.ResourceList, s conversion.Scope) error {
|
||||
if *in == nil {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
package v1_test
|
||||
|
||||
import (
|
||||
"k8s.io/api/core/v1"
|
||||
"net/url"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
@ -38,7 +39,7 @@ func TestPodLogOptions(t *testing.T) {
|
|||
limitBytes := int64(3)
|
||||
|
||||
versionedLogOptions := &v1.PodLogOptions{
|
||||
Container: "mycontainer",
|
||||
v1.Container: "mycontainer",
|
||||
Follow: true,
|
||||
Previous: true,
|
||||
SinceSeconds: &sinceSeconds,
|
||||
|
@ -48,7 +49,7 @@ func TestPodLogOptions(t *testing.T) {
|
|||
LimitBytes: &limitBytes,
|
||||
}
|
||||
unversionedLogOptions := &api.PodLogOptions{
|
||||
Container: "mycontainer",
|
||||
v1.Container: "mycontainer",
|
||||
Follow: true,
|
||||
Previous: true,
|
||||
SinceSeconds: &sinceSeconds,
|
||||
|
@ -117,7 +118,7 @@ func TestPodLogOptions(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// TestPodSpecConversion tests that ServiceAccount is an alias for
|
||||
// TestPodSpecConversion tests that v1.ServiceAccount is an alias for
|
||||
// ServiceAccountName.
|
||||
func TestPodSpecConversion(t *testing.T) {
|
||||
name, other := "foo", "bar"
|
||||
|
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
package v1
|
||||
|
||||
import (
|
||||
"k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
|
@ -27,26 +28,26 @@ func addDefaultingFuncs(scheme *runtime.Scheme) error {
|
|||
return RegisterDefaults(scheme)
|
||||
}
|
||||
|
||||
func SetDefaults_ResourceList(obj *ResourceList) {
|
||||
func SetDefaults_ResourceList(obj *v1.ResourceList) {
|
||||
for key, val := range *obj {
|
||||
// TODO(#18538): We round up resource values to milli scale to maintain API compatibility.
|
||||
// In the future, we should instead reject values that need rounding.
|
||||
const milliScale = -3
|
||||
val.RoundUp(milliScale)
|
||||
|
||||
(*obj)[ResourceName(key)] = val
|
||||
(*obj)[v1.ResourceName(key)] = val
|
||||
}
|
||||
}
|
||||
|
||||
func SetDefaults_PodExecOptions(obj *PodExecOptions) {
|
||||
func SetDefaults_PodExecOptions(obj *v1.PodExecOptions) {
|
||||
obj.Stdout = true
|
||||
obj.Stderr = true
|
||||
}
|
||||
func SetDefaults_PodAttachOptions(obj *PodAttachOptions) {
|
||||
func SetDefaults_PodAttachOptions(obj *v1.PodAttachOptions) {
|
||||
obj.Stdout = true
|
||||
obj.Stderr = true
|
||||
}
|
||||
func SetDefaults_ReplicationController(obj *ReplicationController) {
|
||||
func SetDefaults_ReplicationController(obj *v1.ReplicationController) {
|
||||
var labels map[string]string
|
||||
if obj.Spec.Template != nil {
|
||||
labels = obj.Spec.Template.Labels
|
||||
|
@ -65,48 +66,48 @@ func SetDefaults_ReplicationController(obj *ReplicationController) {
|
|||
*obj.Spec.Replicas = 1
|
||||
}
|
||||
}
|
||||
func SetDefaults_Volume(obj *Volume) {
|
||||
func SetDefaults_Volume(obj *v1.Volume) {
|
||||
if util.AllPtrFieldsNil(&obj.VolumeSource) {
|
||||
obj.VolumeSource = VolumeSource{
|
||||
EmptyDir: &EmptyDirVolumeSource{},
|
||||
obj.VolumeSource = v1.VolumeSource{
|
||||
EmptyDir: &v1.EmptyDirVolumeSource{},
|
||||
}
|
||||
}
|
||||
}
|
||||
func SetDefaults_ContainerPort(obj *ContainerPort) {
|
||||
func SetDefaults_ContainerPort(obj *v1.ContainerPort) {
|
||||
if obj.Protocol == "" {
|
||||
obj.Protocol = ProtocolTCP
|
||||
obj.Protocol = v1.ProtocolTCP
|
||||
}
|
||||
}
|
||||
func SetDefaults_Container(obj *Container) {
|
||||
func SetDefaults_Container(obj *v1.Container) {
|
||||
if obj.ImagePullPolicy == "" {
|
||||
// Ignore error and assume it has been validated elsewhere
|
||||
_, tag, _, _ := parsers.ParseImageName(obj.Image)
|
||||
|
||||
// Check image tag
|
||||
if tag == "latest" {
|
||||
obj.ImagePullPolicy = PullAlways
|
||||
obj.ImagePullPolicy = v1.PullAlways
|
||||
} else {
|
||||
obj.ImagePullPolicy = PullIfNotPresent
|
||||
obj.ImagePullPolicy = v1.PullIfNotPresent
|
||||
}
|
||||
}
|
||||
if obj.TerminationMessagePath == "" {
|
||||
obj.TerminationMessagePath = TerminationMessagePathDefault
|
||||
obj.TerminationMessagePath = v1.TerminationMessagePathDefault
|
||||
}
|
||||
if obj.TerminationMessagePolicy == "" {
|
||||
obj.TerminationMessagePolicy = TerminationMessageReadFile
|
||||
obj.TerminationMessagePolicy = v1.TerminationMessageReadFile
|
||||
}
|
||||
}
|
||||
func SetDefaults_Service(obj *Service) {
|
||||
func SetDefaults_Service(obj *v1.Service) {
|
||||
if obj.Spec.SessionAffinity == "" {
|
||||
obj.Spec.SessionAffinity = ServiceAffinityNone
|
||||
obj.Spec.SessionAffinity = v1.ServiceAffinityNone
|
||||
}
|
||||
if obj.Spec.Type == "" {
|
||||
obj.Spec.Type = ServiceTypeClusterIP
|
||||
obj.Spec.Type = v1.ServiceTypeClusterIP
|
||||
}
|
||||
for i := range obj.Spec.Ports {
|
||||
sp := &obj.Spec.Ports[i]
|
||||
if sp.Protocol == "" {
|
||||
sp.Protocol = ProtocolTCP
|
||||
sp.Protocol = v1.ProtocolTCP
|
||||
}
|
||||
if sp.TargetPort == intstr.FromInt(0) || sp.TargetPort == intstr.FromString("") {
|
||||
sp.TargetPort = intstr.FromInt(int(sp.Port))
|
||||
|
@ -114,24 +115,24 @@ func SetDefaults_Service(obj *Service) {
|
|||
}
|
||||
// Defaults ExternalTrafficPolicy field for NodePort / LoadBalancer service
|
||||
// to Global for consistency.
|
||||
if _, ok := obj.Annotations[BetaAnnotationExternalTraffic]; ok {
|
||||
if _, ok := obj.Annotations[v1.BetaAnnotationExternalTraffic]; ok {
|
||||
// Don't default this field if beta annotation exists.
|
||||
return
|
||||
} else if (obj.Spec.Type == ServiceTypeNodePort ||
|
||||
obj.Spec.Type == ServiceTypeLoadBalancer) &&
|
||||
} else if (obj.Spec.Type == v1.ServiceTypeNodePort ||
|
||||
obj.Spec.Type == v1.ServiceTypeLoadBalancer) &&
|
||||
obj.Spec.ExternalTrafficPolicy == "" {
|
||||
obj.Spec.ExternalTrafficPolicy = ServiceExternalTrafficPolicyTypeCluster
|
||||
obj.Spec.ExternalTrafficPolicy = v1.ServiceExternalTrafficPolicyTypeCluster
|
||||
}
|
||||
}
|
||||
func SetDefaults_Pod(obj *Pod) {
|
||||
func SetDefaults_Pod(obj *v1.Pod) {
|
||||
// If limits are specified, but requests are not, default requests to limits
|
||||
// This is done here rather than a more specific defaulting pass on ResourceRequirements
|
||||
// because we only want this defaulting semantic to take place on a Pod and not a PodTemplate
|
||||
// This is done here rather than a more specific defaulting pass on v1.ResourceRequirements
|
||||
// because we only want this defaulting semantic to take place on a v1.Pod and not a v1.PodTemplate
|
||||
for i := range obj.Spec.Containers {
|
||||
// set requests to limits if requests are not specified, but limits are
|
||||
if obj.Spec.Containers[i].Resources.Limits != nil {
|
||||
if obj.Spec.Containers[i].Resources.Requests == nil {
|
||||
obj.Spec.Containers[i].Resources.Requests = make(ResourceList)
|
||||
obj.Spec.Containers[i].Resources.Requests = make(v1.ResourceList)
|
||||
}
|
||||
for key, value := range obj.Spec.Containers[i].Resources.Limits {
|
||||
if _, exists := obj.Spec.Containers[i].Resources.Requests[key]; !exists {
|
||||
|
@ -143,7 +144,7 @@ func SetDefaults_Pod(obj *Pod) {
|
|||
for i := range obj.Spec.InitContainers {
|
||||
if obj.Spec.InitContainers[i].Resources.Limits != nil {
|
||||
if obj.Spec.InitContainers[i].Resources.Requests == nil {
|
||||
obj.Spec.InitContainers[i].Resources.Requests = make(ResourceList)
|
||||
obj.Spec.InitContainers[i].Resources.Requests = make(v1.ResourceList)
|
||||
}
|
||||
for key, value := range obj.Spec.InitContainers[i].Resources.Limits {
|
||||
if _, exists := obj.Spec.InitContainers[i].Resources.Requests[key]; !exists {
|
||||
|
@ -153,29 +154,29 @@ func SetDefaults_Pod(obj *Pod) {
|
|||
}
|
||||
}
|
||||
}
|
||||
func SetDefaults_PodSpec(obj *PodSpec) {
|
||||
func SetDefaults_PodSpec(obj *v1.PodSpec) {
|
||||
if obj.DNSPolicy == "" {
|
||||
obj.DNSPolicy = DNSClusterFirst
|
||||
obj.DNSPolicy = v1.DNSClusterFirst
|
||||
}
|
||||
if obj.RestartPolicy == "" {
|
||||
obj.RestartPolicy = RestartPolicyAlways
|
||||
obj.RestartPolicy = v1.RestartPolicyAlways
|
||||
}
|
||||
if obj.HostNetwork {
|
||||
defaultHostNetworkPorts(&obj.Containers)
|
||||
defaultHostNetworkPorts(&obj.InitContainers)
|
||||
}
|
||||
if obj.SecurityContext == nil {
|
||||
obj.SecurityContext = &PodSecurityContext{}
|
||||
obj.SecurityContext = &v1.PodSecurityContext{}
|
||||
}
|
||||
if obj.TerminationGracePeriodSeconds == nil {
|
||||
period := int64(DefaultTerminationGracePeriodSeconds)
|
||||
period := int64(v1.DefaultTerminationGracePeriodSeconds)
|
||||
obj.TerminationGracePeriodSeconds = &period
|
||||
}
|
||||
if obj.SchedulerName == "" {
|
||||
obj.SchedulerName = DefaultSchedulerName
|
||||
obj.SchedulerName = v1.DefaultSchedulerName
|
||||
}
|
||||
}
|
||||
func SetDefaults_Probe(obj *Probe) {
|
||||
func SetDefaults_Probe(obj *v1.Probe) {
|
||||
if obj.TimeoutSeconds == 0 {
|
||||
obj.TimeoutSeconds = 1
|
||||
}
|
||||
|
@ -189,61 +190,61 @@ func SetDefaults_Probe(obj *Probe) {
|
|||
obj.FailureThreshold = 3
|
||||
}
|
||||
}
|
||||
func SetDefaults_SecretVolumeSource(obj *SecretVolumeSource) {
|
||||
func SetDefaults_SecretVolumeSource(obj *v1.SecretVolumeSource) {
|
||||
if obj.DefaultMode == nil {
|
||||
perm := int32(SecretVolumeSourceDefaultMode)
|
||||
perm := int32(v1.SecretVolumeSourceDefaultMode)
|
||||
obj.DefaultMode = &perm
|
||||
}
|
||||
}
|
||||
func SetDefaults_ConfigMapVolumeSource(obj *ConfigMapVolumeSource) {
|
||||
func SetDefaults_ConfigMapVolumeSource(obj *v1.ConfigMapVolumeSource) {
|
||||
if obj.DefaultMode == nil {
|
||||
perm := int32(ConfigMapVolumeSourceDefaultMode)
|
||||
perm := int32(v1.ConfigMapVolumeSourceDefaultMode)
|
||||
obj.DefaultMode = &perm
|
||||
}
|
||||
}
|
||||
func SetDefaults_DownwardAPIVolumeSource(obj *DownwardAPIVolumeSource) {
|
||||
func SetDefaults_DownwardAPIVolumeSource(obj *v1.DownwardAPIVolumeSource) {
|
||||
if obj.DefaultMode == nil {
|
||||
perm := int32(DownwardAPIVolumeSourceDefaultMode)
|
||||
perm := int32(v1.DownwardAPIVolumeSourceDefaultMode)
|
||||
obj.DefaultMode = &perm
|
||||
}
|
||||
}
|
||||
func SetDefaults_Secret(obj *Secret) {
|
||||
func SetDefaults_Secret(obj *v1.Secret) {
|
||||
if obj.Type == "" {
|
||||
obj.Type = SecretTypeOpaque
|
||||
obj.Type = v1.SecretTypeOpaque
|
||||
}
|
||||
}
|
||||
func SetDefaults_ProjectedVolumeSource(obj *ProjectedVolumeSource) {
|
||||
func SetDefaults_ProjectedVolumeSource(obj *v1.ProjectedVolumeSource) {
|
||||
if obj.DefaultMode == nil {
|
||||
perm := int32(ProjectedVolumeSourceDefaultMode)
|
||||
perm := int32(v1.ProjectedVolumeSourceDefaultMode)
|
||||
obj.DefaultMode = &perm
|
||||
}
|
||||
}
|
||||
func SetDefaults_PersistentVolume(obj *PersistentVolume) {
|
||||
func SetDefaults_PersistentVolume(obj *v1.PersistentVolume) {
|
||||
if obj.Status.Phase == "" {
|
||||
obj.Status.Phase = VolumePending
|
||||
obj.Status.Phase = v1.VolumePending
|
||||
}
|
||||
if obj.Spec.PersistentVolumeReclaimPolicy == "" {
|
||||
obj.Spec.PersistentVolumeReclaimPolicy = PersistentVolumeReclaimRetain
|
||||
obj.Spec.PersistentVolumeReclaimPolicy = v1.PersistentVolumeReclaimRetain
|
||||
}
|
||||
}
|
||||
func SetDefaults_PersistentVolumeClaim(obj *PersistentVolumeClaim) {
|
||||
func SetDefaults_PersistentVolumeClaim(obj *v1.PersistentVolumeClaim) {
|
||||
if obj.Status.Phase == "" {
|
||||
obj.Status.Phase = ClaimPending
|
||||
obj.Status.Phase = v1.ClaimPending
|
||||
}
|
||||
}
|
||||
func SetDefaults_ISCSIVolumeSource(obj *ISCSIVolumeSource) {
|
||||
func SetDefaults_ISCSIVolumeSource(obj *v1.ISCSIVolumeSource) {
|
||||
if obj.ISCSIInterface == "" {
|
||||
obj.ISCSIInterface = "default"
|
||||
}
|
||||
}
|
||||
func SetDefaults_AzureDiskVolumeSource(obj *AzureDiskVolumeSource) {
|
||||
func SetDefaults_AzureDiskVolumeSource(obj *v1.AzureDiskVolumeSource) {
|
||||
if obj.CachingMode == nil {
|
||||
obj.CachingMode = new(AzureDataDiskCachingMode)
|
||||
*obj.CachingMode = AzureDataDiskCachingReadWrite
|
||||
obj.CachingMode = new(v1.AzureDataDiskCachingMode)
|
||||
*obj.CachingMode = v1.AzureDataDiskCachingReadWrite
|
||||
}
|
||||
if obj.Kind == nil {
|
||||
obj.Kind = new(AzureDataDiskKind)
|
||||
*obj.Kind = AzureSharedBlobDisk
|
||||
obj.Kind = new(v1.AzureDataDiskKind)
|
||||
*obj.Kind = v1.AzureSharedBlobDisk
|
||||
}
|
||||
if obj.FSType == nil {
|
||||
obj.FSType = new(string)
|
||||
|
@ -254,58 +255,58 @@ func SetDefaults_AzureDiskVolumeSource(obj *AzureDiskVolumeSource) {
|
|||
*obj.ReadOnly = false
|
||||
}
|
||||
}
|
||||
func SetDefaults_Endpoints(obj *Endpoints) {
|
||||
func SetDefaults_Endpoints(obj *v1.Endpoints) {
|
||||
for i := range obj.Subsets {
|
||||
ss := &obj.Subsets[i]
|
||||
for i := range ss.Ports {
|
||||
ep := &ss.Ports[i]
|
||||
if ep.Protocol == "" {
|
||||
ep.Protocol = ProtocolTCP
|
||||
ep.Protocol = v1.ProtocolTCP
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
func SetDefaults_HTTPGetAction(obj *HTTPGetAction) {
|
||||
func SetDefaults_HTTPGetAction(obj *v1.HTTPGetAction) {
|
||||
if obj.Path == "" {
|
||||
obj.Path = "/"
|
||||
}
|
||||
if obj.Scheme == "" {
|
||||
obj.Scheme = URISchemeHTTP
|
||||
obj.Scheme = v1.URISchemeHTTP
|
||||
}
|
||||
}
|
||||
func SetDefaults_NamespaceStatus(obj *NamespaceStatus) {
|
||||
func SetDefaults_NamespaceStatus(obj *v1.NamespaceStatus) {
|
||||
if obj.Phase == "" {
|
||||
obj.Phase = NamespaceActive
|
||||
obj.Phase = v1.NamespaceActive
|
||||
}
|
||||
}
|
||||
func SetDefaults_Node(obj *Node) {
|
||||
func SetDefaults_Node(obj *v1.Node) {
|
||||
if obj.Spec.ExternalID == "" {
|
||||
obj.Spec.ExternalID = obj.Name
|
||||
}
|
||||
}
|
||||
func SetDefaults_NodeStatus(obj *NodeStatus) {
|
||||
func SetDefaults_NodeStatus(obj *v1.NodeStatus) {
|
||||
if obj.Allocatable == nil && obj.Capacity != nil {
|
||||
obj.Allocatable = make(ResourceList, len(obj.Capacity))
|
||||
obj.Allocatable = make(v1.ResourceList, len(obj.Capacity))
|
||||
for key, value := range obj.Capacity {
|
||||
obj.Allocatable[key] = *(value.Copy())
|
||||
}
|
||||
obj.Allocatable = obj.Capacity
|
||||
}
|
||||
}
|
||||
func SetDefaults_ObjectFieldSelector(obj *ObjectFieldSelector) {
|
||||
func SetDefaults_ObjectFieldSelector(obj *v1.ObjectFieldSelector) {
|
||||
if obj.APIVersion == "" {
|
||||
obj.APIVersion = "v1"
|
||||
}
|
||||
}
|
||||
func SetDefaults_LimitRangeItem(obj *LimitRangeItem) {
|
||||
func SetDefaults_LimitRangeItem(obj *v1.LimitRangeItem) {
|
||||
// for container limits, we apply default values
|
||||
if obj.Type == LimitTypeContainer {
|
||||
if obj.Type == v1.LimitTypeContainer {
|
||||
|
||||
if obj.Default == nil {
|
||||
obj.Default = make(ResourceList)
|
||||
obj.Default = make(v1.ResourceList)
|
||||
}
|
||||
if obj.DefaultRequest == nil {
|
||||
obj.DefaultRequest = make(ResourceList)
|
||||
obj.DefaultRequest = make(v1.ResourceList)
|
||||
}
|
||||
|
||||
// If a default limit is unspecified, but the max is specified, default the limit to the max
|
||||
|
@ -328,14 +329,14 @@ func SetDefaults_LimitRangeItem(obj *LimitRangeItem) {
|
|||
}
|
||||
}
|
||||
}
|
||||
func SetDefaults_ConfigMap(obj *ConfigMap) {
|
||||
func SetDefaults_ConfigMap(obj *v1.ConfigMap) {
|
||||
if obj.Data == nil {
|
||||
obj.Data = make(map[string]string)
|
||||
}
|
||||
}
|
||||
|
||||
// With host networking default all container ports to host ports.
|
||||
func defaultHostNetworkPorts(containers *[]Container) {
|
||||
func defaultHostNetworkPorts(containers *[]v1.Container) {
|
||||
for i := range *containers {
|
||||
for j := range (*containers)[i].Ports {
|
||||
if (*containers)[i].Ports[j].HostPort == 0 {
|
||||
|
@ -345,7 +346,7 @@ func defaultHostNetworkPorts(containers *[]Container) {
|
|||
}
|
||||
}
|
||||
|
||||
func SetDefaults_RBDVolumeSource(obj *RBDVolumeSource) {
|
||||
func SetDefaults_RBDVolumeSource(obj *v1.RBDVolumeSource) {
|
||||
if obj.RBDPool == "" {
|
||||
obj.RBDPool = "rbd"
|
||||
}
|
||||
|
@ -357,7 +358,7 @@ func SetDefaults_RBDVolumeSource(obj *RBDVolumeSource) {
|
|||
}
|
||||
}
|
||||
|
||||
func SetDefaults_ScaleIOVolumeSource(obj *ScaleIOVolumeSource) {
|
||||
func SetDefaults_ScaleIOVolumeSource(obj *v1.ScaleIOVolumeSource) {
|
||||
if obj.ProtectionDomain == "" {
|
||||
obj.ProtectionDomain = "default"
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
package v1_test
|
||||
|
||||
import (
|
||||
"k8s.io/api/core/v1"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
@ -60,7 +61,7 @@ func TestSetDefaultReplicationController(t *testing.T) {
|
|||
rc: &v1.ReplicationController{
|
||||
Spec: v1.ReplicationControllerSpec{
|
||||
Template: &v1.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
v1.ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
|
@ -73,14 +74,14 @@ func TestSetDefaultReplicationController(t *testing.T) {
|
|||
},
|
||||
{
|
||||
rc: &v1.ReplicationController{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
v1.ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"bar": "foo",
|
||||
},
|
||||
},
|
||||
Spec: v1.ReplicationControllerSpec{
|
||||
Template: &v1.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
v1.ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
|
@ -93,7 +94,7 @@ func TestSetDefaultReplicationController(t *testing.T) {
|
|||
},
|
||||
{
|
||||
rc: &v1.ReplicationController{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
v1.ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"bar": "foo",
|
||||
},
|
||||
|
@ -103,7 +104,7 @@ func TestSetDefaultReplicationController(t *testing.T) {
|
|||
"some": "other",
|
||||
},
|
||||
Template: &v1.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
v1.ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
|
@ -121,7 +122,7 @@ func TestSetDefaultReplicationController(t *testing.T) {
|
|||
"some": "other",
|
||||
},
|
||||
Template: &v1.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
v1.ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
|
@ -174,7 +175,7 @@ func TestSetDefaultReplicationControllerReplicas(t *testing.T) {
|
|||
rc: v1.ReplicationController{
|
||||
Spec: v1.ReplicationControllerSpec{
|
||||
Template: &v1.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
v1.ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
|
@ -189,7 +190,7 @@ func TestSetDefaultReplicationControllerReplicas(t *testing.T) {
|
|||
Spec: v1.ReplicationControllerSpec{
|
||||
Replicas: newInt(0),
|
||||
Template: &v1.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
v1.ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
|
@ -204,7 +205,7 @@ func TestSetDefaultReplicationControllerReplicas(t *testing.T) {
|
|||
Spec: v1.ReplicationControllerSpec{
|
||||
Replicas: newInt(3),
|
||||
Template: &v1.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
v1.ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
|
@ -363,7 +364,7 @@ func TestSetDefaultReplicationControllerInitContainers(t *testing.T) {
|
|||
rc: v1.ReplicationController{
|
||||
Spec: v1.ReplicationControllerSpec{
|
||||
Template: &v1.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
v1.ObjectMeta: metav1.ObjectMeta{
|
||||
Annotations: map[string]string{
|
||||
"pod.beta.kubernetes.io/init-containers": `
|
||||
[
|
||||
|
@ -389,7 +390,7 @@ func TestSetDefaultReplicationControllerInitContainers(t *testing.T) {
|
|||
rc: v1.ReplicationController{
|
||||
Spec: v1.ReplicationControllerSpec{
|
||||
Template: &v1.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
v1.ObjectMeta: metav1.ObjectMeta{
|
||||
Annotations: map[string]string{
|
||||
"pod.beta.kubernetes.io/init-containers": `
|
||||
[
|
||||
|
@ -436,7 +437,7 @@ func TestSetDefaultReplicationControllerInitContainers(t *testing.T) {
|
|||
rc: v1.ReplicationController{
|
||||
Spec: v1.ReplicationControllerSpec{
|
||||
Template: &v1.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
v1.ObjectMeta: metav1.ObjectMeta{
|
||||
Annotations: map[string]string{
|
||||
"pod.beta.kubernetes.io/init-containers": `
|
||||
[
|
||||
|
@ -460,7 +461,7 @@ func TestSetDefaultReplicationControllerInitContainers(t *testing.T) {
|
|||
Ports: []v1.ContainerPort{
|
||||
{
|
||||
Name: "default",
|
||||
Protocol: v1.ProtocolTCP,
|
||||
v1.Protocol: v1.ProtocolTCP,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -472,7 +473,7 @@ func TestSetDefaultReplicationControllerInitContainers(t *testing.T) {
|
|||
rc: v1.ReplicationController{
|
||||
Spec: v1.ReplicationControllerSpec{
|
||||
Template: &v1.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
v1.ObjectMeta: metav1.ObjectMeta{
|
||||
Annotations: map[string]string{
|
||||
"pod.beta.kubernetes.io/init-containers": `
|
||||
[
|
||||
|
@ -517,7 +518,7 @@ func TestSetDefaultReplicationControllerInitContainers(t *testing.T) {
|
|||
rc: v1.ReplicationController{
|
||||
Spec: v1.ReplicationControllerSpec{
|
||||
Template: &v1.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
v1.ObjectMeta: metav1.ObjectMeta{
|
||||
Annotations: map[string]string{
|
||||
"pod.beta.kubernetes.io/init-containers": `
|
||||
[
|
||||
|
@ -544,7 +545,7 @@ func TestSetDefaultReplicationControllerInitContainers(t *testing.T) {
|
|||
expected: []v1.Container{
|
||||
{
|
||||
LivenessProbe: &v1.Probe{
|
||||
Handler: v1.Handler{
|
||||
v1.Handler: v1.Handler{
|
||||
HTTPGet: &v1.HTTPGetAction{
|
||||
Path: "/",
|
||||
Scheme: v1.URISchemeHTTP,
|
||||
|
@ -556,7 +557,7 @@ func TestSetDefaultReplicationControllerInitContainers(t *testing.T) {
|
|||
FailureThreshold: 3,
|
||||
},
|
||||
ReadinessProbe: &v1.Probe{
|
||||
Handler: v1.Handler{
|
||||
v1.Handler: v1.Handler{
|
||||
HTTPGet: &v1.HTTPGetAction{
|
||||
Path: "/",
|
||||
Scheme: v1.URISchemeHTTP,
|
||||
|
@ -576,7 +577,7 @@ func TestSetDefaultReplicationControllerInitContainers(t *testing.T) {
|
|||
rc: v1.ReplicationController{
|
||||
Spec: v1.ReplicationControllerSpec{
|
||||
Template: &v1.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
v1.ObjectMeta: metav1.ObjectMeta{
|
||||
Annotations: map[string]string{
|
||||
"pod.beta.kubernetes.io/init-containers": `
|
||||
[
|
||||
|
@ -604,7 +605,7 @@ func TestSetDefaultReplicationControllerInitContainers(t *testing.T) {
|
|||
},
|
||||
expected: []v1.Container{
|
||||
{
|
||||
Lifecycle: &v1.Lifecycle{
|
||||
v1.Lifecycle: &v1.Lifecycle{
|
||||
PostStart: &v1.Handler{
|
||||
HTTPGet: &v1.HTTPGetAction{
|
||||
Path: "/",
|
||||
|
@ -675,8 +676,8 @@ func TestSetDefaultSecretVolumeSource(t *testing.T) {
|
|||
s := v1.PodSpec{}
|
||||
s.Volumes = []v1.Volume{
|
||||
{
|
||||
VolumeSource: v1.VolumeSource{
|
||||
Secret: &v1.SecretVolumeSource{},
|
||||
v1.VolumeSource: v1.VolumeSource{
|
||||
v1.Secret: &v1.SecretVolumeSource{},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -697,8 +698,8 @@ func TestSetDefaultConfigMapVolumeSource(t *testing.T) {
|
|||
s := v1.PodSpec{}
|
||||
s.Volumes = []v1.Volume{
|
||||
{
|
||||
VolumeSource: v1.VolumeSource{
|
||||
ConfigMap: &v1.ConfigMapVolumeSource{},
|
||||
v1.VolumeSource: v1.VolumeSource{
|
||||
v1.ConfigMap: &v1.ConfigMapVolumeSource{},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -711,7 +712,7 @@ func TestSetDefaultConfigMapVolumeSource(t *testing.T) {
|
|||
expectedMode := v1.ConfigMapVolumeSourceDefaultMode
|
||||
|
||||
if defaultMode == nil || *defaultMode != expectedMode {
|
||||
t.Errorf("Expected ConfigMap DefaultMode %v, got %v", expectedMode, defaultMode)
|
||||
t.Errorf("Expected v1.ConfigMap DefaultMode %v, got %v", expectedMode, defaultMode)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -719,7 +720,7 @@ func TestSetDefaultDownwardAPIVolumeSource(t *testing.T) {
|
|||
s := v1.PodSpec{}
|
||||
s.Volumes = []v1.Volume{
|
||||
{
|
||||
VolumeSource: v1.VolumeSource{
|
||||
v1.VolumeSource: v1.VolumeSource{
|
||||
DownwardAPI: &v1.DownwardAPIVolumeSource{},
|
||||
},
|
||||
},
|
||||
|
@ -741,7 +742,7 @@ func TestSetDefaultProjectedVolumeSource(t *testing.T) {
|
|||
s := v1.PodSpec{}
|
||||
s.Volumes = []v1.Volume{
|
||||
{
|
||||
VolumeSource: v1.VolumeSource{
|
||||
v1.VolumeSource: v1.VolumeSource{
|
||||
Projected: &v1.ProjectedVolumeSource{},
|
||||
},
|
||||
},
|
||||
|
@ -755,7 +756,7 @@ func TestSetDefaultProjectedVolumeSource(t *testing.T) {
|
|||
expectedMode := v1.ProjectedVolumeSourceDefaultMode
|
||||
|
||||
if defaultMode == nil || *defaultMode != expectedMode {
|
||||
t.Errorf("Expected ProjectedVolumeSource DefaultMode %v, got %v", expectedMode, defaultMode)
|
||||
t.Errorf("Expected v1.ProjectedVolumeSource DefaultMode %v, got %v", expectedMode, defaultMode)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -898,7 +899,7 @@ func TestSetDefaulServiceExternalTraffic(t *testing.T) {
|
|||
|
||||
in = &v1.Service{
|
||||
Spec: v1.ServiceSpec{Type: v1.ServiceTypeLoadBalancer},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
v1.ObjectMeta: metav1.ObjectMeta{
|
||||
Annotations: map[string]string{v1.BetaAnnotationExternalTraffic: v1.AnnotationValueExternalTrafficLocal},
|
||||
},
|
||||
}
|
||||
|
@ -927,7 +928,7 @@ func TestSetDefaultPodSpecHostNetwork(t *testing.T) {
|
|||
{
|
||||
Ports: []v1.ContainerPort{
|
||||
{
|
||||
ContainerPort: portNum,
|
||||
v1.ContainerPort: portNum,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -936,7 +937,7 @@ func TestSetDefaultPodSpecHostNetwork(t *testing.T) {
|
|||
{
|
||||
Ports: []v1.ContainerPort{
|
||||
{
|
||||
ContainerPort: portNum,
|
||||
v1.ContainerPort: portNum,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1042,7 +1043,7 @@ func TestSetDefaultNodeStatusAllocatable(t *testing.T) {
|
|||
actual := node2.Status.Allocatable
|
||||
expected := testcase.expectedAllocatable
|
||||
if !resourceListsEqual(expected, actual) {
|
||||
t.Errorf("[%d] Expected NodeStatus.Allocatable: %+v; Got: %+v", i, expected, actual)
|
||||
t.Errorf("[%d] Expected v1.NodeStatus.Allocatable: %+v; Got: %+v", i, expected, actual)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1197,7 +1198,7 @@ func TestDefaultRequestIsNotSetForReplicationController(t *testing.T) {
|
|||
Spec: v1.ReplicationControllerSpec{
|
||||
Replicas: newInt(3),
|
||||
Template: &v1.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
v1.ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
|
@ -1217,7 +1218,7 @@ func TestDefaultRequestIsNotSetForReplicationController(t *testing.T) {
|
|||
|
||||
func TestSetDefaultLimitRangeItem(t *testing.T) {
|
||||
limitRange := &v1.LimitRange{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
v1.ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "test-defaults",
|
||||
},
|
||||
Spec: v1.LimitRangeSpec{
|
||||
|
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
package v1
|
||||
|
||||
import (
|
||||
"k8s.io/api/core/v1"
|
||||
"fmt"
|
||||
|
||||
utilrand "k8s.io/apimachinery/pkg/util/rand"
|
||||
|
@ -31,10 +32,10 @@ type NameGenerator interface {
|
|||
GenerateName(base string) string
|
||||
}
|
||||
|
||||
// GenerateName will resolve the object name of the provided ObjectMeta to a generated version if
|
||||
// necessary. It expects that validation for ObjectMeta has already completed (that Base is a
|
||||
// GenerateName will resolve the object name of the provided v1.ObjectMeta to a generated version if
|
||||
// necessary. It expects that validation for v1.ObjectMeta has already completed (that Base is a
|
||||
// valid name) and that the NameGenerator generates a name that is also valid.
|
||||
func GenerateName(u NameGenerator, meta *ObjectMeta) {
|
||||
func GenerateName(u NameGenerator, meta *v1.ObjectMeta) {
|
||||
if len(meta.GenerateName) == 0 || len(meta.Name) != 0 {
|
||||
return
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -21,6 +21,7 @@ limitations under the License.
|
|||
package v1
|
||||
|
||||
import (
|
||||
"k8s.io/api/core/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
|
@ -28,60 +29,60 @@ 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(&ConfigMap{}, func(obj interface{}) { SetObjectDefaults_ConfigMap(obj.(*ConfigMap)) })
|
||||
scheme.AddTypeDefaultingFunc(&ConfigMapList{}, func(obj interface{}) { SetObjectDefaults_ConfigMapList(obj.(*ConfigMapList)) })
|
||||
scheme.AddTypeDefaultingFunc(&Endpoints{}, func(obj interface{}) { SetObjectDefaults_Endpoints(obj.(*Endpoints)) })
|
||||
scheme.AddTypeDefaultingFunc(&EndpointsList{}, func(obj interface{}) { SetObjectDefaults_EndpointsList(obj.(*EndpointsList)) })
|
||||
scheme.AddTypeDefaultingFunc(&LimitRange{}, func(obj interface{}) { SetObjectDefaults_LimitRange(obj.(*LimitRange)) })
|
||||
scheme.AddTypeDefaultingFunc(&LimitRangeList{}, func(obj interface{}) { SetObjectDefaults_LimitRangeList(obj.(*LimitRangeList)) })
|
||||
scheme.AddTypeDefaultingFunc(&Namespace{}, func(obj interface{}) { SetObjectDefaults_Namespace(obj.(*Namespace)) })
|
||||
scheme.AddTypeDefaultingFunc(&NamespaceList{}, func(obj interface{}) { SetObjectDefaults_NamespaceList(obj.(*NamespaceList)) })
|
||||
scheme.AddTypeDefaultingFunc(&Node{}, func(obj interface{}) { SetObjectDefaults_Node(obj.(*Node)) })
|
||||
scheme.AddTypeDefaultingFunc(&NodeList{}, func(obj interface{}) { SetObjectDefaults_NodeList(obj.(*NodeList)) })
|
||||
scheme.AddTypeDefaultingFunc(&PersistentVolume{}, func(obj interface{}) { SetObjectDefaults_PersistentVolume(obj.(*PersistentVolume)) })
|
||||
scheme.AddTypeDefaultingFunc(&PersistentVolumeClaim{}, func(obj interface{}) { SetObjectDefaults_PersistentVolumeClaim(obj.(*PersistentVolumeClaim)) })
|
||||
scheme.AddTypeDefaultingFunc(&PersistentVolumeClaimList{}, func(obj interface{}) { SetObjectDefaults_PersistentVolumeClaimList(obj.(*PersistentVolumeClaimList)) })
|
||||
scheme.AddTypeDefaultingFunc(&PersistentVolumeList{}, func(obj interface{}) { SetObjectDefaults_PersistentVolumeList(obj.(*PersistentVolumeList)) })
|
||||
scheme.AddTypeDefaultingFunc(&Pod{}, func(obj interface{}) { SetObjectDefaults_Pod(obj.(*Pod)) })
|
||||
scheme.AddTypeDefaultingFunc(&PodAttachOptions{}, func(obj interface{}) { SetObjectDefaults_PodAttachOptions(obj.(*PodAttachOptions)) })
|
||||
scheme.AddTypeDefaultingFunc(&PodExecOptions{}, func(obj interface{}) { SetObjectDefaults_PodExecOptions(obj.(*PodExecOptions)) })
|
||||
scheme.AddTypeDefaultingFunc(&PodList{}, func(obj interface{}) { SetObjectDefaults_PodList(obj.(*PodList)) })
|
||||
scheme.AddTypeDefaultingFunc(&PodTemplate{}, func(obj interface{}) { SetObjectDefaults_PodTemplate(obj.(*PodTemplate)) })
|
||||
scheme.AddTypeDefaultingFunc(&PodTemplateList{}, func(obj interface{}) { SetObjectDefaults_PodTemplateList(obj.(*PodTemplateList)) })
|
||||
scheme.AddTypeDefaultingFunc(&ReplicationController{}, func(obj interface{}) { SetObjectDefaults_ReplicationController(obj.(*ReplicationController)) })
|
||||
scheme.AddTypeDefaultingFunc(&ReplicationControllerList{}, func(obj interface{}) { SetObjectDefaults_ReplicationControllerList(obj.(*ReplicationControllerList)) })
|
||||
scheme.AddTypeDefaultingFunc(&ResourceQuota{}, func(obj interface{}) { SetObjectDefaults_ResourceQuota(obj.(*ResourceQuota)) })
|
||||
scheme.AddTypeDefaultingFunc(&ResourceQuotaList{}, func(obj interface{}) { SetObjectDefaults_ResourceQuotaList(obj.(*ResourceQuotaList)) })
|
||||
scheme.AddTypeDefaultingFunc(&Secret{}, func(obj interface{}) { SetObjectDefaults_Secret(obj.(*Secret)) })
|
||||
scheme.AddTypeDefaultingFunc(&SecretList{}, func(obj interface{}) { SetObjectDefaults_SecretList(obj.(*SecretList)) })
|
||||
scheme.AddTypeDefaultingFunc(&Service{}, func(obj interface{}) { SetObjectDefaults_Service(obj.(*Service)) })
|
||||
scheme.AddTypeDefaultingFunc(&ServiceList{}, func(obj interface{}) { SetObjectDefaults_ServiceList(obj.(*ServiceList)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1.ConfigMap{}, func(obj interface{}) { SetObjectDefaults_ConfigMap(obj.(*v1.ConfigMap)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1.ConfigMapList{}, func(obj interface{}) { SetObjectDefaults_ConfigMapList(obj.(*v1.ConfigMapList)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1.Endpoints{}, func(obj interface{}) { SetObjectDefaults_Endpoints(obj.(*v1.Endpoints)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1.EndpointsList{}, func(obj interface{}) { SetObjectDefaults_EndpointsList(obj.(*v1.EndpointsList)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1.LimitRange{}, func(obj interface{}) { SetObjectDefaults_LimitRange(obj.(*v1.LimitRange)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1.LimitRangeList{}, func(obj interface{}) { SetObjectDefaults_LimitRangeList(obj.(*v1.LimitRangeList)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1.Namespace{}, func(obj interface{}) { SetObjectDefaults_Namespace(obj.(*v1.Namespace)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1.NamespaceList{}, func(obj interface{}) { SetObjectDefaults_NamespaceList(obj.(*v1.NamespaceList)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1.Node{}, func(obj interface{}) { SetObjectDefaults_Node(obj.(*v1.Node)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1.NodeList{}, func(obj interface{}) { SetObjectDefaults_NodeList(obj.(*v1.NodeList)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1.PersistentVolume{}, func(obj interface{}) { SetObjectDefaults_PersistentVolume(obj.(*v1.PersistentVolume)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1.PersistentVolumeClaim{}, func(obj interface{}) { SetObjectDefaults_PersistentVolumeClaim(obj.(*v1.PersistentVolumeClaim)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1.PersistentVolumeClaimList{}, func(obj interface{}) { SetObjectDefaults_PersistentVolumeClaimList(obj.(*v1.PersistentVolumeClaimList)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1.PersistentVolumeList{}, func(obj interface{}) { SetObjectDefaults_PersistentVolumeList(obj.(*v1.PersistentVolumeList)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1.Pod{}, func(obj interface{}) { SetObjectDefaults_Pod(obj.(*v1.Pod)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1.PodAttachOptions{}, func(obj interface{}) { SetObjectDefaults_PodAttachOptions(obj.(*v1.PodAttachOptions)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1.PodExecOptions{}, func(obj interface{}) { SetObjectDefaults_PodExecOptions(obj.(*v1.PodExecOptions)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1.PodList{}, func(obj interface{}) { SetObjectDefaults_PodList(obj.(*v1.PodList)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1.PodTemplate{}, func(obj interface{}) { SetObjectDefaults_PodTemplate(obj.(*v1.PodTemplate)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1.PodTemplateList{}, func(obj interface{}) { SetObjectDefaults_PodTemplateList(obj.(*v1.PodTemplateList)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1.ReplicationController{}, func(obj interface{}) { SetObjectDefaults_ReplicationController(obj.(*v1.ReplicationController)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1.ReplicationControllerList{}, func(obj interface{}) { SetObjectDefaults_ReplicationControllerList(obj.(*v1.ReplicationControllerList)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1.ResourceQuota{}, func(obj interface{}) { SetObjectDefaults_ResourceQuota(obj.(*v1.ResourceQuota)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1.ResourceQuotaList{}, func(obj interface{}) { SetObjectDefaults_ResourceQuotaList(obj.(*v1.ResourceQuotaList)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1.Secret{}, func(obj interface{}) { SetObjectDefaults_Secret(obj.(*v1.Secret)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1.SecretList{}, func(obj interface{}) { SetObjectDefaults_SecretList(obj.(*v1.SecretList)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1.Service{}, func(obj interface{}) { SetObjectDefaults_Service(obj.(*v1.Service)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1.ServiceList{}, func(obj interface{}) { SetObjectDefaults_ServiceList(obj.(*v1.ServiceList)) })
|
||||
return nil
|
||||
}
|
||||
|
||||
func SetObjectDefaults_ConfigMap(in *ConfigMap) {
|
||||
func SetObjectDefaults_ConfigMap(in *v1.ConfigMap) {
|
||||
SetDefaults_ConfigMap(in)
|
||||
}
|
||||
|
||||
func SetObjectDefaults_ConfigMapList(in *ConfigMapList) {
|
||||
func SetObjectDefaults_ConfigMapList(in *v1.ConfigMapList) {
|
||||
for i := range in.Items {
|
||||
a := &in.Items[i]
|
||||
SetObjectDefaults_ConfigMap(a)
|
||||
}
|
||||
}
|
||||
|
||||
func SetObjectDefaults_Endpoints(in *Endpoints) {
|
||||
func SetObjectDefaults_Endpoints(in *v1.Endpoints) {
|
||||
SetDefaults_Endpoints(in)
|
||||
}
|
||||
|
||||
func SetObjectDefaults_EndpointsList(in *EndpointsList) {
|
||||
func SetObjectDefaults_EndpointsList(in *v1.EndpointsList) {
|
||||
for i := range in.Items {
|
||||
a := &in.Items[i]
|
||||
SetObjectDefaults_Endpoints(a)
|
||||
}
|
||||
}
|
||||
|
||||
func SetObjectDefaults_LimitRange(in *LimitRange) {
|
||||
func SetObjectDefaults_LimitRange(in *v1.LimitRange) {
|
||||
for i := range in.Spec.Limits {
|
||||
a := &in.Spec.Limits[i]
|
||||
SetDefaults_LimitRangeItem(a)
|
||||
|
@ -93,39 +94,39 @@ func SetObjectDefaults_LimitRange(in *LimitRange) {
|
|||
}
|
||||
}
|
||||
|
||||
func SetObjectDefaults_LimitRangeList(in *LimitRangeList) {
|
||||
func SetObjectDefaults_LimitRangeList(in *v1.LimitRangeList) {
|
||||
for i := range in.Items {
|
||||
a := &in.Items[i]
|
||||
SetObjectDefaults_LimitRange(a)
|
||||
}
|
||||
}
|
||||
|
||||
func SetObjectDefaults_Namespace(in *Namespace) {
|
||||
func SetObjectDefaults_Namespace(in *v1.Namespace) {
|
||||
SetDefaults_NamespaceStatus(&in.Status)
|
||||
}
|
||||
|
||||
func SetObjectDefaults_NamespaceList(in *NamespaceList) {
|
||||
func SetObjectDefaults_NamespaceList(in *v1.NamespaceList) {
|
||||
for i := range in.Items {
|
||||
a := &in.Items[i]
|
||||
SetObjectDefaults_Namespace(a)
|
||||
}
|
||||
}
|
||||
|
||||
func SetObjectDefaults_Node(in *Node) {
|
||||
func SetObjectDefaults_Node(in *v1.Node) {
|
||||
SetDefaults_Node(in)
|
||||
SetDefaults_NodeStatus(&in.Status)
|
||||
SetDefaults_ResourceList(&in.Status.Capacity)
|
||||
SetDefaults_ResourceList(&in.Status.Allocatable)
|
||||
}
|
||||
|
||||
func SetObjectDefaults_NodeList(in *NodeList) {
|
||||
func SetObjectDefaults_NodeList(in *v1.NodeList) {
|
||||
for i := range in.Items {
|
||||
a := &in.Items[i]
|
||||
SetObjectDefaults_Node(a)
|
||||
}
|
||||
}
|
||||
|
||||
func SetObjectDefaults_PersistentVolume(in *PersistentVolume) {
|
||||
func SetObjectDefaults_PersistentVolume(in *v1.PersistentVolume) {
|
||||
SetDefaults_PersistentVolume(in)
|
||||
SetDefaults_ResourceList(&in.Spec.Capacity)
|
||||
if in.Spec.PersistentVolumeSource.RBD != nil {
|
||||
|
@ -142,28 +143,28 @@ func SetObjectDefaults_PersistentVolume(in *PersistentVolume) {
|
|||
}
|
||||
}
|
||||
|
||||
func SetObjectDefaults_PersistentVolumeClaim(in *PersistentVolumeClaim) {
|
||||
func SetObjectDefaults_PersistentVolumeClaim(in *v1.PersistentVolumeClaim) {
|
||||
SetDefaults_PersistentVolumeClaim(in)
|
||||
SetDefaults_ResourceList(&in.Spec.Resources.Limits)
|
||||
SetDefaults_ResourceList(&in.Spec.Resources.Requests)
|
||||
SetDefaults_ResourceList(&in.Status.Capacity)
|
||||
}
|
||||
|
||||
func SetObjectDefaults_PersistentVolumeClaimList(in *PersistentVolumeClaimList) {
|
||||
func SetObjectDefaults_PersistentVolumeClaimList(in *v1.PersistentVolumeClaimList) {
|
||||
for i := range in.Items {
|
||||
a := &in.Items[i]
|
||||
SetObjectDefaults_PersistentVolumeClaim(a)
|
||||
}
|
||||
}
|
||||
|
||||
func SetObjectDefaults_PersistentVolumeList(in *PersistentVolumeList) {
|
||||
func SetObjectDefaults_PersistentVolumeList(in *v1.PersistentVolumeList) {
|
||||
for i := range in.Items {
|
||||
a := &in.Items[i]
|
||||
SetObjectDefaults_PersistentVolume(a)
|
||||
}
|
||||
}
|
||||
|
||||
func SetObjectDefaults_Pod(in *Pod) {
|
||||
func SetObjectDefaults_Pod(in *v1.Pod) {
|
||||
SetDefaults_Pod(in)
|
||||
SetDefaults_PodSpec(&in.Spec)
|
||||
for i := range in.Spec.Volumes {
|
||||
|
@ -297,22 +298,22 @@ func SetObjectDefaults_Pod(in *Pod) {
|
|||
}
|
||||
}
|
||||
|
||||
func SetObjectDefaults_PodAttachOptions(in *PodAttachOptions) {
|
||||
func SetObjectDefaults_PodAttachOptions(in *v1.PodAttachOptions) {
|
||||
SetDefaults_PodAttachOptions(in)
|
||||
}
|
||||
|
||||
func SetObjectDefaults_PodExecOptions(in *PodExecOptions) {
|
||||
func SetObjectDefaults_PodExecOptions(in *v1.PodExecOptions) {
|
||||
SetDefaults_PodExecOptions(in)
|
||||
}
|
||||
|
||||
func SetObjectDefaults_PodList(in *PodList) {
|
||||
func SetObjectDefaults_PodList(in *v1.PodList) {
|
||||
for i := range in.Items {
|
||||
a := &in.Items[i]
|
||||
SetObjectDefaults_Pod(a)
|
||||
}
|
||||
}
|
||||
|
||||
func SetObjectDefaults_PodTemplate(in *PodTemplate) {
|
||||
func SetObjectDefaults_PodTemplate(in *v1.PodTemplate) {
|
||||
SetDefaults_PodSpec(&in.Template.Spec)
|
||||
for i := range in.Template.Spec.Volumes {
|
||||
a := &in.Template.Spec.Volumes[i]
|
||||
|
@ -445,14 +446,14 @@ func SetObjectDefaults_PodTemplate(in *PodTemplate) {
|
|||
}
|
||||
}
|
||||
|
||||
func SetObjectDefaults_PodTemplateList(in *PodTemplateList) {
|
||||
func SetObjectDefaults_PodTemplateList(in *v1.PodTemplateList) {
|
||||
for i := range in.Items {
|
||||
a := &in.Items[i]
|
||||
SetObjectDefaults_PodTemplate(a)
|
||||
}
|
||||
}
|
||||
|
||||
func SetObjectDefaults_ReplicationController(in *ReplicationController) {
|
||||
func SetObjectDefaults_ReplicationController(in *v1.ReplicationController) {
|
||||
SetDefaults_ReplicationController(in)
|
||||
if in.Spec.Template != nil {
|
||||
SetDefaults_PodSpec(&in.Spec.Template.Spec)
|
||||
|
@ -588,42 +589,42 @@ func SetObjectDefaults_ReplicationController(in *ReplicationController) {
|
|||
}
|
||||
}
|
||||
|
||||
func SetObjectDefaults_ReplicationControllerList(in *ReplicationControllerList) {
|
||||
func SetObjectDefaults_ReplicationControllerList(in *v1.ReplicationControllerList) {
|
||||
for i := range in.Items {
|
||||
a := &in.Items[i]
|
||||
SetObjectDefaults_ReplicationController(a)
|
||||
}
|
||||
}
|
||||
|
||||
func SetObjectDefaults_ResourceQuota(in *ResourceQuota) {
|
||||
func SetObjectDefaults_ResourceQuota(in *v1.ResourceQuota) {
|
||||
SetDefaults_ResourceList(&in.Spec.Hard)
|
||||
SetDefaults_ResourceList(&in.Status.Hard)
|
||||
SetDefaults_ResourceList(&in.Status.Used)
|
||||
}
|
||||
|
||||
func SetObjectDefaults_ResourceQuotaList(in *ResourceQuotaList) {
|
||||
func SetObjectDefaults_ResourceQuotaList(in *v1.ResourceQuotaList) {
|
||||
for i := range in.Items {
|
||||
a := &in.Items[i]
|
||||
SetObjectDefaults_ResourceQuota(a)
|
||||
}
|
||||
}
|
||||
|
||||
func SetObjectDefaults_Secret(in *Secret) {
|
||||
func SetObjectDefaults_Secret(in *v1.Secret) {
|
||||
SetDefaults_Secret(in)
|
||||
}
|
||||
|
||||
func SetObjectDefaults_SecretList(in *SecretList) {
|
||||
func SetObjectDefaults_SecretList(in *v1.SecretList) {
|
||||
for i := range in.Items {
|
||||
a := &in.Items[i]
|
||||
SetObjectDefaults_Secret(a)
|
||||
}
|
||||
}
|
||||
|
||||
func SetObjectDefaults_Service(in *Service) {
|
||||
func SetObjectDefaults_Service(in *v1.Service) {
|
||||
SetDefaults_Service(in)
|
||||
}
|
||||
|
||||
func SetObjectDefaults_ServiceList(in *ServiceList) {
|
||||
func SetObjectDefaults_ServiceList(in *v1.ServiceList) {
|
||||
for i := range in.Items {
|
||||
a := &in.Items[i]
|
||||
SetObjectDefaults_Service(a)
|
||||
|
|
Loading…
Reference in New Issue