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

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


The following commit(s) were added to refs/heads/master by this push:
     new 10a590e  Deactivate the Prometheus agent in trait Apply instead of 
Configure
10a590e is described below

commit 10a590ec221099789d644dfd1b1f16da9aa3c165
Author: Antonin Stefanutti <anto...@stefanutti.fr>
AuthorDate: Fri Jan 25 08:57:55 2019 +0100

    Deactivate the Prometheus agent in trait Apply instead of Configure
---
 pkg/trait/prometheus.go | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/pkg/trait/prometheus.go b/pkg/trait/prometheus.go
index 8eaa179..a0c983d 100644
--- a/pkg/trait/prometheus.go
+++ b/pkg/trait/prometheus.go
@@ -47,22 +47,17 @@ func newPrometheusTrait() *prometheusTrait {
 }
 
 func (t *prometheusTrait) Configure(e *Environment) (bool, error) {
-       enabled := false
-
-       if e.IntegrationInPhase(v1alpha1.IntegrationPhaseDeploying) && 
t.Enabled != nil && *t.Enabled {
-               enabled = true
-       }
+       return e.IntegrationInPhase(v1alpha1.IntegrationPhaseDeploying), nil
+}
 
-       // Deactivate the Prometheus Java agent accordingly
-       // Note: the AB_PROMETHEUS_OFF environment variable acts as an option 
flag
-       if !enabled {
+func (t *prometheusTrait) Apply(e *Environment) (err error) {
+       if t.Enabled == nil || !*t.Enabled {
+               // Deactivate the Prometheus Java agent
+               // Note: the AB_PROMETHEUS_OFF environment variable acts as an 
option flag
                envvar.SetVal(&e.EnvVars, "AB_PROMETHEUS_OFF", "true")
+               return nil
        }
 
-       return enabled, nil
-}
-
-func (t *prometheusTrait) Apply(e *Environment) (err error) {
        // Configure the Prometheus Java agent
        envvar.SetVal(&e.EnvVars, "AB_PROMETHEUS_PORT", strconv.Itoa(t.Port))
 

Reply via email to