Browse code

DeploymentConfig hooks did not have round trip defaulting

Need to ensure all hooks have a ContainerName set due to defaulting

Clayton Coleman authored on 2016/02/14 08:08:28
Showing 1 changed files
... ...
@@ -261,6 +261,9 @@ func fuzzInternalObject(t *testing.T, forVersion unversioned.GroupVersion, item
261 261
 					s := int64(120)
262 262
 					params.TimeoutSeconds = &s
263 263
 				}
264
+				defaultLifecycleHook(params.Pre)
265
+				defaultLifecycleHook(params.Mid)
266
+				defaultLifecycleHook(params.Post)
264 267
 				j.RecreateParams = params
265 268
 			case deploy.DeploymentStrategyTypeRolling:
266 269
 				params := &deploy.RollingDeploymentStrategyParams{}
... ...
@@ -293,6 +296,8 @@ func fuzzInternalObject(t *testing.T, forVersion unversioned.GroupVersion, item
293 293
 						},
294 294
 					}
295 295
 				}
296
+				defaultLifecycleHook(params.Pre)
297
+				defaultLifecycleHook(params.Post)
296 298
 				if c.RandBool() {
297 299
 					params.MaxUnavailable = intstr.FromInt(int(c.RandUint64()))
298 300
 					params.MaxSurge = intstr.FromInt(int(c.RandUint64()))
... ...
@@ -397,6 +402,17 @@ func fuzzInternalObject(t *testing.T, forVersion unversioned.GroupVersion, item
397 397
 	return item
398 398
 }
399 399
 
400
+func defaultLifecycleHook(hook *deploy.LifecycleHook) {
401
+	if hook == nil {
402
+		return
403
+	}
404
+	for i := range hook.TagImages {
405
+		if len(hook.TagImages[i].ContainerName) == 0 {
406
+			hook.TagImages[i].ContainerName = "test"
407
+		}
408
+	}
409
+}
410
+
400 411
 func roundTrip(t *testing.T, codec runtime.Codec, originalItem runtime.Object) {
401 412
 	// Make a copy of the originalItem to give to conversion functions
402 413
 	// This lets us know if conversion messed with the input object