This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch camel-main
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 4c7b9d81cefac32085650dbfdca2f496896192c9
Author: Antonin Stefanutti <anto...@stefanutti.fr>
AuthorDate: Tue Jun 8 10:19:20 2021 +0200

    chore(doc): Fix Pod trait documentation formatting
---
 docs/modules/traits/pages/pod.adoc | 31 +++++++++++++++++++------------
 pkg/trait/pod.go                   | 23 ++++++++++++-----------
 2 files changed, 31 insertions(+), 23 deletions(-)

diff --git a/docs/modules/traits/pages/pod.adoc 
b/docs/modules/traits/pages/pod.adoc
index 6d95acb..c81ff62 100755
--- a/docs/modules/traits/pages/pod.adoc
+++ b/docs/modules/traits/pages/pod.adoc
@@ -1,25 +1,28 @@
 = Pod Trait
 
 // Start of autogenerated code - DO NOT EDIT! (description)
-   The pod trait allows the customization of the Integration pods.
-   It applies the `PodSpecTemplate` struct contained in the Integration 
`.spec.podTemplate` field, into the Integration deployment Pods template, using 
strategic merge patch.
+The pod trait allows the customization of the Integration pods.
+It applies the `PodSpecTemplate` struct contained in the Integration 
`.spec.podTemplate` field,
+into the Integration deployment Pods template, using strategic merge patch.
 
-   This can be used to customize the container where Camel routes execute, by 
using the `integration` container name.
+This can be used to customize the container where Camel routes execute,
+by using the `integration` container name.
 
 
 This trait is available in the following profiles: **Kubernetes, Knative, 
OpenShift**.
 
 // End of autogenerated code - DO NOT EDIT! (description)
 
-*Note 1*: In current implementation template options updates also the 
configuration options defined via CLI, for example in:
+*Note 1*: In the current implementation, template options override the 
configuration options defined via CLI, for example in:
 
 [source,console]
 ----
 $ kamel run integration.groovy --pod-template template.yaml --env 
TEST_VARIABLE=will_be_overriden --env ANOTHER_VARIABLE=Im_There
 ----
-`TEST_VARIABLE` will be overwritten by the value from the  template and 
`ANOTHER_VARIABLE` will stay unchanged.
 
-*Note 2:* Changes in integration's container entry point aren't applied due to 
current trait execution order.
+The value from the template overwrites the `TEST_VARIABLE` environment 
variable, while `ANOTHER_VARIABLE` stays unchanged.
+
+*Note 2:* Changes to the `integration` container entrypoint aren't applied due 
to current trait execution order.
 
 // Start of autogenerated code - DO NOT EDIT! (configuration)
 == Configuration
@@ -44,7 +47,10 @@ The following configuration options are available:
 // End of autogenerated code - DO NOT EDIT! (configuration)
 
 == Example
-We have an integration that will read files from defined folder:
+
+With the following Integration, that reads files from a directory:
+
+.integration.groovy
 [source,groovy]
 ----
 from('file:///var/log')
@@ -53,8 +59,10 @@ from('file:///var/log')
  .log('${body}')
 
 ----
-The content of the folder might be autogenerated by bash script using a 
sidecar container. The pod template could be defined as follows:
 
+Plus the following Pod template, that adds a sidecar container to the 
Integration Pod, generating some data into the directory, and mounts it into 
the `integration` container:
+
+.template.yaml
 [source,yaml]
 ----
 containers:
@@ -65,11 +73,9 @@ containers:
     volumeMounts:
       - name: var-logs
         mountPath: /var/log
-  - name: sidecar-container
+  - name: sidecar
     image: busybox
     command: [ "/bin/sh" , "-c", "while true; do echo $(date -u) 'Content from 
the sidecar container' > /var/log/file.txt; sleep 1;done" ]
-
-    resources: { }
     volumeMounts:
       - name: var-logs
         mountPath: /var/log
@@ -78,7 +84,8 @@ volumes:
     emptyDir: { }
 ----
 
-Integration can be verified by running:
+The Integration route logs the content of the file generated by the sidecar 
container, e.g.:
+
 [source,console]
 ----
 $ kamel run integration.groovy --pod-template template.yaml
diff --git a/pkg/trait/pod.go b/pkg/trait/pod.go
index 1f56611..328fca9 100644
--- a/pkg/trait/pod.go
+++ b/pkg/trait/pod.go
@@ -19,20 +19,24 @@ package trait
 
 import (
        "fmt"
-       v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
+
+       appsv1 "k8s.io/api/apps/v1"
        "k8s.io/api/batch/v1beta1"
        corev1 "k8s.io/api/core/v1"
        "k8s.io/apimachinery/pkg/util/json"
        "k8s.io/apimachinery/pkg/util/strategicpatch"
+
        serving "knative.dev/serving/pkg/apis/serving/v1"
 
-       appsv1 "k8s.io/api/apps/v1"
+       v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
 )
 
-//    The pod trait allows the customization of the Integration pods.
-//    It applies the `PodSpecTemplate` struct contained in the Integration 
`.spec.podTemplate` field, into the Integration deployment Pods template, using 
strategic merge patch.
+// The pod trait allows the customization of the Integration pods.
+// It applies the `PodSpecTemplate` struct contained in the Integration 
`.spec.podTemplate` field,
+// into the Integration deployment Pods template, using strategic merge patch.
 //
-//    This can be used to customize the container where Camel routes execute, 
by using the `integration` container name.
+// This can be used to customize the container where Camel routes execute,
+// by using the `integration` container name.
 //
 // +camel-k:trait=pod
 type podTrait struct {
@@ -54,10 +58,7 @@ func (t *podTrait) Configure(e *Environment) (bool, error) {
                return false, nil
        }
 
-       return e.IntegrationInPhase(
-               v1.IntegrationPhaseDeploying,
-               v1.IntegrationPhaseRunning,
-       ), nil
+       return e.IntegrationInPhase(v1.IntegrationPhaseDeploying, 
v1.IntegrationPhaseRunning), nil
 }
 
 func (t *podTrait) Apply(e *Environment) error {
@@ -65,7 +66,7 @@ func (t *podTrait) Apply(e *Environment) error {
        var patchedPodSpec *corev1.PodSpec
        strategy, err := e.DetermineControllerStrategy()
        if err != nil {
-               return fmt.Errorf("unable to determine the controller stratedy")
+               return fmt.Errorf("unable to determine the controller strategy")
        }
        switch strategy {
        case ControllerStrategyCronJob:
@@ -90,7 +91,7 @@ func (t *podTrait) Apply(e *Environment) error {
                e.Resources.VisitKnativeService(func(s *serving.Service) {
                        if s.Name == e.Integration.Name {
                                if patchedPodSpec, err = 
t.applyChangesTo(&s.Spec.Template.Spec.PodSpec, changes); err == nil {
-                                       s.Spec.Template.Spec.PodSpec = * 
patchedPodSpec
+                                       s.Spec.Template.Spec.PodSpec = 
*patchedPodSpec
                                }
                        }
                })

Reply via email to