This is an automated email from the ASF dual-hosted git repository.
tsato 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 3cedfa0dd fix(trait): nil pointer dereference applying trait during
kit building
3cedfa0dd is described below
commit 3cedfa0ddcb840db933d1574a20b46a7dcfab38e
Author: Tadayoshi Sato <[email protected]>
AuthorDate: Fri Jul 22 14:42:00 2022 +0900
fix(trait): nil pointer dereference applying trait during kit building
This issue happened when an trait was enabled at IntegrationPlatform
which is implemented not considering possible absence of Integration.
Fix #3205
---
addons/keda/keda.go | 3 ++-
addons/master/master.go | 9 +++++----
addons/threescale/3scale.go | 6 ++++--
addons/tracing/tracing.go | 2 +-
pkg/trait/affinity.go | 2 +-
pkg/trait/builder.go | 2 +-
pkg/trait/container.go | 2 +-
pkg/trait/cron.go | 16 +++++++++-------
pkg/trait/dependencies.go | 2 +-
pkg/trait/deployment.go | 16 +++++++++-------
pkg/trait/environment.go | 6 +++---
pkg/trait/error_handler.go | 2 +-
pkg/trait/gc.go | 2 +-
pkg/trait/health.go | 3 ++-
pkg/trait/ingress.go | 17 ++++++++++-------
pkg/trait/istio.go | 6 +++---
pkg/trait/jolokia.go | 2 +-
pkg/trait/kamelets.go | 2 +-
pkg/trait/knative.go | 2 +-
pkg/trait/knative_service.go | 16 +++++++++-------
pkg/trait/logging.go | 20 ++++++++++----------
pkg/trait/mount.go | 2 +-
pkg/trait/openapi.go | 6 +-----
pkg/trait/owner.go | 6 +-----
pkg/trait/pdb.go | 2 +-
pkg/trait/platform.go | 2 +-
pkg/trait/pod.go | 4 ++--
pkg/trait/prometheus.go | 2 +-
pkg/trait/pull_secret.go | 2 +-
pkg/trait/registry.go | 2 +-
pkg/trait/route.go | 2 +-
pkg/trait/service.go | 16 +++++++++-------
pkg/trait/service_binding.go | 2 +-
pkg/trait/toleration.go | 2 +-
pkg/trait/trait.go | 2 +-
35 files changed, 99 insertions(+), 91 deletions(-)
diff --git a/addons/keda/keda.go b/addons/keda/keda.go
index 4d04fdd18..26ded971b 100644
--- a/addons/keda/keda.go
+++ b/addons/keda/keda.go
@@ -42,6 +42,7 @@ import (
autoscalingv1 "k8s.io/api/autoscaling/v1"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ "k8s.io/utils/pointer"
ctrl "sigs.k8s.io/controller-runtime/pkg/client"
)
@@ -116,7 +117,7 @@ func NewKedaTrait() trait.Trait {
}
func (t *kedaTrait) Configure(e *trait.Environment) (bool, error) {
- if t.Enabled == nil || !*t.Enabled {
+ if e.Integration == nil || !pointer.BoolDeref(t.Enabled, false) {
return false, nil
}
diff --git a/addons/master/master.go b/addons/master/master.go
index 31ae161fd..5c79ffde2 100644
--- a/addons/master/master.go
+++ b/addons/master/master.go
@@ -21,6 +21,7 @@ import (
"fmt"
"strings"
+ "k8s.io/utils/pointer"
ctrl "sigs.k8s.io/controller-runtime/pkg/client"
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
@@ -84,7 +85,7 @@ var (
)
func (t *masterTrait) Configure(e *trait.Environment) (bool, error) {
- if t.Enabled != nil && !*t.Enabled {
+ if e.Integration == nil || !pointer.BoolDeref(t.Enabled, true) {
return false, nil
}
@@ -92,7 +93,7 @@ func (t *masterTrait) Configure(e *trait.Environment) (bool,
error) {
return false, nil
}
- if t.Auto == nil || *t.Auto {
+ if pointer.BoolDeref(t.Auto, true) {
// Check if the master component has been used
sources, err := kubernetes.ResolveIntegrationSources(e.Ctx,
t.Client, e.Integration, e.Resources)
if err != nil {
@@ -110,7 +111,7 @@ func (t *masterTrait) Configure(e *trait.Environment)
(bool, error) {
}
}
- if t.Enabled == nil || !*t.Enabled {
+ if !pointer.BoolDeref(t.Enabled, false) {
return false, nil
}
@@ -145,7 +146,7 @@ func (t *masterTrait) Configure(e *trait.Environment)
(bool, error) {
}
}
- return t.Enabled != nil && *t.Enabled, nil
+ return pointer.BoolDeref(t.Enabled, true), nil
}
func (t *masterTrait) Apply(e *trait.Environment) error {
diff --git a/addons/threescale/3scale.go b/addons/threescale/3scale.go
index e7f246deb..89ddef8f0 100644
--- a/addons/threescale/3scale.go
+++ b/addons/threescale/3scale.go
@@ -21,6 +21,7 @@ import (
"strconv"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ "k8s.io/utils/pointer"
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
traitv1 "github.com/apache/camel-k/pkg/apis/camel/v1/trait"
@@ -87,7 +88,7 @@ func NewThreeScaleTrait() trait.Trait {
}
func (t *threeScaleTrait) Configure(e *trait.Environment) (bool, error) {
- if t.Enabled == nil || !*t.Enabled {
+ if e.Integration == nil || !pointer.BoolDeref(t.Enabled, false) {
// disabled by default
return false, nil
}
@@ -96,7 +97,7 @@ func (t *threeScaleTrait) Configure(e *trait.Environment)
(bool, error) {
return false, nil
}
- if t.Auto == nil || *t.Auto {
+ if pointer.BoolDeref(t.Auto, true) {
if t.Scheme == "" {
t.Scheme = ThreeScaleSchemeDefaultValue
}
@@ -111,6 +112,7 @@ func (t *threeScaleTrait) Configure(e *trait.Environment)
(bool, error) {
t.DescriptionPath = &openAPI
}
}
+
return true, nil
}
diff --git a/addons/tracing/tracing.go b/addons/tracing/tracing.go
index 1fffd3dc8..7423eb9fb 100644
--- a/addons/tracing/tracing.go
+++ b/addons/tracing/tracing.go
@@ -84,7 +84,7 @@ func NewTracingTrait() trait.Trait {
}
func (t *tracingTrait) Configure(e *trait.Environment) (bool, error) {
- if !pointer.BoolDeref(t.Enabled, false) {
+ if e.Integration == nil || !pointer.BoolDeref(t.Enabled, false) {
return false, nil
}
diff --git a/pkg/trait/affinity.go b/pkg/trait/affinity.go
index dc67b1785..1fa051ac3 100644
--- a/pkg/trait/affinity.go
+++ b/pkg/trait/affinity.go
@@ -47,7 +47,7 @@ func newAffinityTrait() Trait {
}
func (t *affinityTrait) Configure(e *Environment) (bool, error) {
- if !pointer.BoolDeref(t.Enabled, false) {
+ if e.Integration == nil || !pointer.BoolDeref(t.Enabled, false) {
return false, nil
}
diff --git a/pkg/trait/builder.go b/pkg/trait/builder.go
index 23efd93de..fff4aff9d 100644
--- a/pkg/trait/builder.go
+++ b/pkg/trait/builder.go
@@ -53,7 +53,7 @@ func (t *builderTrait) InfluencesKit() bool {
}
func (t *builderTrait) Configure(e *Environment) (bool, error) {
- if !pointer.BoolDeref(t.Enabled, true) {
+ if e.IntegrationKit == nil || !pointer.BoolDeref(t.Enabled, true) {
return false, nil
}
diff --git a/pkg/trait/container.go b/pkg/trait/container.go
index 1ae267dd3..426d63efb 100644
--- a/pkg/trait/container.go
+++ b/pkg/trait/container.go
@@ -69,7 +69,7 @@ func newContainerTrait() Trait {
}
func (t *containerTrait) Configure(e *Environment) (bool, error) {
- if !pointer.BoolDeref(t.Enabled, true) {
+ if e.Integration == nil || !pointer.BoolDeref(t.Enabled, true) {
return false, nil
}
diff --git a/pkg/trait/cron.go b/pkg/trait/cron.go
index f3355492a..c39e8cbd4 100644
--- a/pkg/trait/cron.go
+++ b/pkg/trait/cron.go
@@ -75,13 +75,15 @@ func newCronTrait() Trait {
}
func (t *cronTrait) Configure(e *Environment) (bool, error) {
- if !pointer.BoolDeref(t.Enabled, true) {
- e.Integration.Status.SetCondition(
- v1.IntegrationConditionCronJobAvailable,
- corev1.ConditionFalse,
- v1.IntegrationConditionCronJobNotAvailableReason,
- "explicitly disabled",
- )
+ if e.Integration == nil || !pointer.BoolDeref(t.Enabled, true) {
+ if e.Integration != nil {
+ e.Integration.Status.SetCondition(
+ v1.IntegrationConditionCronJobAvailable,
+ corev1.ConditionFalse,
+
v1.IntegrationConditionCronJobNotAvailableReason,
+ "explicitly disabled",
+ )
+ }
return false, nil
}
diff --git a/pkg/trait/dependencies.go b/pkg/trait/dependencies.go
index 9278dbc26..440291c9a 100644
--- a/pkg/trait/dependencies.go
+++ b/pkg/trait/dependencies.go
@@ -41,7 +41,7 @@ func newDependenciesTrait() Trait {
}
func (t *dependenciesTrait) Configure(e *Environment) (bool, error) {
- if !pointer.BoolDeref(t.Enabled, true) {
+ if e.Integration == nil || !pointer.BoolDeref(t.Enabled, true) {
return false, nil
}
diff --git a/pkg/trait/deployment.go b/pkg/trait/deployment.go
index 934eef07b..d7a966d93 100644
--- a/pkg/trait/deployment.go
+++ b/pkg/trait/deployment.go
@@ -44,13 +44,15 @@ func newDeploymentTrait() Trait {
}
func (t *deploymentTrait) Configure(e *Environment) (bool, error) {
- if !pointer.BoolDeref(t.Enabled, true) {
- e.Integration.Status.SetCondition(
- v1.IntegrationConditionDeploymentAvailable,
- corev1.ConditionFalse,
- v1.IntegrationConditionDeploymentAvailableReason,
- "explicitly disabled",
- )
+ if e.Integration == nil || !pointer.BoolDeref(t.Enabled, true) {
+ if e.Integration != nil {
+ e.Integration.Status.SetCondition(
+ v1.IntegrationConditionDeploymentAvailable,
+ corev1.ConditionFalse,
+
v1.IntegrationConditionDeploymentAvailableReason,
+ "explicitly disabled",
+ )
+ }
return false, nil
}
diff --git a/pkg/trait/environment.go b/pkg/trait/environment.go
index b9c1ac315..ab12eb817 100644
--- a/pkg/trait/environment.go
+++ b/pkg/trait/environment.go
@@ -62,11 +62,11 @@ func newEnvironmentTrait() Trait {
}
func (t *environmentTrait) Configure(e *Environment) (bool, error) {
- if pointer.BoolDeref(t.Enabled, true) {
- return e.IntegrationInRunningPhases(), nil
+ if e.Integration == nil || !pointer.BoolDeref(t.Enabled, true) {
+ return false, nil
}
- return false, nil
+ return e.IntegrationInRunningPhases(), nil
}
func (t *environmentTrait) Apply(e *Environment) error {
diff --git a/pkg/trait/error_handler.go b/pkg/trait/error_handler.go
index c906ca40f..529467579 100644
--- a/pkg/trait/error_handler.go
+++ b/pkg/trait/error_handler.go
@@ -49,7 +49,7 @@ func (t *errorHandlerTrait) IsPlatformTrait() bool {
}
func (t *errorHandlerTrait) Configure(e *Environment) (bool, error) {
- if !pointer.BoolDeref(t.Enabled, true) {
+ if e.Integration == nil || !pointer.BoolDeref(t.Enabled, true) {
return false, nil
}
diff --git a/pkg/trait/gc.go b/pkg/trait/gc.go
index 5c0db1b8d..755b51b9a 100644
--- a/pkg/trait/gc.go
+++ b/pkg/trait/gc.go
@@ -70,7 +70,7 @@ func newGCTrait() Trait {
}
func (t *gcTrait) Configure(e *Environment) (bool, error) {
- if !pointer.BoolDeref(t.Enabled, true) {
+ if e.Integration == nil || !pointer.BoolDeref(t.Enabled, true) {
return false, nil
}
diff --git a/pkg/trait/health.go b/pkg/trait/health.go
index cf233d3e6..882487e17 100644
--- a/pkg/trait/health.go
+++ b/pkg/trait/health.go
@@ -51,7 +51,8 @@ func newHealthTrait() Trait {
}
func (t *healthTrait) Configure(e *Environment) (bool, error) {
- if !e.IntegrationInPhase(v1.IntegrationPhaseInitialization) &&
!e.IntegrationInRunningPhases() {
+ if e.Integration == nil ||
+ !e.IntegrationInPhase(v1.IntegrationPhaseInitialization) &&
!e.IntegrationInRunningPhases() {
return false, nil
}
diff --git a/pkg/trait/ingress.go b/pkg/trait/ingress.go
index 5ee3aaf1f..0c46ef4ac 100644
--- a/pkg/trait/ingress.go
+++ b/pkg/trait/ingress.go
@@ -50,13 +50,16 @@ func (t *ingressTrait) IsAllowedInProfile(profile
v1.TraitProfile) bool {
}
func (t *ingressTrait) Configure(e *Environment) (bool, error) {
- if !pointer.BoolDeref(t.Enabled, true) {
- e.Integration.Status.SetCondition(
- v1.IntegrationConditionExposureAvailable,
- corev1.ConditionFalse,
- v1.IntegrationConditionIngressNotAvailableReason,
- "explicitly disabled",
- )
+ if e.Integration == nil || !pointer.BoolDeref(t.Enabled, true) {
+ if e.Integration != nil {
+ e.Integration.Status.SetCondition(
+ v1.IntegrationConditionExposureAvailable,
+ corev1.ConditionFalse,
+
v1.IntegrationConditionIngressNotAvailableReason,
+ "explicitly disabled",
+ )
+ }
+
return false, nil
}
diff --git a/pkg/trait/istio.go b/pkg/trait/istio.go
index f065c58db..27d559c55 100644
--- a/pkg/trait/istio.go
+++ b/pkg/trait/istio.go
@@ -48,11 +48,11 @@ func newIstioTrait() Trait {
}
func (t *istioTrait) Configure(e *Environment) (bool, error) {
- if pointer.BoolDeref(t.Enabled, false) {
- return e.IntegrationInRunningPhases(), nil
+ if e.Integration == nil || !pointer.BoolDeref(t.Enabled, false) {
+ return false, nil
}
- return false, nil
+ return e.IntegrationInRunningPhases(), nil
}
func (t *istioTrait) Apply(e *Environment) error {
diff --git a/pkg/trait/jolokia.go b/pkg/trait/jolokia.go
index 0e1fc51d4..209fbf36a 100644
--- a/pkg/trait/jolokia.go
+++ b/pkg/trait/jolokia.go
@@ -45,7 +45,7 @@ func newJolokiaTrait() Trait {
}
func (t *jolokiaTrait) Configure(e *Environment) (bool, error) {
- if !pointer.BoolDeref(t.Enabled, false) {
+ if e.Integration == nil || !pointer.BoolDeref(t.Enabled, false) {
return false, nil
}
diff --git a/pkg/trait/kamelets.go b/pkg/trait/kamelets.go
index 5ac294c80..e71f78864 100644
--- a/pkg/trait/kamelets.go
+++ b/pkg/trait/kamelets.go
@@ -76,7 +76,7 @@ func (t *kameletsTrait) IsPlatformTrait() bool {
}
func (t *kameletsTrait) Configure(e *Environment) (bool, error) {
- if !pointer.BoolDeref(t.Enabled, true) {
+ if e.Integration == nil || !pointer.BoolDeref(t.Enabled, true) {
return false, nil
}
diff --git a/pkg/trait/knative.go b/pkg/trait/knative.go
index bdf03b3d7..4db8a43f3 100644
--- a/pkg/trait/knative.go
+++ b/pkg/trait/knative.go
@@ -69,7 +69,7 @@ func (t *knativeTrait) IsAllowedInProfile(profile
v1.TraitProfile) bool {
}
func (t *knativeTrait) Configure(e *Environment) (bool, error) {
- if !pointer.BoolDeref(t.Enabled, true) {
+ if e.Integration == nil || !pointer.BoolDeref(t.Enabled, true) {
return false, nil
}
diff --git a/pkg/trait/knative_service.go b/pkg/trait/knative_service.go
index 55c813d00..129781028 100644
--- a/pkg/trait/knative_service.go
+++ b/pkg/trait/knative_service.go
@@ -66,13 +66,15 @@ func (t *knativeServiceTrait) IsAllowedInProfile(profile
v1.TraitProfile) bool {
}
func (t *knativeServiceTrait) Configure(e *Environment) (bool, error) {
- if !pointer.BoolDeref(t.Enabled, true) {
- e.Integration.Status.SetCondition(
- v1.IntegrationConditionKnativeServiceAvailable,
- corev1.ConditionFalse,
- v1.IntegrationConditionKnativeServiceNotAvailableReason,
- "explicitly disabled",
- )
+ if e.Integration == nil || !pointer.BoolDeref(t.Enabled, true) {
+ if e.Integration != nil {
+ e.Integration.Status.SetCondition(
+ v1.IntegrationConditionKnativeServiceAvailable,
+ corev1.ConditionFalse,
+
v1.IntegrationConditionKnativeServiceNotAvailableReason,
+ "explicitly disabled",
+ )
+ }
return false, nil
}
diff --git a/pkg/trait/logging.go b/pkg/trait/logging.go
index 99eef35b3..aa6fa0078 100644
--- a/pkg/trait/logging.go
+++ b/pkg/trait/logging.go
@@ -47,32 +47,32 @@ func newLoggingTraitTrait() Trait {
}
}
-func (l loggingTrait) Configure(environment *Environment) (bool, error) {
- if !pointer.BoolDeref(l.Enabled, true) {
+func (l loggingTrait) Configure(e *Environment) (bool, error) {
+ if e.Integration == nil || !pointer.BoolDeref(l.Enabled, true) {
return false, nil
}
- return environment.IntegrationInRunningPhases(), nil
+ return e.IntegrationInRunningPhases(), nil
}
-func (l loggingTrait) Apply(environment *Environment) error {
- envvar.SetVal(&environment.EnvVars, envVarQuarkusLogLevel, l.Level)
+func (l loggingTrait) Apply(e *Environment) error {
+ envvar.SetVal(&e.EnvVars, envVarQuarkusLogLevel, l.Level)
if l.Format != "" {
- envvar.SetVal(&environment.EnvVars,
envVarQuarkusLogConsoleFormat, l.Format)
+ envvar.SetVal(&e.EnvVars, envVarQuarkusLogConsoleFormat,
l.Format)
}
if pointer.BoolDeref(l.JSON, false) {
- envvar.SetVal(&environment.EnvVars,
envVarQuarkusLogConsoleJSON, True)
+ envvar.SetVal(&e.EnvVars, envVarQuarkusLogConsoleJSON, True)
if pointer.BoolDeref(l.JSONPrettyPrint, false) {
- envvar.SetVal(&environment.EnvVars,
envVarQuarkusLogConsoleJSONPrettyPrint, True)
+ envvar.SetVal(&e.EnvVars,
envVarQuarkusLogConsoleJSONPrettyPrint, True)
}
} else {
// If the trait is false OR unset, we default to false.
- envvar.SetVal(&environment.EnvVars,
envVarQuarkusLogConsoleJSON, False)
+ envvar.SetVal(&e.EnvVars, envVarQuarkusLogConsoleJSON, False)
if pointer.BoolDeref(l.Color, true) {
- envvar.SetVal(&environment.EnvVars,
envVarQuarkusLogConsoleColor, True)
+ envvar.SetVal(&e.EnvVars, envVarQuarkusLogConsoleColor,
True)
}
}
diff --git a/pkg/trait/mount.go b/pkg/trait/mount.go
index d695f437d..942f1be4f 100644
--- a/pkg/trait/mount.go
+++ b/pkg/trait/mount.go
@@ -49,7 +49,7 @@ func newMountTrait() Trait {
}
func (t *mountTrait) Configure(e *Environment) (bool, error) {
- if !pointer.BoolDeref(t.Enabled, true) {
+ if e.Integration == nil || !pointer.BoolDeref(t.Enabled, true) {
return false, nil
}
diff --git a/pkg/trait/openapi.go b/pkg/trait/openapi.go
index b5b54914a..e19d40a5c 100644
--- a/pkg/trait/openapi.go
+++ b/pkg/trait/openapi.go
@@ -65,11 +65,7 @@ func (t *openAPITrait) IsPlatformTrait() bool {
}
func (t *openAPITrait) Configure(e *Environment) (bool, error) {
- if !pointer.BoolDeref(t.Enabled, true) {
- return false, nil
- }
-
- if e.Integration == nil {
+ if e.Integration == nil || !pointer.BoolDeref(t.Enabled, true) {
return false, nil
}
diff --git a/pkg/trait/owner.go b/pkg/trait/owner.go
index 8c8a5fc53..1bd42f6e0 100644
--- a/pkg/trait/owner.go
+++ b/pkg/trait/owner.go
@@ -40,11 +40,7 @@ func newOwnerTrait() Trait {
}
func (t *ownerTrait) Configure(e *Environment) (bool, error) {
- if !pointer.BoolDeref(t.Enabled, true) {
- return false, nil
- }
-
- if e.Integration == nil {
+ if e.Integration == nil || !pointer.BoolDeref(t.Enabled, true) {
return false, nil
}
diff --git a/pkg/trait/pdb.go b/pkg/trait/pdb.go
index ba98af215..6f02265f1 100644
--- a/pkg/trait/pdb.go
+++ b/pkg/trait/pdb.go
@@ -41,7 +41,7 @@ func newPdbTrait() Trait {
}
func (t *pdbTrait) Configure(e *Environment) (bool, error) {
- if !pointer.BoolDeref(t.Enabled, false) {
+ if e.Integration == nil || !pointer.BoolDeref(t.Enabled, false) {
return false, nil
}
diff --git a/pkg/trait/platform.go b/pkg/trait/platform.go
index 263214ef4..635bc1258 100644
--- a/pkg/trait/platform.go
+++ b/pkg/trait/platform.go
@@ -43,7 +43,7 @@ func newPlatformTrait() Trait {
}
func (t *platformTrait) Configure(e *Environment) (bool, error) {
- if !pointer.BoolDeref(t.Enabled, true) {
+ if e.Integration == nil || !pointer.BoolDeref(t.Enabled, true) {
return false, nil
}
diff --git a/pkg/trait/pod.go b/pkg/trait/pod.go
index b6ea6ed1f..85ff68531 100644
--- a/pkg/trait/pod.go
+++ b/pkg/trait/pod.go
@@ -45,11 +45,11 @@ func newPodTrait() Trait {
}
func (t *podTrait) Configure(e *Environment) (bool, error) {
- if !pointer.BoolDeref(t.Enabled, true) {
+ if e.Integration == nil || !pointer.BoolDeref(t.Enabled, true) {
return false, nil
}
- if e.Integration != nil && e.Integration.Spec.PodTemplate == nil {
+ if e.Integration.Spec.PodTemplate == nil {
return false, nil
}
diff --git a/pkg/trait/prometheus.go b/pkg/trait/prometheus.go
index 1f107dcdf..531dc73cb 100644
--- a/pkg/trait/prometheus.go
+++ b/pkg/trait/prometheus.go
@@ -46,7 +46,7 @@ func newPrometheusTrait() Trait {
}
func (t *prometheusTrait) Configure(e *Environment) (bool, error) {
- if !pointer.BoolDeref(t.Enabled, false) {
+ if e.Integration == nil || !pointer.BoolDeref(t.Enabled, false) {
return false, nil
}
diff --git a/pkg/trait/pull_secret.go b/pkg/trait/pull_secret.go
index 4a00537c2..55ff73e9d 100644
--- a/pkg/trait/pull_secret.go
+++ b/pkg/trait/pull_secret.go
@@ -47,7 +47,7 @@ func newPullSecretTrait() Trait {
}
func (t *pullSecretTrait) Configure(e *Environment) (bool, error) {
- if !pointer.BoolDeref(t.Enabled, true) {
+ if e.Integration == nil || !pointer.BoolDeref(t.Enabled, true) {
return false, nil
}
diff --git a/pkg/trait/registry.go b/pkg/trait/registry.go
index c303c5b03..ef972169e 100644
--- a/pkg/trait/registry.go
+++ b/pkg/trait/registry.go
@@ -55,7 +55,7 @@ func (t *registryTrait) InfluencesKit() bool {
func (t *registryTrait) Configure(e *Environment) (bool, error) {
// disabled by default
- if !pointer.BoolDeref(t.Enabled, false) {
+ if e.IntegrationKit == nil || !pointer.BoolDeref(t.Enabled, false) {
return false, nil
}
diff --git a/pkg/trait/route.go b/pkg/trait/route.go
index 5b6da6616..008f71607 100644
--- a/pkg/trait/route.go
+++ b/pkg/trait/route.go
@@ -52,7 +52,7 @@ func (t *routeTrait) IsAllowedInProfile(profile
v1.TraitProfile) bool {
}
func (t *routeTrait) Configure(e *Environment) (bool, error) {
- if !pointer.BoolDeref(t.Enabled, true) {
+ if e.Integration == nil || !pointer.BoolDeref(t.Enabled, true) {
if e.Integration != nil {
e.Integration.Status.SetCondition(
v1.IntegrationConditionExposureAvailable,
diff --git a/pkg/trait/service.go b/pkg/trait/service.go
index a83a7c545..d4211fb39 100644
--- a/pkg/trait/service.go
+++ b/pkg/trait/service.go
@@ -48,13 +48,15 @@ func (t *serviceTrait) IsAllowedInProfile(profile
v1.TraitProfile) bool {
}
func (t *serviceTrait) Configure(e *Environment) (bool, error) {
- if !pointer.BoolDeref(t.Enabled, true) {
- e.Integration.Status.SetCondition(
- v1.IntegrationConditionServiceAvailable,
- corev1.ConditionFalse,
- v1.IntegrationConditionServiceNotAvailableReason,
- "explicitly disabled",
- )
+ if e.Integration == nil || !pointer.BoolDeref(t.Enabled, true) {
+ if e.Integration != nil {
+ e.Integration.Status.SetCondition(
+ v1.IntegrationConditionServiceAvailable,
+ corev1.ConditionFalse,
+
v1.IntegrationConditionServiceNotAvailableReason,
+ "explicitly disabled",
+ )
+ }
return false, nil
}
diff --git a/pkg/trait/service_binding.go b/pkg/trait/service_binding.go
index ae37c81bd..5cbac6b5a 100644
--- a/pkg/trait/service_binding.go
+++ b/pkg/trait/service_binding.go
@@ -49,7 +49,7 @@ func newServiceBindingTrait() Trait {
}
func (t *serviceBindingTrait) Configure(e *Environment) (bool, error) {
- if !pointer.BoolDeref(t.Enabled, true) {
+ if e.Integration == nil || !pointer.BoolDeref(t.Enabled, true) {
return false, nil
}
diff --git a/pkg/trait/toleration.go b/pkg/trait/toleration.go
index c8c6a79b9..447c7ac4e 100644
--- a/pkg/trait/toleration.go
+++ b/pkg/trait/toleration.go
@@ -39,7 +39,7 @@ func newTolerationTrait() Trait {
}
func (t *tolerationTrait) Configure(e *Environment) (bool, error) {
- if !pointer.BoolDeref(t.Enabled, false) {
+ if e.Integration == nil || !pointer.BoolDeref(t.Enabled, false) {
return false, nil
}
diff --git a/pkg/trait/trait.go b/pkg/trait/trait.go
index 98f8ef706..98d7429f0 100644
--- a/pkg/trait/trait.go
+++ b/pkg/trait/trait.go
@@ -80,7 +80,7 @@ func Apply(ctx context.Context, c client.Client, integration
*v1.Integration, ki
// newEnvironment creates a Environment from the given data.
func newEnvironment(ctx context.Context, c client.Client, integration
*v1.Integration, kit *v1.IntegrationKit) (*Environment, error) {
- if integration == nil && ctx == nil {
+ if integration == nil && kit == nil {
return nil, errors.New("neither integration nor kit are set")
}