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

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


The following commit(s) were added to refs/heads/main by this push:
     new e38c6ea  Reworked logging trait dependencies
e38c6ea is described below

commit e38c6ea8841236dea3188a0eeeab3b361346545b
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Wed Aug 18 11:33:48 2021 +0200

    Reworked logging trait dependencies
    
    As part of GH issue apache/camel-k#2541, moved the dependency to the 
runtime to ensure it's always present, even with custom base images or other 
customizations. This also allow us to manage the dependencies on a single place 
instead of spreading them over the codebase.
---
 pkg/trait/dependencies_test.go |  4 ++++
 pkg/trait/logging.go           | 17 ++---------------
 2 files changed, 6 insertions(+), 15 deletions(-)

diff --git a/pkg/trait/dependencies_test.go b/pkg/trait/dependencies_test.go
index f37c12d..6490a8c 100644
--- a/pkg/trait/dependencies_test.go
+++ b/pkg/trait/dependencies_test.go
@@ -86,6 +86,7 @@ func TestIntegrationDefaultDeps(t *testing.T) {
                        "camel:direct",
                        "camel:log",
                        
"mvn:org.apache.camel.quarkus:camel-quarkus-java-joor-dsl",
+                       "mvn:io.quarkus:quarkus-logging-json",
                        "mvn:org.apache.camel.k:camel-k-runtime"},
                e.Integration.Status.Dependencies,
        )
@@ -134,6 +135,7 @@ func TestIntegrationCustomDeps(t *testing.T) {
                        "camel:netty-http",
                        "org.foo:bar",
                        
"mvn:org.apache.camel.quarkus:camel-quarkus-java-joor-dsl",
+                       "mvn:io.quarkus:quarkus-logging-json",
                        "mvn:org.apache.camel.k:camel-k-runtime"},
                e.Integration.Status.Dependencies,
        )
@@ -192,6 +194,7 @@ func TestIntegrationAutoGeneratedDeps(t *testing.T) {
                        "mvn:org.apache.camel.quarkus:camel-quarkus-rest",
                        
"mvn:org.apache.camel.quarkus:camel-quarkus-java-joor-dsl",
                        "mvn:org.apache.camel.quarkus:camel-quarkus-xml-io-dsl",
+                       "mvn:io.quarkus:quarkus-logging-json",
                        "mvn:org.apache.camel.k:camel-k-runtime",
                        
"mvn:org.apache.camel.quarkus:camel-quarkus-platform-http"},
                e.Integration.Status.Dependencies,
@@ -238,6 +241,7 @@ func TestIntegrationCustomLoader(t *testing.T) {
                []string{
                        "camel:direct",
                        "camel:log",
+                       "mvn:io.quarkus:quarkus-logging-json",
                        "mvn:org.apache.camel.quarkus:camel-quarkus-yaml-dsl",
                        "mvn:org.apache.camel.k:camel-k-runtime"},
                e.Integration.Status.Dependencies,
diff --git a/pkg/trait/logging.go b/pkg/trait/logging.go
index 90e107b..0c97dcc 100644
--- a/pkg/trait/logging.go
+++ b/pkg/trait/logging.go
@@ -19,7 +19,6 @@ package trait
 
 import (
        v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
-       "github.com/apache/camel-k/pkg/util"
        "github.com/apache/camel-k/pkg/util/envvar"
 )
 
@@ -29,7 +28,6 @@ const (
        envVarQuarkusLogConsoleFormat          = "QUARKUS_LOG_CONSOLE_FORMAT"
        envVarQuarkusLogConsoleJson            = "QUARKUS_LOG_CONSOLE_JSON"
        envVarQuarkusLogConsoleJsonPrettyPrint = 
"QUARKUS_LOG_CONSOLE_JSON_PRETTY_PRINT"
-       depQuarkusLoggingJson                  = 
"mvn:io.quarkus:quarkus-logging-json"
        defaultLogLevel                        = "INFO"
 )
 
@@ -63,22 +61,10 @@ func (l loggingTrait) Configure(environment *Environment) 
(bool, error) {
                return false, nil
        }
 
-       return 
environment.IntegrationInPhase(v1.IntegrationPhaseInitialization, 
v1.IntegrationPhaseDeploying,
-               v1.IntegrationPhaseRunning), nil
+       return environment.IntegrationInPhase(v1.IntegrationPhaseDeploying, 
v1.IntegrationPhaseRunning), nil
 }
 
 func (l loggingTrait) Apply(environment *Environment) error {
-       if environment.IntegrationInPhase(v1.IntegrationPhaseInitialization) {
-               if IsTrue(l.Json) {
-                       if environment.Integration.Status.Dependencies == nil {
-                               environment.Integration.Status.Dependencies = 
make([]string, 0)
-                       }
-                       
util.StringSliceUniqueAdd(&environment.Integration.Status.Dependencies, 
depQuarkusLoggingJson)
-               }
-
-               return nil
-       }
-
        envvar.SetVal(&environment.EnvVars, envVarQuarkusLogLevel, l.Level)
 
        if l.Format != "" {
@@ -91,6 +77,7 @@ func (l loggingTrait) Apply(environment *Environment) error {
                        envvar.SetVal(&environment.EnvVars, 
envVarQuarkusLogConsoleJsonPrettyPrint, True)
                }
        } else {
+               // If the trait is false OR unset, we default to false.
                envvar.SetVal(&environment.EnvVars, 
envVarQuarkusLogConsoleJson, False)
 
                if IsNilOrTrue(l.Color) {

Reply via email to