| ... | ... |
@@ -9,24 +9,26 @@ import ( |
| 9 | 9 |
|
| 10 | 10 |
var oldAllowAllPolicyRule = PolicyRule{APIGroups: nil, Verbs: []string{internal.VerbAll}, Resources: []string{internal.ResourceAll}}
|
| 11 | 11 |
|
| 12 |
-func addDefaultingFuncs(scheme *runtime.Scheme) {
|
|
| 13 |
- err := scheme.AddDefaultingFuncs( |
|
| 14 |
- func(obj *PolicyRule) {
|
|
| 15 |
- if obj == nil {
|
|
| 16 |
- return |
|
| 17 |
- } |
|
| 12 |
+func SetDefaults_PolicyRule(obj *PolicyRule) {
|
|
| 13 |
+ if obj == nil {
|
|
| 14 |
+ return |
|
| 15 |
+ } |
|
| 18 | 16 |
|
| 19 |
- // this seems really strange, but semantic equality checks most of what we want, but nil == {}
|
|
| 20 |
- // this is ok for the restof the fields, but not APIGroups |
|
| 21 |
- if kapi.Semantic.Equalities.DeepEqual(oldAllowAllPolicyRule, *obj) && obj.APIGroups == nil {
|
|
| 22 |
- obj.APIGroups = []string{internal.APIGroupAll}
|
|
| 23 |
- } |
|
| 17 |
+ // this seems really strange, but semantic equality checks most of what we want, but nil == {}
|
|
| 18 |
+ // this is ok for the restof the fields, but not APIGroups |
|
| 19 |
+ if kapi.Semantic.Equalities.DeepEqual(oldAllowAllPolicyRule, *obj) && obj.APIGroups == nil {
|
|
| 20 |
+ obj.APIGroups = []string{internal.APIGroupAll}
|
|
| 21 |
+ } |
|
| 24 | 22 |
|
| 25 |
- // if no groups are found, then we assume "" |
|
| 26 |
- if len(obj.Resources) > 0 && len(obj.APIGroups) == 0 {
|
|
| 27 |
- obj.APIGroups = []string{""}
|
|
| 28 |
- } |
|
| 29 |
- }, |
|
| 23 |
+ // if no groups are found, then we assume "" |
|
| 24 |
+ if len(obj.Resources) > 0 && len(obj.APIGroups) == 0 {
|
|
| 25 |
+ obj.APIGroups = []string{""}
|
|
| 26 |
+ } |
|
| 27 |
+} |
|
| 28 |
+ |
|
| 29 |
+func addDefaultingFuncs(scheme *runtime.Scheme) {
|
|
| 30 |
+ err := scheme.AddDefaultingFuncs( |
|
| 31 |
+ SetDefaults_PolicyRule, |
|
| 30 | 32 |
) |
| 31 | 33 |
if err != nil {
|
| 32 | 34 |
panic(err) |
| ... | ... |
@@ -151,47 +151,6 @@ func Convert_api_BuildStrategy_To_v1_BuildStrategy(in *newer.BuildStrategy, out |
| 151 | 151 |
} |
| 152 | 152 |
|
| 153 | 153 |
func addConversionFuncs(scheme *runtime.Scheme) {
|
| 154 |
- err := scheme.AddDefaultingFuncs( |
|
| 155 |
- func(config *BuildConfigSpec) {
|
|
| 156 |
- if len(config.RunPolicy) == 0 {
|
|
| 157 |
- config.RunPolicy = BuildRunPolicySerial |
|
| 158 |
- } |
|
| 159 |
- }, |
|
| 160 |
- func(source *BuildSource) {
|
|
| 161 |
- if (source != nil) && (source.Type == BuildSourceBinary) && (source.Binary == nil) {
|
|
| 162 |
- source.Binary = &BinaryBuildSource{}
|
|
| 163 |
- } |
|
| 164 |
- }, |
|
| 165 |
- func(strategy *BuildStrategy) {
|
|
| 166 |
- if (strategy != nil) && (strategy.Type == DockerBuildStrategyType) && (strategy.DockerStrategy == nil) {
|
|
| 167 |
- strategy.DockerStrategy = &DockerBuildStrategy{}
|
|
| 168 |
- } |
|
| 169 |
- }, |
|
| 170 |
- func(obj *SourceBuildStrategy) {
|
|
| 171 |
- if len(obj.From.Kind) == 0 {
|
|
| 172 |
- obj.From.Kind = "ImageStreamTag" |
|
| 173 |
- } |
|
| 174 |
- }, |
|
| 175 |
- func(obj *DockerBuildStrategy) {
|
|
| 176 |
- if obj.From != nil && len(obj.From.Kind) == 0 {
|
|
| 177 |
- obj.From.Kind = "ImageStreamTag" |
|
| 178 |
- } |
|
| 179 |
- }, |
|
| 180 |
- func(obj *CustomBuildStrategy) {
|
|
| 181 |
- if len(obj.From.Kind) == 0 {
|
|
| 182 |
- obj.From.Kind = "ImageStreamTag" |
|
| 183 |
- } |
|
| 184 |
- }, |
|
| 185 |
- func(obj *BuildTriggerPolicy) {
|
|
| 186 |
- if obj.Type == ImageChangeBuildTriggerType && obj.ImageChange == nil {
|
|
| 187 |
- obj.ImageChange = &ImageChangeTrigger{}
|
|
| 188 |
- } |
|
| 189 |
- }, |
|
| 190 |
- ) |
|
| 191 |
- if err != nil {
|
|
| 192 |
- panic(err) |
|
| 193 |
- } |
|
| 194 |
- |
|
| 195 | 154 |
scheme.AddConversionFuncs( |
| 196 | 155 |
Convert_v1_BuildConfig_To_api_BuildConfig, |
| 197 | 156 |
Convert_api_BuildConfig_To_v1_BuildConfig, |
| 198 | 157 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,60 @@ |
| 0 |
+package v1 |
|
| 1 |
+ |
|
| 2 |
+import "k8s.io/kubernetes/pkg/runtime" |
|
| 3 |
+ |
|
| 4 |
+func SetDefaults_BuildConfigSpec(config *BuildConfigSpec) {
|
|
| 5 |
+ if len(config.RunPolicy) == 0 {
|
|
| 6 |
+ config.RunPolicy = BuildRunPolicySerial |
|
| 7 |
+ } |
|
| 8 |
+} |
|
| 9 |
+ |
|
| 10 |
+func SetDefaults_BuildSource(source *BuildSource) {
|
|
| 11 |
+ if (source != nil) && (source.Type == BuildSourceBinary) && (source.Binary == nil) {
|
|
| 12 |
+ source.Binary = &BinaryBuildSource{}
|
|
| 13 |
+ } |
|
| 14 |
+} |
|
| 15 |
+ |
|
| 16 |
+func SetDefaults_BuildStrategy(strategy *BuildStrategy) {
|
|
| 17 |
+ if (strategy != nil) && (strategy.Type == DockerBuildStrategyType) && (strategy.DockerStrategy == nil) {
|
|
| 18 |
+ strategy.DockerStrategy = &DockerBuildStrategy{}
|
|
| 19 |
+ } |
|
| 20 |
+} |
|
| 21 |
+ |
|
| 22 |
+func SetDefaults_SourceBuildStrategy(obj *SourceBuildStrategy) {
|
|
| 23 |
+ if len(obj.From.Kind) == 0 {
|
|
| 24 |
+ obj.From.Kind = "ImageStreamTag" |
|
| 25 |
+ } |
|
| 26 |
+} |
|
| 27 |
+ |
|
| 28 |
+func SetDefaults_DockerBuildStrategy(obj *DockerBuildStrategy) {
|
|
| 29 |
+ if obj.From != nil && len(obj.From.Kind) == 0 {
|
|
| 30 |
+ obj.From.Kind = "ImageStreamTag" |
|
| 31 |
+ } |
|
| 32 |
+} |
|
| 33 |
+ |
|
| 34 |
+func SetDefaults_CustomBuildStrategy(obj *CustomBuildStrategy) {
|
|
| 35 |
+ if len(obj.From.Kind) == 0 {
|
|
| 36 |
+ obj.From.Kind = "ImageStreamTag" |
|
| 37 |
+ } |
|
| 38 |
+} |
|
| 39 |
+ |
|
| 40 |
+func SetDefaults_BuildTriggerPolicy(obj *BuildTriggerPolicy) {
|
|
| 41 |
+ if obj.Type == ImageChangeBuildTriggerType && obj.ImageChange == nil {
|
|
| 42 |
+ obj.ImageChange = &ImageChangeTrigger{}
|
|
| 43 |
+ } |
|
| 44 |
+} |
|
| 45 |
+ |
|
| 46 |
+func addDefaultingFuncs(scheme *runtime.Scheme) {
|
|
| 47 |
+ err := scheme.AddDefaultingFuncs( |
|
| 48 |
+ SetDefaults_BuildConfigSpec, |
|
| 49 |
+ SetDefaults_BuildSource, |
|
| 50 |
+ SetDefaults_BuildStrategy, |
|
| 51 |
+ SetDefaults_SourceBuildStrategy, |
|
| 52 |
+ SetDefaults_DockerBuildStrategy, |
|
| 53 |
+ SetDefaults_CustomBuildStrategy, |
|
| 54 |
+ SetDefaults_BuildTriggerPolicy, |
|
| 55 |
+ ) |
|
| 56 |
+ if err != nil {
|
|
| 57 |
+ panic(err) |
|
| 58 |
+ } |
|
| 59 |
+} |
| ... | ... |
@@ -24,92 +24,101 @@ func defaultHookContainerName(hook *LifecycleHook, containerName string) {
|
| 24 | 24 |
} |
| 25 | 25 |
} |
| 26 | 26 |
|
| 27 |
-func addDefaultingFuncs(scheme *runtime.Scheme) {
|
|
| 28 |
- mkintp := func(i int64) *int64 {
|
|
| 29 |
- return &i |
|
| 27 |
+func SetDefaults_DeploymentConfigSpec(obj *DeploymentConfigSpec) {
|
|
| 28 |
+ if obj.Triggers == nil {
|
|
| 29 |
+ obj.Triggers = []DeploymentTriggerPolicy{
|
|
| 30 |
+ {Type: DeploymentTriggerOnConfigChange},
|
|
| 31 |
+ } |
|
| 32 |
+ } |
|
| 33 |
+ if len(obj.Selector) == 0 && obj.Template != nil {
|
|
| 34 |
+ obj.Selector = obj.Template.Labels |
|
| 30 | 35 |
} |
| 31 | 36 |
|
| 32 |
- err := scheme.AddDefaultingFuncs( |
|
| 33 |
- func(obj *DeploymentConfigSpec) {
|
|
| 34 |
- if obj.Triggers == nil {
|
|
| 35 |
- obj.Triggers = []DeploymentTriggerPolicy{
|
|
| 36 |
- {Type: DeploymentTriggerOnConfigChange},
|
|
| 37 |
- } |
|
| 38 |
- } |
|
| 39 |
- if len(obj.Selector) == 0 && obj.Template != nil {
|
|
| 40 |
- obj.Selector = obj.Template.Labels |
|
| 41 |
- } |
|
| 37 |
+ // if you only specify a single container, default the TagImages hook to the container name |
|
| 38 |
+ if obj.Template != nil && len(obj.Template.Spec.Containers) == 1 {
|
|
| 39 |
+ containerName := obj.Template.Spec.Containers[0].Name |
|
| 40 |
+ if p := obj.Strategy.RecreateParams; p != nil {
|
|
| 41 |
+ defaultHookContainerName(p.Pre, containerName) |
|
| 42 |
+ defaultHookContainerName(p.Mid, containerName) |
|
| 43 |
+ defaultHookContainerName(p.Post, containerName) |
|
| 44 |
+ } |
|
| 45 |
+ if p := obj.Strategy.RollingParams; p != nil {
|
|
| 46 |
+ defaultHookContainerName(p.Pre, containerName) |
|
| 47 |
+ defaultHookContainerName(p.Post, containerName) |
|
| 48 |
+ } |
|
| 49 |
+ } |
|
| 50 |
+} |
|
| 42 | 51 |
|
| 43 |
- // if you only specify a single container, default the TagImages hook to the container name |
|
| 44 |
- if obj.Template != nil && len(obj.Template.Spec.Containers) == 1 {
|
|
| 45 |
- containerName := obj.Template.Spec.Containers[0].Name |
|
| 46 |
- if p := obj.Strategy.RecreateParams; p != nil {
|
|
| 47 |
- defaultHookContainerName(p.Pre, containerName) |
|
| 48 |
- defaultHookContainerName(p.Mid, containerName) |
|
| 49 |
- defaultHookContainerName(p.Post, containerName) |
|
| 50 |
- } |
|
| 51 |
- if p := obj.Strategy.RollingParams; p != nil {
|
|
| 52 |
- defaultHookContainerName(p.Pre, containerName) |
|
| 53 |
- defaultHookContainerName(p.Post, containerName) |
|
| 54 |
- } |
|
| 55 |
- } |
|
| 56 |
- }, |
|
| 57 |
- func(obj *DeploymentStrategy) {
|
|
| 58 |
- if len(obj.Type) == 0 {
|
|
| 59 |
- obj.Type = DeploymentStrategyTypeRolling |
|
| 60 |
- } |
|
| 52 |
+func SetDefaults_DeploymentStrategy(obj *DeploymentStrategy) {
|
|
| 53 |
+ if len(obj.Type) == 0 {
|
|
| 54 |
+ obj.Type = DeploymentStrategyTypeRolling |
|
| 55 |
+ } |
|
| 61 | 56 |
|
| 62 |
- if obj.Type == DeploymentStrategyTypeRolling && obj.RollingParams == nil {
|
|
| 63 |
- obj.RollingParams = &RollingDeploymentStrategyParams{
|
|
| 64 |
- IntervalSeconds: mkintp(deployapi.DefaultRollingIntervalSeconds), |
|
| 65 |
- UpdatePeriodSeconds: mkintp(deployapi.DefaultRollingUpdatePeriodSeconds), |
|
| 66 |
- TimeoutSeconds: mkintp(deployapi.DefaultRollingTimeoutSeconds), |
|
| 67 |
- } |
|
| 68 |
- } |
|
| 69 |
- if obj.Type == DeploymentStrategyTypeRecreate && obj.RecreateParams == nil {
|
|
| 70 |
- obj.RecreateParams = &RecreateDeploymentStrategyParams{}
|
|
| 71 |
- } |
|
| 72 |
- }, |
|
| 73 |
- func(obj *RecreateDeploymentStrategyParams) {
|
|
| 74 |
- if obj.TimeoutSeconds == nil {
|
|
| 75 |
- obj.TimeoutSeconds = mkintp(deployapi.DefaultRollingTimeoutSeconds) |
|
| 76 |
- } |
|
| 77 |
- }, |
|
| 78 |
- func(obj *RollingDeploymentStrategyParams) {
|
|
| 79 |
- if obj.IntervalSeconds == nil {
|
|
| 80 |
- obj.IntervalSeconds = mkintp(deployapi.DefaultRollingIntervalSeconds) |
|
| 81 |
- } |
|
| 57 |
+ if obj.Type == DeploymentStrategyTypeRolling && obj.RollingParams == nil {
|
|
| 58 |
+ obj.RollingParams = &RollingDeploymentStrategyParams{
|
|
| 59 |
+ IntervalSeconds: mkintp(deployapi.DefaultRollingIntervalSeconds), |
|
| 60 |
+ UpdatePeriodSeconds: mkintp(deployapi.DefaultRollingUpdatePeriodSeconds), |
|
| 61 |
+ TimeoutSeconds: mkintp(deployapi.DefaultRollingTimeoutSeconds), |
|
| 62 |
+ } |
|
| 63 |
+ } |
|
| 64 |
+ if obj.Type == DeploymentStrategyTypeRecreate && obj.RecreateParams == nil {
|
|
| 65 |
+ obj.RecreateParams = &RecreateDeploymentStrategyParams{}
|
|
| 66 |
+ } |
|
| 67 |
+} |
|
| 82 | 68 |
|
| 83 |
- if obj.UpdatePeriodSeconds == nil {
|
|
| 84 |
- obj.UpdatePeriodSeconds = mkintp(deployapi.DefaultRollingUpdatePeriodSeconds) |
|
| 85 |
- } |
|
| 69 |
+func SetDefaults_RecreateDeploymentStrategyParams(obj *RecreateDeploymentStrategyParams) {
|
|
| 70 |
+ if obj.TimeoutSeconds == nil {
|
|
| 71 |
+ obj.TimeoutSeconds = mkintp(deployapi.DefaultRollingTimeoutSeconds) |
|
| 72 |
+ } |
|
| 73 |
+} |
|
| 74 |
+func SetDefaults_RollingDeploymentStrategyParams(obj *RollingDeploymentStrategyParams) {
|
|
| 75 |
+ if obj.IntervalSeconds == nil {
|
|
| 76 |
+ obj.IntervalSeconds = mkintp(deployapi.DefaultRollingIntervalSeconds) |
|
| 77 |
+ } |
|
| 86 | 78 |
|
| 87 |
- if obj.TimeoutSeconds == nil {
|
|
| 88 |
- obj.TimeoutSeconds = mkintp(deployapi.DefaultRollingTimeoutSeconds) |
|
| 89 |
- } |
|
| 79 |
+ if obj.UpdatePeriodSeconds == nil {
|
|
| 80 |
+ obj.UpdatePeriodSeconds = mkintp(deployapi.DefaultRollingUpdatePeriodSeconds) |
|
| 81 |
+ } |
|
| 90 | 82 |
|
| 91 |
- if obj.UpdatePercent == nil {
|
|
| 92 |
- // Apply defaults. |
|
| 93 |
- if obj.MaxUnavailable == nil {
|
|
| 94 |
- maxUnavailable := intstr.FromString("25%")
|
|
| 95 |
- obj.MaxUnavailable = &maxUnavailable |
|
| 96 |
- } |
|
| 97 |
- if obj.MaxSurge == nil {
|
|
| 98 |
- maxSurge := intstr.FromString("25%")
|
|
| 99 |
- obj.MaxSurge = &maxSurge |
|
| 100 |
- } |
|
| 101 |
- } |
|
| 102 |
- }, |
|
| 103 |
- func(obj *DeploymentConfig) {
|
|
| 104 |
- for _, t := range obj.Spec.Triggers {
|
|
| 105 |
- if t.ImageChangeParams != nil {
|
|
| 106 |
- t.ImageChangeParams.From.Kind = "ImageStreamTag" |
|
| 107 |
- if len(t.ImageChangeParams.From.Name) > 0 && len(t.ImageChangeParams.From.Namespace) == 0 {
|
|
| 108 |
- t.ImageChangeParams.From.Namespace = obj.Namespace |
|
| 109 |
- } |
|
| 110 |
- } |
|
| 83 |
+ if obj.TimeoutSeconds == nil {
|
|
| 84 |
+ obj.TimeoutSeconds = mkintp(deployapi.DefaultRollingTimeoutSeconds) |
|
| 85 |
+ } |
|
| 86 |
+ |
|
| 87 |
+ if obj.UpdatePercent == nil {
|
|
| 88 |
+ // Apply defaults. |
|
| 89 |
+ if obj.MaxUnavailable == nil {
|
|
| 90 |
+ maxUnavailable := intstr.FromString("25%")
|
|
| 91 |
+ obj.MaxUnavailable = &maxUnavailable |
|
| 92 |
+ } |
|
| 93 |
+ if obj.MaxSurge == nil {
|
|
| 94 |
+ maxSurge := intstr.FromString("25%")
|
|
| 95 |
+ obj.MaxSurge = &maxSurge |
|
| 96 |
+ } |
|
| 97 |
+ } |
|
| 98 |
+} |
|
| 99 |
+ |
|
| 100 |
+func SetDefaults_DeploymentConfig(obj *DeploymentConfig) {
|
|
| 101 |
+ for _, t := range obj.Spec.Triggers {
|
|
| 102 |
+ if t.ImageChangeParams != nil {
|
|
| 103 |
+ t.ImageChangeParams.From.Kind = "ImageStreamTag" |
|
| 104 |
+ if len(t.ImageChangeParams.From.Name) > 0 && len(t.ImageChangeParams.From.Namespace) == 0 {
|
|
| 105 |
+ t.ImageChangeParams.From.Namespace = obj.Namespace |
|
| 111 | 106 |
} |
| 112 |
- }, |
|
| 107 |
+ } |
|
| 108 |
+ } |
|
| 109 |
+} |
|
| 110 |
+ |
|
| 111 |
+func mkintp(i int64) *int64 {
|
|
| 112 |
+ return &i |
|
| 113 |
+} |
|
| 114 |
+ |
|
| 115 |
+func addDefaultingFuncs(scheme *runtime.Scheme) {
|
|
| 116 |
+ err := scheme.AddDefaultingFuncs( |
|
| 117 |
+ SetDefaults_DeploymentConfigSpec, |
|
| 118 |
+ SetDefaults_DeploymentStrategy, |
|
| 119 |
+ SetDefaults_RecreateDeploymentStrategyParams, |
|
| 120 |
+ SetDefaults_RollingDeploymentStrategyParams, |
|
| 121 |
+ SetDefaults_DeploymentConfig, |
|
| 113 | 122 |
) |
| 114 | 123 |
if err != nil {
|
| 115 | 124 |
panic(err) |
| ... | ... |
@@ -6,7 +6,6 @@ import ( |
| 6 | 6 |
|
| 7 | 7 |
"k8s.io/kubernetes/pkg/api" |
| 8 | 8 |
"k8s.io/kubernetes/pkg/api/unversioned" |
| 9 |
- v1 "k8s.io/kubernetes/pkg/api/v1" |
|
| 10 | 9 |
"k8s.io/kubernetes/pkg/conversion" |
| 11 | 10 |
"k8s.io/kubernetes/pkg/runtime" |
| 12 | 11 |
|
| ... | ... |
@@ -233,21 +232,7 @@ func Convert_api_TagReferenceMap_to_v1_TagReferenceArray(in *map[string]newer.Ta |
| 233 | 233 |
} |
| 234 | 234 |
|
| 235 | 235 |
func addConversionFuncs(scheme *runtime.Scheme) {
|
| 236 |
- err := scheme.AddDefaultingFuncs( |
|
| 237 |
- func(obj *ImageImportSpec) {
|
|
| 238 |
- if obj.To == nil {
|
|
| 239 |
- if ref, err := newer.ParseDockerImageReference(obj.From.Name); err == nil {
|
|
| 240 |
- if len(ref.Tag) > 0 {
|
|
| 241 |
- obj.To = &v1.LocalObjectReference{Name: ref.Tag}
|
|
| 242 |
- } |
|
| 243 |
- } |
|
| 244 |
- } |
|
| 245 |
- }) |
|
| 246 |
- if err != nil {
|
|
| 247 |
- // If one of the default functions is malformed, detect it immediately. |
|
| 248 |
- panic(err) |
|
| 249 |
- } |
|
| 250 |
- err = scheme.AddConversionFuncs( |
|
| 236 |
+ err := scheme.AddConversionFuncs( |
|
| 251 | 237 |
Convert_v1_NamedTagEventListArray_to_api_TagEventListArray, |
| 252 | 238 |
Convert_api_TagEventListArray_to_v1_NamedTagEventListArray, |
| 253 | 239 |
Convert_v1_TagReferenceArray_to_api_TagReferenceMap, |
| 254 | 240 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,26 @@ |
| 0 |
+package v1 |
|
| 1 |
+ |
|
| 2 |
+import ( |
|
| 3 |
+ newer "github.com/openshift/origin/pkg/image/api" |
|
| 4 |
+ "k8s.io/kubernetes/pkg/api/v1" |
|
| 5 |
+ "k8s.io/kubernetes/pkg/runtime" |
|
| 6 |
+) |
|
| 7 |
+ |
|
| 8 |
+func SetDefaults_ImageImportSpec(obj *ImageImportSpec) {
|
|
| 9 |
+ if obj.To == nil {
|
|
| 10 |
+ if ref, err := newer.ParseDockerImageReference(obj.From.Name); err == nil {
|
|
| 11 |
+ if len(ref.Tag) > 0 {
|
|
| 12 |
+ obj.To = &v1.LocalObjectReference{Name: ref.Tag}
|
|
| 13 |
+ } |
|
| 14 |
+ } |
|
| 15 |
+ } |
|
| 16 |
+} |
|
| 17 |
+ |
|
| 18 |
+func addDefaultingFuncs(scheme *runtime.Scheme) {
|
|
| 19 |
+ err := scheme.AddDefaultingFuncs( |
|
| 20 |
+ SetDefaults_ImageImportSpec, |
|
| 21 |
+ ) |
|
| 22 |
+ if err != nil {
|
|
| 23 |
+ panic(err) |
|
| 24 |
+ } |
|
| 25 |
+} |
| ... | ... |
@@ -8,32 +8,7 @@ import ( |
| 8 | 8 |
) |
| 9 | 9 |
|
| 10 | 10 |
func addConversionFuncs(scheme *runtime.Scheme) {
|
| 11 |
- err := scheme.AddDefaultingFuncs( |
|
| 12 |
- func(obj *RouteSpec) {
|
|
| 13 |
- if len(obj.To.Kind) == 0 {
|
|
| 14 |
- obj.To.Kind = "Service" |
|
| 15 |
- } |
|
| 16 |
- }, |
|
| 17 |
- func(obj *TLSConfig) {
|
|
| 18 |
- if len(obj.Termination) == 0 && len(obj.DestinationCACertificate) == 0 {
|
|
| 19 |
- obj.Termination = TLSTerminationEdge |
|
| 20 |
- } |
|
| 21 |
- switch obj.Termination {
|
|
| 22 |
- case TLSTerminationType("Reencrypt"):
|
|
| 23 |
- obj.Termination = TLSTerminationReencrypt |
|
| 24 |
- case TLSTerminationType("Edge"):
|
|
| 25 |
- obj.Termination = TLSTerminationEdge |
|
| 26 |
- case TLSTerminationType("Passthrough"):
|
|
| 27 |
- obj.Termination = TLSTerminationPassthrough |
|
| 28 |
- } |
|
| 29 |
- }, |
|
| 30 |
- ) |
|
| 31 |
- if err != nil {
|
|
| 32 |
- panic(err) |
|
| 33 |
- } |
|
| 34 |
- |
|
| 35 |
- err = scheme.AddConversionFuncs() |
|
| 36 |
- if err != nil {
|
|
| 11 |
+ if err := scheme.AddConversionFuncs(); err != nil {
|
|
| 37 | 12 |
panic(err) |
| 38 | 13 |
} |
| 39 | 14 |
|
| 40 | 15 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,33 @@ |
| 0 |
+package v1 |
|
| 1 |
+ |
|
| 2 |
+import "k8s.io/kubernetes/pkg/runtime" |
|
| 3 |
+ |
|
| 4 |
+func SetDefaults_RouteSpec(obj *RouteSpec) {
|
|
| 5 |
+ if len(obj.To.Kind) == 0 {
|
|
| 6 |
+ obj.To.Kind = "Service" |
|
| 7 |
+ } |
|
| 8 |
+} |
|
| 9 |
+ |
|
| 10 |
+func SetDefaults_TLSConfig(obj *TLSConfig) {
|
|
| 11 |
+ if len(obj.Termination) == 0 && len(obj.DestinationCACertificate) == 0 {
|
|
| 12 |
+ obj.Termination = TLSTerminationEdge |
|
| 13 |
+ } |
|
| 14 |
+ switch obj.Termination {
|
|
| 15 |
+ case TLSTerminationType("Reencrypt"):
|
|
| 16 |
+ obj.Termination = TLSTerminationReencrypt |
|
| 17 |
+ case TLSTerminationType("Edge"):
|
|
| 18 |
+ obj.Termination = TLSTerminationEdge |
|
| 19 |
+ case TLSTerminationType("Passthrough"):
|
|
| 20 |
+ obj.Termination = TLSTerminationPassthrough |
|
| 21 |
+ } |
|
| 22 |
+} |
|
| 23 |
+ |
|
| 24 |
+func addDefaultingFuncs(scheme *runtime.Scheme) {
|
|
| 25 |
+ err := scheme.AddDefaultingFuncs( |
|
| 26 |
+ SetDefaults_RouteSpec, |
|
| 27 |
+ SetDefaults_TLSConfig, |
|
| 28 |
+ ) |
|
| 29 |
+ if err != nil {
|
|
| 30 |
+ panic(err) |
|
| 31 |
+ } |
|
| 32 |
+} |
| ... | ... |
@@ -1,18 +1,20 @@ |
| 1 | 1 |
package v1 |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
+ "k8s.io/kubernetes/pkg/api/unversioned" |
|
| 4 | 5 |
"k8s.io/kubernetes/pkg/runtime" |
| 5 | 6 |
) |
| 6 | 7 |
|
| 8 |
+func SetDefaults_PodNodeConstraintsConfig(obj *PodNodeConstraintsConfig) {
|
|
| 9 |
+ if obj.NodeSelectorLabelBlacklist == nil {
|
|
| 10 |
+ obj.NodeSelectorLabelBlacklist = []string{
|
|
| 11 |
+ unversioned.LabelHostname, |
|
| 12 |
+ } |
|
| 13 |
+ } |
|
| 14 |
+} |
|
| 7 | 15 |
func addDefaultingFuncs(scheme *runtime.Scheme) {
|
| 8 | 16 |
err := scheme.AddDefaultingFuncs( |
| 9 |
- func(obj *PodNodeConstraintsConfig) {
|
|
| 10 |
- if obj.NodeSelectorLabelBlacklist == nil {
|
|
| 11 |
- obj.NodeSelectorLabelBlacklist = []string{
|
|
| 12 |
- "kubernetes.io/hostname", |
|
| 13 |
- } |
|
| 14 |
- } |
|
| 15 |
- }, |
|
| 17 |
+ SetDefaults_PodNodeConstraintsConfig, |
|
| 16 | 18 |
) |
| 17 | 19 |
if err != nil {
|
| 18 | 20 |
panic(err) |