astefanutti commented on a change in pull request #1787:
URL: https://github.com/apache/camel-k/pull/1787#discussion_r517153678



##########
File path: deploy/operator-role-olm.yaml
##########
@@ -47,6 +47,15 @@ rules:
   - patch
   - update
   - watch
+- apiGroups:
+  - "policy"
+  resources:
+  - poddisruptionbudgets
+  verbs:
+  - create
+  - delete
+  - get
+  - update

Review comment:
       `patch` verb is probably to be added.
   
   Also, `operator-role-kubernetes.yaml` must be updated.

##########
File path: pkg/trait/pod.go
##########
@@ -0,0 +1,100 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package trait
+
+import (
+       "fmt"
+       v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
+       "k8s.io/api/policy/v1beta1"
+       metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+       "k8s.io/apimachinery/pkg/util/intstr"
+)
+
+// The PodDisruptionBudget trait is used to configure the pdb
+//
+// +camel-k:trait=pod
+type podTrait struct {
+       BaseTrait      `property:",squash"`
+       MaxUnavailable string `property:"max-unavailable" 
json:"maxUnavailable,omitempty"`
+       MinAvailable   string `property:"min-available" 
json:"minAvailable,omitempty"`
+}
+
+func newPodTrait() Trait {
+       return &podTrait{
+               BaseTrait: NewBaseTrait("pod", 900),
+       }
+}
+
+func (t *podTrait) Configure(e *Environment) (bool, error) {
+       if t.Enabled != nil && !*t.Enabled {
+               return false, nil
+       }
+
+       return e.IntegrationInPhase(
+               v1.IntegrationPhaseDeploying,
+               v1.IntegrationPhaseRunning,
+       ), nil
+}
+
+func (t *podTrait) Apply(e *Environment) error {
+       pdb, err := t.generatePodDisruptionBudget(e.Integration)

Review comment:
       The idiomatic way is to check the `err` right after the method call, and 
return `nil` at the end of the method.

##########
File path: pkg/trait/pod_test.go
##########
@@ -0,0 +1,121 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package trait
+
+import (
+       "k8s.io/api/policy/v1beta1"

Review comment:
       Nit: group the import with others from the same TLD.

##########
File path: deploy/operator-role-openshift.yaml
##########
@@ -47,6 +47,15 @@ rules:
   - patch
   - update
   - watch
+- apiGroups:
+    - "policy"
+  resources:
+    - poddisruptionbudgets
+  verbs:
+    - create
+    - delete
+    - get
+    - update

Review comment:
       `patch` verb is probably to be added.




----------------------------------------------------------------
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


Reply via email to