Example #1
0
func addConversionFuncs(scheme *runtime.Scheme) {
	err := scheme.AddDefaultingFuncs(
		func(obj *RouteSpec) {
			obj.To.Kind = "Service"
		},
		func(obj *TLSConfig) {
			if len(obj.Termination) == 0 && len(obj.DestinationCACertificate) == 0 {
				obj.Termination = TLSTerminationEdge
			}
			switch obj.Termination {
			case TLSTerminationType("Reencrypt"):
				obj.Termination = TLSTerminationReencrypt
			case TLSTerminationType("Edge"):
				obj.Termination = TLSTerminationEdge
			case TLSTerminationType("Passthrough"):
				obj.Termination = TLSTerminationPassthrough
			}
		},
	)
	if err != nil {
		panic(err)
	}

	err = scheme.AddConversionFuncs()
	if err != nil {
		panic(err)
	}

	if err := scheme.AddFieldLabelConversionFunc("v1", "Route",
		oapi.GetFieldLabelConversionFunc(routeapi.RouteToSelectableFields(&routeapi.Route{}), nil),
	); err != nil {
		panic(err)
	}
}
Example #2
0
func addDefaultingFuncs(scheme *runtime.Scheme) error {
	RegisterDefaults(scheme)
	return scheme.AddDefaultingFuncs(
		SetDefaults_MasterConfiguration,
		SetDefaults_NodeConfiguration,
	)
}
Example #3
0
func addDefaultingFuncs(scheme *runtime.Scheme) {
	scheme.AddDefaultingFuncs(
		v1.SetDefaults_Secret,
		v1.SetDefaults_ServiceSpec,
		v1.SetDefaults_NamespaceStatus,
	)
}
Example #4
0
func addDefaultingFuncs(scheme *runtime.Scheme) {
	scheme.AddDefaultingFuncs(
		SetDefaults_KubeProxyConfiguration,
		SetDefaults_KubeSchedulerConfiguration,
		SetDefaults_LeaderElectionConfiguration,
	)
}
Example #5
0
func addDefaultingFuncs(scheme *runtime.Scheme) error {
	return scheme.AddDefaultingFuncs(
		SetDefaults_PodExecOptions,
		SetDefaults_PodAttachOptions,
		SetDefaults_ReplicationController,
		SetDefaults_Volume,
		SetDefaults_ContainerPort,
		SetDefaults_Container,
		SetDefaults_ServiceSpec,
		SetDefaults_Pod,
		SetDefaults_PodSpec,
		SetDefaults_Probe,
		SetDefaults_SecretVolumeSource,
		SetDefaults_ConfigMapVolumeSource,
		SetDefaults_DownwardAPIVolumeSource,
		SetDefaults_DeprecatedDownwardAPIVolumeSource,
		SetDefaults_Secret,
		SetDefaults_PersistentVolume,
		SetDefaults_PersistentVolumeClaim,
		SetDefaults_ISCSIVolumeSource,
		SetDefaults_Endpoints,
		SetDefaults_HTTPGetAction,
		SetDefaults_NamespaceStatus,
		SetDefaults_Node,
		SetDefaults_NodeStatus,
		SetDefaults_ObjectFieldSelector,
		SetDefaults_LimitRangeItem,
		SetDefaults_ConfigMap,
		SetDefaults_RBDVolumeSource,
		SetDefaults_SCC,
	)
}
Example #6
0
func addDefaultingFuncs(scheme *runtime.Scheme) {
	scheme.AddDefaultingFuncs(
		func(obj *Job) {
			labels := obj.Spec.Template.Labels
			// TODO: support templates defined elsewhere when we support them in the API
			if labels != nil {
				if obj.Spec.Selector == nil {
					obj.Spec.Selector = &LabelSelector{
						MatchLabels: labels,
					}
				}
				if len(obj.Labels) == 0 {
					obj.Labels = labels
				}
			}
			// For a non-parallel job, you can leave both `.spec.completions` and
			// `.spec.parallelism` unset.  When both are unset, both are defaulted to 1.
			if obj.Spec.Completions == nil && obj.Spec.Parallelism == nil {
				obj.Spec.Completions = new(int32)
				*obj.Spec.Completions = 1
				obj.Spec.Parallelism = new(int32)
				*obj.Spec.Parallelism = 1
			}
			if obj.Spec.Parallelism == nil {
				obj.Spec.Parallelism = new(int32)
				*obj.Spec.Parallelism = 1
			}
		},
	)
}
Example #7
0
func addDefaultingFuncs(scheme *runtime.Scheme) error {
	RegisterDefaults(scheme)
	return scheme.AddDefaultingFuncs(
		SetDefaults_Job,
		SetDefaults_ScheduledJob,
	)
}
func addDefaultingFuncs(scheme *runtime.Scheme) error {
	RegisterDefaults(scheme)
	return scheme.AddDefaultingFuncs(
		SetDefaults_ClusterRoleBinding,
		SetDefaults_RoleBinding,
	)
}
Example #9
0
func addDefaultingFuncs(scheme *runtime.Scheme) {
	err := scheme.AddDefaultingFuncs(
		SetDefaults_ImageImportSpec,
	)
	if err != nil {
		panic(err)
	}
}
Example #10
0
func addDefaultingFuncs(scheme *runtime.Scheme) error {
	return scheme.AddDefaultingFuncs(
		SetDefaults_RouteSpec,
		SetDefaults_RouteTargetReference,
		SetDefaults_TLSConfig,
		SetDefaults_RouteIngress,
	)
}
Example #11
0
func addDefaultingFuncs(scheme *runtime.Scheme) {
	err := scheme.AddDefaultingFuncs(
		SetDefaults_PolicyRule,
	)
	if err != nil {
		panic(err)
	}
}
Example #12
0
func addDefaultingFuncs(scheme *runtime.Scheme) {
	err := scheme.AddDefaultingFuncs(
		SetDefaults_ImagePolicyConfig,
	)
	if err != nil {
		panic(err)
	}
}
Example #13
0
func addDefaultingFuncs(scheme *kruntime.Scheme) error {
	return scheme.AddDefaultingFuncs(
		SetDefaults_KubeProxyConfiguration,
		SetDefaults_KubeSchedulerConfiguration,
		SetDefaults_LeaderElectionConfiguration,
		SetDefaults_KubeletConfiguration,
	)
}
Example #14
0
func addDefaultingFuncs(scheme *runtime.Scheme) error {
	v1.RegisterDefaults(scheme)
	return scheme.AddDefaultingFuncs(
		v1.SetDefaults_Secret,
		v1.SetDefaults_ServiceSpec,
		v1.SetDefaults_NamespaceStatus,
	)
}
Example #15
0
func addDefaultingFuncs(scheme *runtime.Scheme) {
	err := scheme.AddDefaultingFuncs(
		SetDefaults_PodNodeConstraintsConfig,
	)
	if err != nil {
		panic(err)
	}
}
Example #16
0
func addDefaultingFuncs(scheme *runtime.Scheme) {
	err := scheme.AddDefaultingFuncs(
		SetDefaults_RouteSpec,
		SetDefaults_TLSConfig,
	)
	if err != nil {
		panic(err)
	}
}
Example #17
0
func addDefaultingFuncs(scheme *runtime.Scheme) error {
	return scheme.AddDefaultingFuncs(
		SetDefaults_DeploymentConfigSpec,
		SetDefaults_DeploymentStrategy,
		SetDefaults_RecreateDeploymentStrategyParams,
		SetDefaults_RollingDeploymentStrategyParams,
		SetDefaults_DeploymentConfig,
	)
}
Example #18
0
func addDefaultingFuncs(scheme *runtime.Scheme) {
	scheme.AddDefaultingFuncs(
		SetDefaults_DaemonSet,
		SetDefaults_Deployment,
		SetDefaults_Job,
		SetDefaults_HorizontalPodAutoscaler,
		SetDefaults_ReplicaSet,
	)
}
Example #19
0
func addDefaultingFuncs(scheme *runtime.Scheme) error {
	return scheme.AddDefaultingFuncs(
		SetDefaults_DaemonSet,
		SetDefaults_Deployment,
		SetDefaults_Job,
		SetDefaults_HorizontalPodAutoscaler,
		SetDefaults_ReplicaSet,
		SetDefaults_NetworkPolicy,
	)
}
Example #20
0
func addDefaultingFuncs(scheme *runtime.Scheme) {
	scheme.AddDefaultingFuncs(
		func(obj *HorizontalPodAutoscaler) {
			if obj.Spec.MinReplicas == nil {
				minReplicas := int32(1)
				obj.Spec.MinReplicas = &minReplicas
			}
		},
	)
}
Example #21
0
func addDefaultingFuncs(scheme *runtime.Scheme) {
	scheme.AddDefaultingFuncs(
		func(obj *KubeProxyConfiguration) {
			if obj.BindAddress == "" {
				obj.BindAddress = "0.0.0.0"
			}
			if obj.HealthzPort == 0 {
				obj.HealthzPort = 10249
			}
			if obj.HealthzBindAddress == "" {
				obj.HealthzBindAddress = "127.0.0.1"
			}
			if obj.OOMScoreAdj == nil {
				temp := int32(qos.KubeProxyOOMScoreAdj)
				obj.OOMScoreAdj = &temp
			}
			if obj.IPTablesSyncPeriod.Duration == 0 {
				obj.IPTablesSyncPeriod = unversioned.Duration{5 * time.Second}
			}
		},
		func(obj *KubeSchedulerConfiguration) {
			if obj.Port == 0 {
				obj.Port = ports.SchedulerPort
			}
			if obj.Address == "" {
				obj.Address = "0.0.0.0"
			}
			if obj.AlgorithmProvider == "" {
				obj.AlgorithmProvider = "DefaultProvider"
			}
			if obj.KubeAPIQPS == 0 {
				obj.KubeAPIQPS = 50.0
			}
			if obj.KubeAPIBurst == 0 {
				obj.KubeAPIBurst = 100
			}
			if obj.SchedulerName == "" {
				obj.SchedulerName = api.DefaultSchedulerName
			}
		},
		func(obj *LeaderElectionConfiguration) {
			zero := unversioned.Duration{}
			if obj.LeaseDuration == zero {
				obj.LeaseDuration = unversioned.Duration{15 * time.Second}
			}
			if obj.RenewDeadline == zero {
				obj.RenewDeadline = unversioned.Duration{10 * time.Second}
			}
			if obj.RetryPeriod == zero {
				obj.RetryPeriod = unversioned.Duration{2 * time.Second}
			}
		},
	)
}
Example #22
0
func addDefaultingFuncs(scheme *runtime.Scheme) error {
	return scheme.AddDefaultingFuncs(
		SetDefaults_BuildConfigSpec,
		SetDefaults_BuildSource,
		SetDefaults_BuildStrategy,
		SetDefaults_SourceBuildStrategy,
		SetDefaults_DockerBuildStrategy,
		SetDefaults_CustomBuildStrategy,
		SetDefaults_BuildTriggerPolicy,
	)
}
Example #23
0
func addConversionFuncs(scheme *runtime.Scheme) {
	err := scheme.AddDefaultingFuncs(
		func(obj *RouteTargetReference) {
			if len(obj.Kind) == 0 {
				obj.Kind = "Service"
			}
			if obj.Weight == nil {
				obj.Weight = new(int32)
				*obj.Weight = 100
			}
		},
		func(obj *TLSConfig) {
			if len(obj.Termination) == 0 && len(obj.DestinationCACertificate) == 0 {
				obj.Termination = TLSTerminationEdge
			}
			switch obj.Termination {
			case TLSTerminationType("Reencrypt"):
				obj.Termination = TLSTerminationReencrypt
			case TLSTerminationType("Edge"):
				obj.Termination = TLSTerminationEdge
			case TLSTerminationType("Passthrough"):
				obj.Termination = TLSTerminationPassthrough
			}
		},
	)
	if err != nil {
		panic(err)
	}

	err = scheme.AddConversionFuncs()
	if err != nil {
		panic(err)
	}

	// Add field conversion funcs.
	err = scheme.AddFieldLabelConversionFunc("v1beta3", "Route",
		func(label, value string) (string, string, error) {
			switch label {
			case "metadata.name",
				"spec.host",
				"spec.path",
				"spec.to.name":
				return label, value, nil
				// This is for backwards compatibility with old v1 clients which send spec.host
			default:
				return "", "", fmt.Errorf("field label not supported: %s", label)
			}
		})
	if err != nil {
		// If one of the conversion functions is malformed, detect it immediately.
		panic(err)
	}

}
Example #24
0
func addDefaultingFuncs(scheme *runtime.Scheme) {
	err := scheme.AddDefaultingFuncs(
		SetDefaults_DeploymentConfigSpec,
		SetDefaults_DeploymentStrategy,
		SetDefaults_RecreateDeploymentStrategyParams,
		SetDefaults_RollingDeploymentStrategyParams,
		SetDefaults_DeploymentConfig,
	)
	if err != nil {
		panic(err)
	}
}
Example #25
0
func addDefaultingFuncs(scheme *runtime.Scheme) {
	scheme.AddDefaultingFuncs(
		func(obj *api.ListOptions) {
			if obj.LabelSelector == nil {
				obj.LabelSelector = labels.Everything()
			}
			if obj.FieldSelector == nil {
				obj.FieldSelector = fields.Everything()
			}
		},
	)
}
Example #26
0
func addDefaultingFuncs(scheme *runtime.Scheme) error {
	return scheme.AddDefaultingFuncs(
		func(obj *ClusterRoleBinding) {
			if len(obj.RoleRef.APIGroup) == 0 {
				obj.RoleRef.APIGroup = GroupName
			}
		},
		func(obj *RoleBinding) {
			if len(obj.RoleRef.APIGroup) == 0 {
				obj.RoleRef.APIGroup = GroupName
			}
		},
	)
}
Example #27
0
func addDefaultingFuncs(scheme *runtime.Scheme) {
	err := scheme.AddDefaultingFuncs(
		func(obj *PodNodeConstraintsConfig) {
			if obj.NodeSelectorLabelBlacklist == nil {
				obj.NodeSelectorLabelBlacklist = []string{
					"kubernetes.io/hostname",
				}
			}
		},
	)
	if err != nil {
		panic(err)
	}
}
Example #28
0
func addDefaultingFuncs(scheme *runtime.Scheme) {
	err := scheme.AddDefaultingFuncs(
		SetDefaults_BuildConfigSpec,
		SetDefaults_BuildSource,
		SetDefaults_BuildStrategy,
		SetDefaults_SourceBuildStrategy,
		SetDefaults_DockerBuildStrategy,
		SetDefaults_CustomBuildStrategy,
		SetDefaults_BuildTriggerPolicy,
	)
	if err != nil {
		panic(err)
	}
}
Example #29
0
func addConversionFuncs(scheme *runtime.Scheme) {
	err := scheme.AddDefaultingFuncs(
		func(obj *ImageImportSpec) {
			if obj.To == nil {
				if ref, err := newer.ParseDockerImageReference(obj.From.Name); err == nil {
					if len(ref.Tag) > 0 {
						obj.To = &v1.LocalObjectReference{Name: ref.Tag}
					}
				}
			}
		})
	if err != nil {
		// If one of the default functions is malformed, detect it immediately.
		panic(err)
	}
	err = scheme.AddConversionFuncs(
		Convert_v1_NamedTagEventListArray_to_api_TagEventListArray,
		Convert_api_TagEventListArray_to_v1_NamedTagEventListArray,
		Convert_v1_TagReferenceArray_to_api_TagReferenceMap,
		Convert_api_TagReferenceMap_to_v1_TagReferenceArray,

		Convert_api_Image_To_v1_Image,
		Convert_v1_Image_To_api_Image,
		Convert_v1_ImageStreamSpec_To_api_ImageStreamSpec,
		Convert_api_ImageStreamSpec_To_v1_ImageStreamSpec,
		Convert_v1_ImageStreamStatus_To_api_ImageStreamStatus,
		Convert_api_ImageStreamStatus_To_v1_ImageStreamStatus,
		Convert_api_ImageStreamMapping_To_v1_ImageStreamMapping,
		Convert_v1_ImageStreamMapping_To_api_ImageStreamMapping,
	)
	if err != nil {
		// If one of the conversion functions is malformed, detect it immediately.
		panic(err)
	}

	if err := scheme.AddFieldLabelConversionFunc("v1", "Image",
		oapi.GetFieldLabelConversionFunc(newer.ImageToSelectableFields(&newer.Image{}), nil),
	); err != nil {
		panic(err)
	}

	if err := scheme.AddFieldLabelConversionFunc("v1", "ImageStream",
		oapi.GetFieldLabelConversionFunc(newer.ImageStreamToSelectableFields(&newer.ImageStream{}), map[string]string{"name": "metadata.name"}),
	); err != nil {
		panic(err)
	}
}
Example #30
0
func addDefaultingFuncs(scheme *runtime.Scheme) {
	scheme.AddDefaultingFuncs(
		func(obj *Job) {
			// For a non-parallel job, you can leave both `.spec.completions` and
			// `.spec.parallelism` unset.  When both are unset, both are defaulted to 1.
			if obj.Spec.Completions == nil && obj.Spec.Parallelism == nil {
				obj.Spec.Completions = new(int32)
				*obj.Spec.Completions = 1
				obj.Spec.Parallelism = new(int32)
				*obj.Spec.Parallelism = 1
			}
			if obj.Spec.Parallelism == nil {
				obj.Spec.Parallelism = new(int32)
				*obj.Spec.Parallelism = 1
			}
		},
	)
}