diff --git a/addons/master/master.go b/addons/master/master.go index c60733341a..e2002e806d 100644 --- a/addons/master/master.go +++ b/addons/master/master.go @@ -91,10 +91,6 @@ func (t *masterTrait) Configure(e *trait.Environment) (bool, *trait.TraitConditi if !e.IntegrationInPhase(v1.IntegrationPhaseInitialization) && !e.IntegrationInRunningPhases() { return false, nil, nil } - if !pointer.BoolDeref(t.Enabled, false) { - return false, trait.NewIntegrationConditionUserDisabled(), nil - } - 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) @@ -115,7 +111,9 @@ func (t *masterTrait) Configure(e *trait.Environment) (bool, *trait.TraitConditi } } } - + if !pointer.BoolDeref(t.Enabled, false) { + return false, trait.NewIntegrationConditionUserDisabled(), nil + } if t.IncludeDelegateDependencies == nil || *t.IncludeDelegateDependencies { t.delegateDependencies = findAdditionalDependencies(e, meta) } diff --git a/docs/modules/ROOT/pages/architecture/traits.adoc b/docs/modules/ROOT/pages/architecture/traits.adoc index 3457b3b4ec..fc56b11928 100644 --- a/docs/modules/ROOT/pages/architecture/traits.adoc +++ b/docs/modules/ROOT/pages/architecture/traits.adoc @@ -40,7 +40,7 @@ type Trait interface { Identifiable client.Injectable InjectContext(context.Context) - Configure(environment *Environment) (bool, error) + Configure(environment *Environment) (bool, TraitCondition, error) Apply(environment *Environment) error InfluencesKit() bool InfluencesBuild(this, prev map[string]interface{}) bool @@ -51,7 +51,7 @@ type Trait interface { } ---- -Each trait will implement this interface. The most important methods that will be invoked by the xref:architecture/operator.adoc[Operator] are `Configure()` and `Apply()`. Basically, the `Configure()` method will set those inputs aforementioned (each trait has its own). The method is in charge to verify also the correctness of those expected parameters, where it makes sense (i.e., a well expected `Kubernetes` resource name). +Each trait will implement this interface. The most important methods that will be invoked by the xref:architecture/operator.adoc[Operator] are `Configure()` and `Apply()`. Basically, the `Configure()` method will set those inputs aforementioned (each trait has its own). The method is in charge to verify also the correctness of those expected parameters, where it makes sense (i.e., a well expected `Kubernetes` resource name). The function can return a `TraitCondition` object containing any informative or warning condition to be attached to the resulting Integration (for instance, traits forcefully altered by the platform, or deprecation notices). Once configured, the `Apply()` method will be called along the build or initialization phase in order to do the business logic expected for it. The `environment` variable will give you all the below resources you will need to perform your operation (ie, the `Integration` or any Kubernetes resource attached to it). You can have a deeper look at the `https://github.com/apache/camel-k/blob/main/pkg/trait/trait_types.go#L188[Environment]` struct. diff --git a/pkg/trait/trait_condition_types.go b/pkg/trait/trait_condition_types.go index 9b35647c99..6acf12dcf3 100644 --- a/pkg/trait/trait_condition_types.go +++ b/pkg/trait/trait_condition_types.go @@ -54,23 +54,10 @@ func NewIntegrationConditionUserDisabled() *TraitCondition { return NewIntegrationCondition(v1.IntegrationConditionTraitInfo, corev1.ConditionTrue, traitConfigurationMessage, userDisabledMessage) } -func newIntegrationConditionPlatformDisabled() *TraitCondition { - return NewIntegrationCondition(v1.IntegrationConditionTraitInfo, corev1.ConditionTrue, traitConfigurationMessage, platformDisabledMessage) -} - func newIntegrationConditionPlatformDisabledWithReason(reason string) *TraitCondition { return NewIntegrationCondition(v1.IntegrationConditionTraitInfo, corev1.ConditionTrue, traitConfigurationMessage, fmt.Sprintf("%s: %s", platformDisabledMessage, reason)) } -func newIntegrationKitCondition(ikct v1.IntegrationKitConditionType, cs corev1.ConditionStatus, message, reason string) *TraitCondition { - return &TraitCondition{ - integrationKitConditionType: ikct, - conditionStatus: cs, - message: message, - reason: reason, - } -} - func (tc *TraitCondition) integrationCondition() (v1.IntegrationConditionType, corev1.ConditionStatus, string, string) { return tc.integrationConditionType, tc.conditionStatus, tc.message, tc.reason }