From 73705647df8eae016002f577c4cfc4c02f3172c7 Mon Sep 17 00:00:00 2001 From: Antonin Stefanutti Date: Mon, 28 Jun 2021 13:41:39 +0200 Subject: [PATCH 1/2] fix: Unrecognized configuration from quarkus-logging-json --- pkg/trait/logging.go | 29 ++++++++++++----------------- pkg/trait/logging_test.go | 13 ++++++++----- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/pkg/trait/logging.go b/pkg/trait/logging.go index 72e6589d2a..f7f103a297 100644 --- a/pkg/trait/logging.go +++ b/pkg/trait/logging.go @@ -18,8 +18,6 @@ limitations under the License. package trait import ( - "strconv" - 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" @@ -32,7 +30,6 @@ const ( envVarQuarkusLogConsoleJson = "QUARKUS_LOG_CONSOLE_JSON" envVarQuarkusLogConsoleJsonPrettyPrint = "QUARKUS_LOG_CONSOLE_JSON_PRETTY_PRINT" depQuarkusLoggingJson = "quarkus-logging-json" - defaultLogFormat = "" defaultLogLevel = "INFO" ) @@ -56,17 +53,13 @@ type loggingTrait struct { func newLoggingTraitTrait() Trait { return &loggingTrait{ - BaseTrait: NewBaseTrait("logging", 800), - Color: util.BoolP(true), - Format: defaultLogFormat, - Level: defaultLogLevel, - Json: util.BoolP(false), - JsonPrettyPrint: util.BoolP(false), + BaseTrait: NewBaseTrait("logging", 800), + Level: defaultLogLevel, } } func (l loggingTrait) Configure(environment *Environment) (bool, error) { - if l.Enabled != nil && !*l.Enabled { + if util.IsFalse(l.Enabled) { return false, nil } @@ -76,7 +69,7 @@ func (l loggingTrait) Configure(environment *Environment) (bool, error) { func (l loggingTrait) Apply(environment *Environment) error { if environment.IntegrationInPhase(v1.IntegrationPhaseInitialization) { - if *l.Json { + if util.IsTrue(l.Json) { if environment.Integration.Status.Dependencies == nil { environment.Integration.Status.Dependencies = make([]string, 0) } @@ -88,15 +81,17 @@ func (l loggingTrait) Apply(environment *Environment) error { envvar.SetVal(&environment.EnvVars, envVarQuarkusLogLevel, l.Level) - if l.Format != defaultLogFormat { + if l.Format != "" { envvar.SetVal(&environment.EnvVars, envVarQuarkusLogConsoleFormat, l.Format) } - envvar.SetVal(&environment.EnvVars, envVarQuarkusLogConsoleJson, strconv.FormatBool(*l.Json)) - envvar.SetVal(&environment.EnvVars, envVarQuarkusLogConsoleJsonPrettyPrint, strconv.FormatBool(*l.JsonPrettyPrint)) - - if !*l.Json { - envvar.SetVal(&environment.EnvVars, envVarQuarkusLogConsoleColor, strconv.FormatBool(*l.Color)) + if util.IsTrue(l.Json) { + envvar.SetVal(&environment.EnvVars, envVarQuarkusLogConsoleJson, True) + if util.IsTrue(l.JsonPrettyPrint) { + envvar.SetVal(&environment.EnvVars, envVarQuarkusLogConsoleJsonPrettyPrint, True) + } + } else if util.IsNilOrTrue(l.Color) { + envvar.SetVal(&environment.EnvVars, envVarQuarkusLogConsoleColor, True) } return nil diff --git a/pkg/trait/logging_test.go b/pkg/trait/logging_test.go index e165b1e3d2..f5fc573a67 100644 --- a/pkg/trait/logging_test.go +++ b/pkg/trait/logging_test.go @@ -19,14 +19,17 @@ package trait import ( "context" + "testing" + + "github.com/stretchr/testify/assert" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + v1 "github.com/apache/camel-k/pkg/apis/camel/v1" "github.com/apache/camel-k/pkg/util/camel" "github.com/apache/camel-k/pkg/util/kubernetes" "github.com/apache/camel-k/pkg/util/test" - "github.com/stretchr/testify/assert" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "testing" ) func createLoggingTestEnv(t *testing.T, color bool, json bool, jsonPrettyPrint bool, logLevel string, logFormat string) *Environment { @@ -82,7 +85,7 @@ func createLoggingTestEnv(t *testing.T, color bool, json bool, jsonPrettyPrint b } func createDefaultLoggingTestEnv(t *testing.T) *Environment { - return createLoggingTestEnv(t, true, false, false, defaultLogLevel, defaultLogFormat) + return createLoggingTestEnv(t, true, false, false, defaultLogLevel, "") } func NewLoggingTestCatalog() *Catalog { From accb2559005d7d5244fb86384b39341a5b7915f8 Mon Sep 17 00:00:00 2001 From: Antonin Stefanutti Date: Mon, 28 Jun 2021 13:42:29 +0200 Subject: [PATCH 2/2] fix: Correct quarkus-logging-json dependency resolution --- pkg/trait/logging.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/trait/logging.go b/pkg/trait/logging.go index f7f103a297..d092aacb86 100644 --- a/pkg/trait/logging.go +++ b/pkg/trait/logging.go @@ -29,7 +29,7 @@ const ( envVarQuarkusLogConsoleFormat = "QUARKUS_LOG_CONSOLE_FORMAT" envVarQuarkusLogConsoleJson = "QUARKUS_LOG_CONSOLE_JSON" envVarQuarkusLogConsoleJsonPrettyPrint = "QUARKUS_LOG_CONSOLE_JSON_PRETTY_PRINT" - depQuarkusLoggingJson = "quarkus-logging-json" + depQuarkusLoggingJson = "mvn:io.quarkus:quarkus-logging-json" defaultLogLevel = "INFO" )