Skip to content

Commit

Permalink
Reworked logging trait dependencies
Browse files Browse the repository at this point in the history
As part of GH issue #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.
  • Loading branch information
orpiske committed Aug 18, 2021
1 parent 69f0a4b commit 074c323
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 4 additions & 0 deletions pkg/trait/dependencies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -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,
)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 1 addition & 3 deletions pkg/trait/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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"
)

Expand Down Expand Up @@ -73,7 +71,6 @@ func (l loggingTrait) Apply(environment *Environment) error {
if environment.Integration.Status.Dependencies == nil {
environment.Integration.Status.Dependencies = make([]string, 0)
}
util.StringSliceUniqueAdd(&environment.Integration.Status.Dependencies, depQuarkusLoggingJson)
}

return nil
Expand All @@ -91,6 +88,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) {
Expand Down

0 comments on commit 074c323

Please sign in to comment.