This is an automated email from the ASF dual-hosted git repository. pcongiusti pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit b8ae4830b197c40803a344533f0b3a3a98f510d0 Author: hernanguardado <[email protected]> AuthorDate: Fri Jul 12 18:42:16 2024 -0400 adding forcefullyEnabled for sourceless --- addons/telemetry/telemetry.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/addons/telemetry/telemetry.go b/addons/telemetry/telemetry.go index fb9e6b86b..81654830c 100644 --- a/addons/telemetry/telemetry.go +++ b/addons/telemetry/telemetry.go @@ -91,11 +91,15 @@ func NewTelemetryTrait() trait.Trait { } } +func (t *telemetryTrait) isForcefullyEnabled() bool { + return pointer.BoolDeref(t.Enabled, false) && !pointer.BoolDeref(t.Auto, true) +} + func (t *telemetryTrait) Configure(e *trait.Environment) (bool, *trait.TraitCondition, error) { if e.Integration == nil || !pointer.BoolDeref(t.Enabled, false) { return false, nil, nil } - if e.CamelCatalog == nil { + if e.CamelCatalog == nil && !t.isForcefullyEnabled() { return false, trait.NewIntegrationConditionPlatformDisabledCatalogMissing(), nil } @@ -140,10 +144,10 @@ func (t *telemetryTrait) Configure(e *trait.Environment) (bool, *trait.TraitCond func (t *telemetryTrait) Apply(e *trait.Environment) error { util.StringSliceUniqueAdd(&e.Integration.Status.Capabilities, v1.CapabilityTelemetry) - if e.CamelCatalog.Runtime.Capabilities["telemetry"].RuntimeProperties != nil { + if t.isForcefullyEnabled() || e.CamelCatalog.Runtime.Capabilities["telemetry"].RuntimeProperties != nil { t.setCatalogConfiguration(e) } else { - t.setProperties(e) + t.setRuntimeProviderProperties(e) } return nil @@ -172,13 +176,15 @@ func (t *telemetryTrait) setCatalogConfiguration(e *trait.Environment) { e.ApplicationProperties["camel.k.telemetry.samplerParentBased"] = boolean.FalseString } - for _, cp := range e.CamelCatalog.Runtime.Capabilities["telemetry"].RuntimeProperties { - e.ApplicationProperties[trait.CapabilityPropertyKey(cp.Key, e.ApplicationProperties)] = cp.Value + if e.CamelCatalog != nil && e.CamelCatalog.Runtime.Capabilities["telemetry"].RuntimeProperties != nil { + for _, cp := range e.CamelCatalog.Runtime.Capabilities["telemetry"].RuntimeProperties { + e.ApplicationProperties[trait.CapabilityPropertyKey(cp.Key, e.ApplicationProperties)] = cp.Value + } } } // Deprecated: to be removed in future release in favor of func setCatalogConfiguration(). -func (t *telemetryTrait) setProperties(e *trait.Environment) { +func (t *telemetryTrait) setRuntimeProviderProperties(e *trait.Environment) { if e.CamelCatalog == nil { return }
