Skip to content

Commit

Permalink
controller: fix flavor apply proper order
Browse files Browse the repository at this point in the history
  • Loading branch information
morpheu committed Jan 22, 2024
1 parent 2f8a538 commit fdb8873
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
2 changes: 1 addition & 1 deletion controllers/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func mergeInstanceWithFlavor(instance *v1alpha1.RpaasInstance, flavor v1alpha1.R
return nil
}

mergedInstanceSpec, err := mergeInstance(*flavor.Spec.InstanceTemplate, instance.Spec)
mergedInstanceSpec, err := mergeInstance(instance.Spec, *flavor.Spec.InstanceTemplate)
if err != nil {
return err
}
Expand Down
59 changes: 59 additions & 0 deletions controllers/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,65 @@ func TestReconcileRpaasInstance_getRpaasInstance(t *testing.T) {
return i
},
},

"when there are multiple flavors and last on overrides ingress annotations": {
resources: []runtime.Object{
&v1alpha1.RpaasFlavor{
ObjectMeta: metav1.ObjectMeta{
Name: "flavor-a",
Namespace: "default",
},
Spec: v1alpha1.RpaasFlavorSpec{
InstanceTemplate: &v1alpha1.RpaasInstanceSpec{
Service: &nginxv1alpha1.NginxService{
Annotations: map[string]string{
"rpaas.extensions.tsuru.io/custom-annotation-svc": "custom svc annotation",
},
},
Ingress: &nginxv1alpha1.NginxIngress{
Annotations: map[string]string{
"rpaas.extensions.tsuru.io/custom-annotation-ingress": "foo",
},
},
},
},
},
&v1alpha1.RpaasFlavor{
ObjectMeta: metav1.ObjectMeta{
Name: "flavor-b",
Namespace: "default",
},
Spec: v1alpha1.RpaasFlavorSpec{
InstanceTemplate: &v1alpha1.RpaasInstanceSpec{
Ingress: &nginxv1alpha1.NginxIngress{
Annotations: map[string]string{
"rpaas.extensions.tsuru.io/custom-annotation-ingress": "bar",
"another.example.com/blah": "bleh",
},
},
},
},
},
},
instance: func(i *v1alpha1.RpaasInstance) *v1alpha1.RpaasInstance {
i.Spec.Flavors = []string{"flavor-a", "flavor-b"}
return i
},
expected: func(i *v1alpha1.RpaasInstance) *v1alpha1.RpaasInstance {
i.Spec.Service = &nginxv1alpha1.NginxService{
Annotations: map[string]string{
"rpaas.extensions.tsuru.io/custom-annotation-svc": "custom svc annotation",
},
}
i.Spec.Ingress = &nginxv1alpha1.NginxIngress{
Annotations: map[string]string{
"rpaas.extensions.tsuru.io/custom-annotation-ingress": "bar",
"another.example.com/blah": "bleh",
},
}
return i
},
},
}

for name, tt := range tests {
Expand Down

0 comments on commit fdb8873

Please sign in to comment.