astefanutti commented on a change in pull request #2078: URL: https://github.com/apache/camel-k/pull/2078#discussion_r584850173
########## File path: pkg/trait/toleration.go ########## @@ -74,46 +71,14 @@ func (t *tolerationTrait) Apply(e *Environment) (err error) { if err != nil { return err } - var specTolerations *[]corev1.Toleration - found := false - - // Deployment - deployment := e.Resources.GetDeployment(func(d *appsv1.Deployment) bool { - return d.Name == e.Integration.Name - }) - if deployment != nil { - specTolerations = &deployment.Spec.Template.Spec.Tolerations - found = true - } - - // Knative service - if !found { - knativeService := e.Resources.GetKnativeService(func(s *serving.Service) bool { - return s.Name == e.Integration.Name - }) - if knativeService != nil { - specTolerations = &knativeService.Spec.Template.Spec.Tolerations - found = true - } - } - - // Cronjob - if !found { - cronJob := e.Resources.GetCronJob(func(c *v1beta1.CronJob) bool { - return c.Name == e.Integration.Name - }) - if cronJob != nil { - specTolerations = &cronJob.Spec.JobTemplate.Spec.Template.Spec.Tolerations - found = true - } - } + podSpec := e.GetIntegrationPodSpec() // Add the toleration - if found { - if *specTolerations == nil { - *specTolerations = make([]corev1.Toleration, 0) + if podSpec != nil { Review comment: I wonder if it should fail in case the returned PodSpec is nil? ########## File path: pkg/trait/affinity.go ########## @@ -129,16 +127,11 @@ func (t *affinityTrait) addNodeAffinity(_ *Environment, deployment *appsv1.Deplo }, } - if deployment.Spec.Template.Spec.Affinity == nil { Review comment: I wonder what has changed that avoids to have that nil check? ########## File path: pkg/trait/affinity.go ########## @@ -74,28 +73,27 @@ func (t *affinityTrait) Configure(e *Environment) (bool, error) { } func (t *affinityTrait) Apply(e *Environment) (err error) { - var deployment *appsv1.Deployment - e.Resources.VisitDeployment(func(d *appsv1.Deployment) { - if d.Name == e.Integration.Name { - deployment = d + podSpec := e.GetIntegrationPodSpec() + + if podSpec != nil { Review comment: I wonder if it should fail in case the returned PodSpec is nil? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org