You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pc...@apache.org on 2024/08/28 08:57:59 UTC
(camel-k) 02/04: feat(trait): operate via default catalog
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 0dc8ee17994d5238ea96890dcf6b190a26de6d94
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Wed Aug 21 11:35:54 2024 +0200
feat(trait): operate via default catalog
With this refactoring, we allow any trait to be executed with at least a default CamelCatalog.
This is useful when we run sourceless where, from now on, we can pick the catalog used to operate, regardless if it's a managed Integration or not.
---
docs/modules/ROOT/partials/apis/camel-k-crds.adoc | 47 +++++++++++++++
helm/camel-k/crds/camel-k-crds.yaml | 22 +++++++
pkg/apis/camel/v1/common_types.go | 6 ++
pkg/apis/camel/v1/integration_types.go | 3 +
pkg/apis/camel/v1/integrationkit_types.go | 2 +
pkg/apis/camel/v1/zz_generated.deepcopy.go | 17 ++++++
.../camel/applyconfiguration/camel/v1/catalog.go | 53 +++++++++++++++++
.../camel/v1/integrationkitstatus.go | 9 +++
.../camel/v1/integrationstatus.go | 9 +++
pkg/client/camel/applyconfiguration/utils.go | 2 +
pkg/controller/integrationkit/initialize.go | 2 +-
.../bases/camel.apache.org_integrationkits.yaml | 9 +++
.../crd/bases/camel.apache.org_integrations.yaml | 13 +++++
pkg/trait/camel.go | 67 ++++++++++++++--------
pkg/trait/camel_test.go | 39 +++++++++++--
pkg/trait/logging_test.go | 8 +--
pkg/trait/trait_types.go | 5 +-
pkg/trait/trait_types_test.go | 9 ++-
18 files changed, 281 insertions(+), 41 deletions(-)
diff --git a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
index 2cd4b1420..3b4e6e41b 100644
--- a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
+++ b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
@@ -1476,6 +1476,38 @@ map[string]string
Set of generic metadata
+|===
+
+[#_camel_apache_org_v1_Catalog]
+=== Catalog
+
+*Appears on:*
+
+* <<#_camel_apache_org_v1_IntegrationKitStatus, IntegrationKitStatus>>
+* <<#_camel_apache_org_v1_IntegrationStatus, IntegrationStatus>>
+
+Catalog represents the Camel Catalog runtime specification.
+
+[cols="2,2a",options="header"]
+|===
+|Field
+|Description
+
+|`version` +
+string
+|
+
+
+
+
+|`provider` +
+*xref:#_camel_apache_org_v1_RuntimeProvider[RuntimeProvider]*
+|
+
+
+
+
+
|===
[#_camel_apache_org_v1_Configurable]
@@ -2648,6 +2680,13 @@ the runtime version for which this kit was configured
the runtime provider for which this kit was configured
+|`catalog` +
+*xref:#_camel_apache_org_v1_Catalog[Catalog]*
+|
+
+
+the catalog used to build/operate the IntegrationKit.
+
|`platform` +
string
|
@@ -3522,6 +3561,13 @@ the runtime version targeted for this Integration
the runtime provider targeted for this Integration
+|`catalog` +
+*xref:#_camel_apache_org_v1_Catalog[Catalog]*
+|
+
+
+the catalog used to build/operate the Integration.
+
|`configuration` +
*xref:#_camel_apache_org_v1_ConfigurationSpec[[\]ConfigurationSpec]*
|
@@ -5259,6 +5305,7 @@ ResourceCondition is a common type for all conditions.
*Appears on:*
+* <<#_camel_apache_org_v1_Catalog, Catalog>>
* <<#_camel_apache_org_v1_IntegrationKitStatus, IntegrationKitStatus>>
* <<#_camel_apache_org_v1_IntegrationPlatformBuildSpec, IntegrationPlatformBuildSpec>>
* <<#_camel_apache_org_v1_IntegrationProfileBuildSpec, IntegrationProfileBuildSpec>>
diff --git a/helm/camel-k/crds/camel-k-crds.yaml b/helm/camel-k/crds/camel-k-crds.yaml
index 3e409754f..51d4da8fc 100644
--- a/helm/camel-k/crds/camel-k-crds.yaml
+++ b/helm/camel-k/crds/camel-k-crds.yaml
@@ -3045,6 +3045,15 @@ spec:
baseImage:
description: base image used by the kit (could be another IntegrationKit)
type: string
+ catalog:
+ description: the catalog used to build/operate the IntegrationKit.
+ properties:
+ provider:
+ description: RuntimeProvider is the provider chosen for the runtime.
+ type: string
+ version:
+ type: string
+ type: object
conditions:
description: a list of conditions which happened for the events related
the kit
@@ -11195,6 +11204,10 @@ spec:
jsonPath: .status.runtimeVersion
name: Runtime Version
type: string
+ - description: The catalog version
+ jsonPath: .status.catalog.version
+ name: Catalog Version
+ type: string
- description: The integration kit
jsonPath: .status.integrationKit.name
name: Kit
@@ -19345,6 +19358,15 @@ spec:
items:
type: string
type: array
+ catalog:
+ description: the catalog used to build/operate the Integration.
+ properties:
+ provider:
+ description: RuntimeProvider is the provider chosen for the runtime.
+ type: string
+ version:
+ type: string
+ type: object
conditions:
description: a list of events happened for the Integration
items:
diff --git a/pkg/apis/camel/v1/common_types.go b/pkg/apis/camel/v1/common_types.go
index ed4bb2af0..80466ab4c 100644
--- a/pkg/apis/camel/v1/common_types.go
+++ b/pkg/apis/camel/v1/common_types.go
@@ -123,6 +123,12 @@ type ConfigurationSpec struct {
Value string `json:"value"`
}
+// Catalog represents the Camel Catalog runtime specification.
+type Catalog struct {
+ Version string `json:"version,omitempty" yaml:"version,omitempty"`
+ Provider RuntimeProvider `json:"provider,omitempty" yaml:"provider,omitempty"`
+}
+
// Artifact represents a materialized artifact (a jar dependency or in general a file used by the build).
type Artifact struct {
// the identification (GAV for maven dependencies or file name for other file types)
diff --git a/pkg/apis/camel/v1/integration_types.go b/pkg/apis/camel/v1/integration_types.go
index 4ba863052..a68533cda 100644
--- a/pkg/apis/camel/v1/integration_types.go
+++ b/pkg/apis/camel/v1/integration_types.go
@@ -37,6 +37,7 @@ import (
// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].status`,description="The integration readiness"
// +kubebuilder:printcolumn:name="Runtime Provider",type=string,JSONPath=`.status.runtimeProvider`,description="The runtime version"
// +kubebuilder:printcolumn:name="Runtime Version",type=string,JSONPath=`.status.runtimeVersion`,description="The runtime provider"
+// +kubebuilder:printcolumn:name="Catalog Version",type=string,JSONPath=`.status.catalog.version`,description="The catalog version"
// +kubebuilder:printcolumn:name="Kit",type=string,JSONPath=`.status.integrationKit.name`,description="The integration kit"
// +kubebuilder:printcolumn:name="Replicas",type=integer,JSONPath=`.status.replicas`,description="The number of pods"
@@ -106,6 +107,8 @@ type IntegrationStatus struct {
RuntimeVersion string `json:"runtimeVersion,omitempty"`
// the runtime provider targeted for this Integration
RuntimeProvider RuntimeProvider `json:"runtimeProvider,omitempty"`
+ // the catalog used to build/operate the Integration.
+ Catalog *Catalog `json:"catalog,omitempty"`
// Deprecated:
// a list of configuration specification
Configuration []ConfigurationSpec `json:"configuration,omitempty"`
diff --git a/pkg/apis/camel/v1/integrationkit_types.go b/pkg/apis/camel/v1/integrationkit_types.go
index d6b695793..3d2d70331 100644
--- a/pkg/apis/camel/v1/integrationkit_types.go
+++ b/pkg/apis/camel/v1/integrationkit_types.go
@@ -117,6 +117,8 @@ type IntegrationKitStatus struct {
RuntimeVersion string `json:"runtimeVersion,omitempty"`
// the runtime provider for which this kit was configured
RuntimeProvider RuntimeProvider `json:"runtimeProvider,omitempty"`
+ // the catalog used to build/operate the IntegrationKit.
+ Catalog *Catalog `json:"catalog,omitempty"`
// the platform for which this kit was configured
Platform string `json:"platform,omitempty"`
// the Camel K operator version for which this kit was configured
diff --git a/pkg/apis/camel/v1/zz_generated.deepcopy.go b/pkg/apis/camel/v1/zz_generated.deepcopy.go
index d5df39c00..3f822d2fb 100644
--- a/pkg/apis/camel/v1/zz_generated.deepcopy.go
+++ b/pkg/apis/camel/v1/zz_generated.deepcopy.go
@@ -659,6 +659,21 @@ func (in *Capability) DeepCopy() *Capability {
return out
}
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *Catalog) DeepCopyInto(out *Catalog) {
+ *out = *in
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Catalog.
+func (in *Catalog) DeepCopy() *Catalog {
+ if in == nil {
+ return nil
+ }
+ out := new(Catalog)
+ in.DeepCopyInto(out)
+ return out
+}
+
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ConfigurationSpec) DeepCopyInto(out *ConfigurationSpec) {
*out = *in
@@ -1315,6 +1330,7 @@ func (in *IntegrationKitStatus) DeepCopyInto(out *IntegrationKitStatus) {
*out = new(Failure)
(*in).DeepCopyInto(*out)
}
+ out.Catalog = in.Catalog
if in.Conditions != nil {
in, out := &in.Conditions, &out.Conditions
*out = make([]IntegrationKitCondition, len(*in))
@@ -1831,6 +1847,7 @@ func (in *IntegrationStatus) DeepCopyInto(out *IntegrationStatus) {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
+ out.Catalog = in.Catalog
if in.Configuration != nil {
in, out := &in.Configuration, &out.Configuration
*out = make([]ConfigurationSpec, len(*in))
diff --git a/pkg/client/camel/applyconfiguration/camel/v1/catalog.go b/pkg/client/camel/applyconfiguration/camel/v1/catalog.go
new file mode 100644
index 000000000..eda43018f
--- /dev/null
+++ b/pkg/client/camel/applyconfiguration/camel/v1/catalog.go
@@ -0,0 +1,53 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+// Code generated by applyconfiguration-gen. DO NOT EDIT.
+
+package v1
+
+import (
+ v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
+)
+
+// CatalogApplyConfiguration represents an declarative configuration of the Catalog type for use
+// with apply.
+type CatalogApplyConfiguration struct {
+ Version *string `json:"version,omitempty"`
+ Provider *v1.RuntimeProvider `json:"provider,omitempty"`
+}
+
+// CatalogApplyConfiguration constructs an declarative configuration of the Catalog type for use with
+// apply.
+func Catalog() *CatalogApplyConfiguration {
+ return &CatalogApplyConfiguration{}
+}
+
+// WithVersion sets the Version field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the Version field is set to the value of the last call.
+func (b *CatalogApplyConfiguration) WithVersion(value string) *CatalogApplyConfiguration {
+ b.Version = &value
+ return b
+}
+
+// WithProvider sets the Provider field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the Provider field is set to the value of the last call.
+func (b *CatalogApplyConfiguration) WithProvider(value v1.RuntimeProvider) *CatalogApplyConfiguration {
+ b.Provider = &value
+ return b
+}
diff --git a/pkg/client/camel/applyconfiguration/camel/v1/integrationkitstatus.go b/pkg/client/camel/applyconfiguration/camel/v1/integrationkitstatus.go
index 12650227a..8bc13a36d 100644
--- a/pkg/client/camel/applyconfiguration/camel/v1/integrationkitstatus.go
+++ b/pkg/client/camel/applyconfiguration/camel/v1/integrationkitstatus.go
@@ -36,6 +36,7 @@ type IntegrationKitStatusApplyConfiguration struct {
Failure *FailureApplyConfiguration `json:"failure,omitempty"`
RuntimeVersion *string `json:"runtimeVersion,omitempty"`
RuntimeProvider *v1.RuntimeProvider `json:"runtimeProvider,omitempty"`
+ Catalog *CatalogApplyConfiguration `json:"catalog,omitempty"`
Platform *string `json:"platform,omitempty"`
Version *string `json:"version,omitempty"`
Conditions []IntegrationKitConditionApplyConfiguration `json:"conditions,omitempty"`
@@ -132,6 +133,14 @@ func (b *IntegrationKitStatusApplyConfiguration) WithRuntimeProvider(value v1.Ru
return b
}
+// WithCatalog sets the Catalog field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the Catalog field is set to the value of the last call.
+func (b *IntegrationKitStatusApplyConfiguration) WithCatalog(value *CatalogApplyConfiguration) *IntegrationKitStatusApplyConfiguration {
+ b.Catalog = value
+ return b
+}
+
// WithPlatform sets the Platform field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Platform field is set to the value of the last call.
diff --git a/pkg/client/camel/applyconfiguration/camel/v1/integrationstatus.go b/pkg/client/camel/applyconfiguration/camel/v1/integrationstatus.go
index d17acaa2b..851decd19 100644
--- a/pkg/client/camel/applyconfiguration/camel/v1/integrationstatus.go
+++ b/pkg/client/camel/applyconfiguration/camel/v1/integrationstatus.go
@@ -39,6 +39,7 @@ type IntegrationStatusApplyConfiguration struct {
GeneratedSources []SourceSpecApplyConfiguration `json:"generatedSources,omitempty"`
RuntimeVersion *string `json:"runtimeVersion,omitempty"`
RuntimeProvider *v1.RuntimeProvider `json:"runtimeProvider,omitempty"`
+ Catalog *CatalogApplyConfiguration `json:"catalog,omitempty"`
Configuration []ConfigurationSpecApplyConfiguration `json:"configuration,omitempty"`
Conditions []IntegrationConditionApplyConfiguration `json:"conditions,omitempty"`
Version *string `json:"version,omitempty"`
@@ -149,6 +150,14 @@ func (b *IntegrationStatusApplyConfiguration) WithRuntimeProvider(value v1.Runti
return b
}
+// WithCatalog sets the Catalog field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the Catalog field is set to the value of the last call.
+func (b *IntegrationStatusApplyConfiguration) WithCatalog(value *CatalogApplyConfiguration) *IntegrationStatusApplyConfiguration {
+ b.Catalog = value
+ return b
+}
+
// WithConfiguration adds the given value to the Configuration field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, values provided by each call will be appended to the Configuration field.
diff --git a/pkg/client/camel/applyconfiguration/utils.go b/pkg/client/camel/applyconfiguration/utils.go
index 6632cd823..626858470 100644
--- a/pkg/client/camel/applyconfiguration/utils.go
+++ b/pkg/client/camel/applyconfiguration/utils.go
@@ -76,6 +76,8 @@ func ForKind(kind schema.GroupVersionKind) interface{} {
return &camelv1.CamelSchemeScopeApplyConfiguration{}
case v1.SchemeGroupVersion.WithKind("Capability"):
return &camelv1.CapabilityApplyConfiguration{}
+ case v1.SchemeGroupVersion.WithKind("Catalog"):
+ return &camelv1.CatalogApplyConfiguration{}
case v1.SchemeGroupVersion.WithKind("ConfigurationSpec"):
return &camelv1.ConfigurationSpecApplyConfiguration{}
case v1.SchemeGroupVersion.WithKind("DataSpec"):
diff --git a/pkg/controller/integrationkit/initialize.go b/pkg/controller/integrationkit/initialize.go
index 75b23ac95..aa27e0c41 100644
--- a/pkg/controller/integrationkit/initialize.go
+++ b/pkg/controller/integrationkit/initialize.go
@@ -83,7 +83,7 @@ func (action *initializeAction) image(ctx context.Context, env *trait.Environmen
catalog, err := kubernetes.GetCamelCatalog(
ctx,
action.client,
- fmt.Sprintf("camel-catalog-%s", strings.ToLower(env.RuntimeVersion)),
+ fmt.Sprintf("camel-catalog-%s", strings.ToLower(env.CamelCatalog.GetRuntimeVersion())),
kit.Namespace,
)
diff --git a/pkg/resources/config/crd/bases/camel.apache.org_integrationkits.yaml b/pkg/resources/config/crd/bases/camel.apache.org_integrationkits.yaml
index 77c7bfd0b..1607b05cd 100644
--- a/pkg/resources/config/crd/bases/camel.apache.org_integrationkits.yaml
+++ b/pkg/resources/config/crd/bases/camel.apache.org_integrationkits.yaml
@@ -466,6 +466,15 @@ spec:
baseImage:
description: base image used by the kit (could be another IntegrationKit)
type: string
+ catalog:
+ description: the catalog used to build/operate the IntegrationKit.
+ properties:
+ provider:
+ description: RuntimeProvider is the provider chosen for the runtime.
+ type: string
+ version:
+ type: string
+ type: object
conditions:
description: a list of conditions which happened for the events related
the kit
diff --git a/pkg/resources/config/crd/bases/camel.apache.org_integrations.yaml b/pkg/resources/config/crd/bases/camel.apache.org_integrations.yaml
index f81c870b7..508e92917 100644
--- a/pkg/resources/config/crd/bases/camel.apache.org_integrations.yaml
+++ b/pkg/resources/config/crd/bases/camel.apache.org_integrations.yaml
@@ -55,6 +55,10 @@ spec:
jsonPath: .status.runtimeVersion
name: Runtime Version
type: string
+ - description: The catalog version
+ jsonPath: .status.catalog.version
+ name: Catalog Version
+ type: string
- description: The integration kit
jsonPath: .status.integrationKit.name
name: Kit
@@ -8205,6 +8209,15 @@ spec:
items:
type: string
type: array
+ catalog:
+ description: the catalog used to build/operate the Integration.
+ properties:
+ provider:
+ description: RuntimeProvider is the provider chosen for the runtime.
+ type: string
+ version:
+ type: string
+ type: object
conditions:
description: a list of events happened for the Integration
items:
diff --git a/pkg/trait/camel.go b/pkg/trait/camel.go
index 8a6c5a04e..093d81767 100644
--- a/pkg/trait/camel.go
+++ b/pkg/trait/camel.go
@@ -77,38 +77,57 @@ func (t *camelTrait) Configure(e *Environment) (bool, *TraitCondition, error) {
}
}
- return true, nil, nil
+ var cond *TraitCondition
+ if e.IntegrationKit != nil && e.IntegrationKit.IsSynthetic() {
+ // We set a condition to warn the user the catalog used to run the Integration
+ // may differ from the runtime version which we don't control
+ cond = NewIntegrationCondition(
+ "Camel",
+ v1.IntegrationConditionTraitInfo,
+ corev1.ConditionTrue,
+ traitConfigurationReason,
+ fmt.Sprintf(
+ "Operated with CamelCatalog version %s which may be different from the runtime used in the container",
+ t.RuntimeVersion,
+ ),
+ )
+ }
+
+ return true, cond, nil
}
-//nolint:nestif
func (t *camelTrait) Apply(e *Environment) error {
- if e.IntegrationKit != nil && e.IntegrationKit.IsSynthetic() {
- // Synthetic Integration Kit
-
- // This is required as during init phase, the trait set by default these values
- // which are widely used in the platform for different purposese.
- if e.Integration != nil {
- e.Integration.Status.RuntimeVersion = ""
- e.Integration.Status.RuntimeProvider = ""
+ if e.CamelCatalog == nil {
+ if err := t.loadOrCreateCatalog(e, t.RuntimeVersion); err != nil {
+ return err
}
- } else {
- // Managed Integration
- if e.CamelCatalog == nil {
- if err := t.loadOrCreateCatalog(e, t.RuntimeVersion); err != nil {
- return err
- }
- }
- e.RuntimeVersion = e.CamelCatalog.Runtime.Version
- if e.Integration != nil {
- e.Integration.Status.RuntimeVersion = e.CamelCatalog.Runtime.Version
- e.Integration.Status.RuntimeProvider = e.CamelCatalog.Runtime.Provider
+ }
+
+ if e.Integration != nil {
+ e.Integration.Status.RuntimeVersion = e.CamelCatalog.Runtime.Version
+ e.Integration.Status.RuntimeProvider = e.CamelCatalog.Runtime.Provider
+ e.Integration.Status.Catalog = &v1.Catalog{
+ Version: e.CamelCatalog.Runtime.Version,
+ Provider: e.CamelCatalog.Runtime.Provider,
}
- if e.IntegrationKit != nil {
- e.IntegrationKit.Status.RuntimeVersion = e.CamelCatalog.Runtime.Version
- e.IntegrationKit.Status.RuntimeProvider = e.CamelCatalog.Runtime.Provider
+ }
+ if e.IntegrationKit != nil {
+ e.IntegrationKit.Status.RuntimeVersion = e.CamelCatalog.Runtime.Version
+ e.IntegrationKit.Status.RuntimeProvider = e.CamelCatalog.Runtime.Provider
+ e.IntegrationKit.Status.Catalog = &v1.Catalog{
+ Version: e.CamelCatalog.Runtime.Version,
+ Provider: e.CamelCatalog.Runtime.Provider,
}
}
+ if e.IntegrationKit != nil && e.IntegrationKit.IsSynthetic() {
+ // Synthetic Integration Kit
+ e.Integration.Status.RuntimeVersion = ""
+ e.Integration.Status.RuntimeProvider = ""
+ e.IntegrationKit.Status.RuntimeVersion = ""
+ e.IntegrationKit.Status.RuntimeProvider = ""
+ }
+
if e.IntegrationKitInPhase(v1.IntegrationKitPhaseReady) && e.IntegrationInRunningPhases() {
// Get all resources
maps := t.computeConfigMaps(e)
diff --git a/pkg/trait/camel_test.go b/pkg/trait/camel_test.go
index d3fe63e35..531e725e3 100644
--- a/pkg/trait/camel_test.go
+++ b/pkg/trait/camel_test.go
@@ -19,6 +19,7 @@ package trait
import (
"context"
+ "fmt"
"testing"
corev1 "k8s.io/api/core/v1"
@@ -55,9 +56,12 @@ func TestApplyCamelTraitSucceeds(t *testing.T) {
err = trait.Apply(environment)
require.NoError(t, err)
- assert.Equal(t, "0.0.1", environment.RuntimeVersion)
+ assert.Equal(t, "0.0.1", environment.CamelCatalog.GetRuntimeVersion())
assert.Equal(t, "0.0.1", environment.Integration.Status.RuntimeVersion)
assert.Equal(t, "0.0.1", environment.IntegrationKit.Status.RuntimeVersion)
+ expectedCatalog := &v1.Catalog{Version: "0.0.1", Provider: v1.RuntimeProviderQuarkus}
+ assert.Equal(t, expectedCatalog, environment.Integration.Status.Catalog)
+ assert.Equal(t, expectedCatalog, environment.IntegrationKit.Status.Catalog)
// Test regex as well
assert.True(t, exactVersionRegexp.MatchString("1.2.3"))
@@ -71,7 +75,17 @@ func TestApplyCamelTraitExternalKit(t *testing.T) {
configured, condition, err := trait.Configure(environment)
require.NoError(t, err)
- assert.Nil(t, condition)
+ expectedCondition := NewIntegrationCondition(
+ "Camel",
+ v1.IntegrationConditionTraitInfo,
+ corev1.ConditionTrue,
+ traitConfigurationReason,
+ fmt.Sprintf(
+ "Operated with CamelCatalog version %s which may be different from the runtime used in the container",
+ "0.0.1",
+ ),
+ )
+ assert.Equal(t, expectedCondition, condition)
assert.True(t, configured)
err = trait.Apply(environment)
require.NoError(t, err)
@@ -79,6 +93,9 @@ func TestApplyCamelTraitExternalKit(t *testing.T) {
assert.Equal(t, v1.RuntimeProvider(""), environment.Integration.Status.RuntimeProvider)
assert.Equal(t, "", environment.IntegrationKit.Status.RuntimeVersion)
assert.Equal(t, v1.RuntimeProvider(""), environment.Integration.Status.RuntimeProvider)
+ expectedCatalog := &v1.Catalog{Version: "0.0.1", Provider: v1.RuntimeProviderQuarkus}
+ assert.Equal(t, expectedCatalog, environment.Integration.Status.Catalog)
+ assert.Equal(t, expectedCatalog, environment.IntegrationKit.Status.Catalog)
}
func TestApplyCamelTraitWithoutEnvironmentCatalogAndUnmatchableVersionFails(t *testing.T) {
@@ -214,7 +231,17 @@ func TestApplyCamelTraitSyntheticKitWithProperties(t *testing.T) {
configured, condition, err := trait.Configure(environment)
require.NoError(t, err)
- assert.Nil(t, condition)
+ expectedCondition := NewIntegrationCondition(
+ "Camel",
+ v1.IntegrationConditionTraitInfo,
+ corev1.ConditionTrue,
+ traitConfigurationReason,
+ fmt.Sprintf(
+ "Operated with CamelCatalog version %s which may be different from the runtime used in the container",
+ "0.0.1",
+ ),
+ )
+ assert.Equal(t, expectedCondition, condition)
assert.True(t, configured)
err = trait.Apply(environment)
@@ -274,8 +301,8 @@ func TestCamelMatches(t *testing.T) {
func TestCamelCatalogSemver(t *testing.T) {
trait, environment := createNominalCamelTest(true)
environment.Integration.Status.Phase = v1.IntegrationPhaseBuildingKit
+ environment.CamelCatalog.Runtime.Version = "2.16.1"
trait.RuntimeVersion = "2.x"
- environment.CamelCatalog.CamelCatalogSpec.Runtime.Version = "2.16.0"
configured, condition, err := trait.Configure(environment)
require.NoError(t, err)
@@ -284,8 +311,8 @@ func TestCamelCatalogSemver(t *testing.T) {
err = trait.Apply(environment)
require.NoError(t, err)
- // 2.x will translate with 2.16.0 as it is already existing
- assert.Equal(t, environment.CamelCatalog.CamelCatalogSpec.Runtime.Version, environment.RuntimeVersion)
+ // 2.x will translate with 2.16.1 as it is already existing
+ assert.Equal(t, "2.16.1", environment.CamelCatalog.GetRuntimeVersion())
}
func TestCamelTraitSyntheticIntegration(t *testing.T) {
diff --git a/pkg/trait/logging_test.go b/pkg/trait/logging_test.go
index 1ba6c482e..7d77ff7e0 100644
--- a/pkg/trait/logging_test.go
+++ b/pkg/trait/logging_test.go
@@ -156,10 +156,10 @@ func TestJsonLoggingTrait(t *testing.T) {
func TestDefaultQuarkusLogging(t *testing.T) {
env := createDefaultLoggingTestEnv(t)
- // Simulate a synthetic Integration Kit for which the catalog is not available
- env.CamelCatalog = nil
- env.IntegrationKit.Labels = map[string]string{
- v1.IntegrationKitTypeLabel: v1.IntegrationKitTypeSynthetic,
+ // Simulate an older catalog configuration which is missing the logging
+ // capability
+ env.CamelCatalog.Runtime.Capabilities["logging"] = v1.Capability{
+ RuntimeProperties: nil,
}
env.EnvVars = []corev1.EnvVar{}
conditions, err := NewLoggingTestCatalog().apply(env)
diff --git a/pkg/trait/trait_types.go b/pkg/trait/trait_types.go
index 7e95a8868..299b7f1c2 100644
--- a/pkg/trait/trait_types.go
+++ b/pkg/trait/trait_types.go
@@ -206,9 +206,8 @@ type ControllerStrategySelector interface {
//
//nolint:containedctx
type Environment struct {
- CamelCatalog *camel.RuntimeCatalog
- RuntimeVersion string
- Catalog *Catalog
+ CamelCatalog *camel.RuntimeCatalog
+ Catalog *Catalog
// The Go standard context for the traits execution
Ctx context.Context
// The client to the API server
diff --git a/pkg/trait/trait_types_test.go b/pkg/trait/trait_types_test.go
index 497cd034a..50146584f 100644
--- a/pkg/trait/trait_types_test.go
+++ b/pkg/trait/trait_types_test.go
@@ -282,9 +282,12 @@ func createSyntethicKitTestEnvironment(t *testing.T, profile v1.TraitProfile) *E
t.Helper()
client, _ := test.NewFakeClient()
traitCatalog := NewCatalog(nil)
+ catalog, err := camel.DefaultCatalog()
+ require.NoError(t, err)
environment := &Environment{
- Catalog: traitCatalog,
- Client: client,
+ CamelCatalog: catalog,
+ Catalog: traitCatalog,
+ Client: client,
Integration: &v1.Integration{
ObjectMeta: metav1.ObjectMeta{
Name: "test",
@@ -325,7 +328,7 @@ func createSyntethicKitTestEnvironment(t *testing.T, profile v1.TraitProfile) *E
environment.Platform.ResyncStatusFullConfig()
- _, err := traitCatalog.apply(environment)
+ _, err = traitCatalog.apply(environment)
require.NoError(t, err)
return environment