Skip to content

Commit

Permalink
Make config change triggers a default
Browse files Browse the repository at this point in the history
  • Loading branch information
smarterclayton committed Aug 22, 2015
1 parent 8c3a178 commit b63a590
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions pkg/api/serialization_test.go
Expand Up @@ -112,6 +112,10 @@ func fuzzInternalObject(t *testing.T, forVersion string, item runtime.Object, se
j.To.Name = strings.Replace(j.To.Name, ":", "-", -1)
}
},
func(j *deploy.DeploymentConfig, c fuzz.Continue) {
c.FuzzNoCustom(j)
j.Triggers = []deploy.DeploymentTriggerPolicy{{Type: deploy.DeploymentTriggerOnConfigChange}}
},
func(j *deploy.DeploymentStrategy, c fuzz.Continue) {
c.FuzzNoCustom(j)
mkintp := func(i int) *int64 {
Expand Down
7 changes: 7 additions & 0 deletions pkg/deploy/api/v1/defaults.go
Expand Up @@ -12,6 +12,13 @@ func init() {
}

err := api.Scheme.AddDefaultingFuncs(
func(obj *DeploymentConfigSpec) {
if obj.Triggers == nil {
obj.Triggers = []DeploymentTriggerPolicy{
{Type: DeploymentTriggerOnConfigChange},
}
}
},
func(obj *DeploymentStrategy) {
if len(obj.Type) == 0 {
obj.Type = DeploymentStrategyTypeRolling
Expand Down
7 changes: 6 additions & 1 deletion pkg/deploy/api/v1/defaults_test.go
Expand Up @@ -31,10 +31,15 @@ func roundTrip(t *testing.T, obj runtime.Object) runtime.Object {
return obj3
}

func TestDefaults_rollingParams(t *testing.T) {
func TestDefaults(t *testing.T) {
c := &current.DeploymentConfig{}
o := roundTrip(t, runtime.Object(c))
config := o.(*current.DeploymentConfig)

if len(config.Spec.Triggers) != 1 && config.Spec.Triggers[0].Type != current.DeploymentTriggerOnConfigChange {
t.Errorf("expected default trigger for config: %#v", config.Spec.Triggers)
}

strat := config.Spec.Strategy
if e, a := current.DeploymentStrategyTypeRolling, strat.Type; e != a {
t.Errorf("expected strategy type %s, got %s", e, a)
Expand Down

0 comments on commit b63a590

Please sign in to comment.