This is an automated email from the ASF dual-hosted git repository.

astefanutti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 4c501d86ae491a326dd8d1bf9b15d284718d6afb
Author: Pasquale Congiusti <pasquale.congiu...@gmail.com>
AuthorDate: Fri Sep 24 12:40:21 2021 +0200

    feat(trait): moved runtime to camel trait
    
    * Camel trait is the most suitable to control how properties are managed
    * Some refactoring in trait_test.go as the properties configmap is now 
managed by camel trait
    
    Closes #2320
---
 docs/modules/ROOT/nav.adoc                   |   1 -
 docs/modules/traits/pages/camel.adoc         |   4 +
 docs/modules/traits/pages/configuration.adoc |  36 ------
 docs/modules/traits/pages/istio.adoc         |   2 +-
 docs/modules/traits/pages/runtime.adoc       |  36 ------
 e2e/common/cli/duplicate_parameters_test.go  |   2 +-
 pkg/cmd/run.go                               |   2 +-
 pkg/trait/camel.go                           | 174 +++++++++++++++++++++++++++
 pkg/trait/camel_test.go                      |  34 +++++-
 pkg/trait/runtime.go                         | 108 -----------------
 pkg/trait/runtime_test.go                    |  98 ---------------
 pkg/trait/trait_register.go                  |   1 -
 pkg/trait/trait_test.go                      |  22 +---
 pkg/trait/trait_types.go                     | 121 -------------------
 resources/traits.yaml                        |  23 +---
 15 files changed, 223 insertions(+), 441 deletions(-)

diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc
index 3ff11a4..375ad93 100644
--- a/docs/modules/ROOT/nav.adoc
+++ b/docs/modules/ROOT/nav.adoc
@@ -71,7 +71,6 @@
 ** xref:traits:pull-secret.adoc[Pull Secret]
 ** xref:traits:quarkus.adoc[Quarkus]
 ** xref:traits:route.adoc[Route]
-** xref:traits:runtime.adoc[Runtime]
 ** xref:traits:service-binding.adoc[Service Binding]
 ** xref:traits:service.adoc[Service]
 ** xref:traits:toleration.adoc[Toleration]
diff --git a/docs/modules/traits/pages/camel.adoc 
b/docs/modules/traits/pages/camel.adoc
index 59f3db5..a153a68 100755
--- a/docs/modules/traits/pages/camel.adoc
+++ b/docs/modules/traits/pages/camel.adoc
@@ -31,6 +31,10 @@ The following configuration options are available:
 | string
 | The camel-k-runtime version to use for the integration. It overrides the 
default version set in the Integration Platform.
 
+| camel.properties
+| []string
+| A list of properties to be provided to the Integration runtime
+
 |===
 
 // End of autogenerated code - DO NOT EDIT! (configuration)
diff --git a/docs/modules/traits/pages/configuration.adoc 
b/docs/modules/traits/pages/configuration.adoc
deleted file mode 100755
index 99292ce..0000000
--- a/docs/modules/traits/pages/configuration.adoc
+++ /dev/null
@@ -1,36 +0,0 @@
-= Configuration Trait
-
-// Start of autogenerated code - DO NOT EDIT! (description)
-The configuration trait is used to customize the Integration configuration 
such as properties and resources.
-
-
-This trait is available in the following profiles: **Kubernetes, Knative, 
OpenShift**.
-
-WARNING: The configuration trait is a *platform trait*: disabling it may 
compromise the platform functionality.
-
-// End of autogenerated code - DO NOT EDIT! (description)
-// Start of autogenerated code - DO NOT EDIT! (configuration)
-== Configuration
-
-Trait properties can be specified when running any integration with the CLI:
-[source,console]
-----
-$ kamel run --trait configuration.[key]=[value] --trait 
configuration.[key2]=[value2] integration.groovy
-----
-The following configuration options are available:
-
-[cols="2m,1m,5a"]
-|===
-|Property | Type | Description
-
-| configuration.enabled
-| bool
-| Can be used to enable or disable a trait. All traits share this common 
property.
-
-| configuration.properties
-| []string
-| A list of properties to be provided to the Integration runtime
-
-|===
-
-// End of autogenerated code - DO NOT EDIT! (configuration)
diff --git a/docs/modules/traits/pages/istio.adoc 
b/docs/modules/traits/pages/istio.adoc
index b8fdef0..7fda913 100755
--- a/docs/modules/traits/pages/istio.adoc
+++ b/docs/modules/traits/pages/istio.adoc
@@ -1,7 +1,7 @@
 = Istio Trait
 
 // Start of autogenerated code - DO NOT EDIT! (description)
-The Istio trait allows to configure properties related to the Istio service 
mesh,
+The Istio trait allows configuring properties related to the Istio service 
mesh,
 such as sidecar injection and outbound IP ranges.
 
 
diff --git a/docs/modules/traits/pages/runtime.adoc 
b/docs/modules/traits/pages/runtime.adoc
deleted file mode 100755
index 7e9bbfb..0000000
--- a/docs/modules/traits/pages/runtime.adoc
+++ /dev/null
@@ -1,36 +0,0 @@
-= Runtime Trait
-
-// Start of autogenerated code - DO NOT EDIT! (description)
-The runtime trait is used to customize the Integration runtime configuration 
such as properties and resources.
-
-
-This trait is available in the following profiles: **Kubernetes, Knative, 
OpenShift**.
-
-WARNING: The runtime trait is a *platform trait*: disabling it may compromise 
the platform functionality.
-
-// End of autogenerated code - DO NOT EDIT! (description)
-// Start of autogenerated code - DO NOT EDIT! (configuration)
-== Configuration
-
-Trait properties can be specified when running any integration with the CLI:
-[source,console]
-----
-$ kamel run --trait runtime.[key]=[value] --trait runtime.[key2]=[value2] 
integration.groovy
-----
-The following configuration options are available:
-
-[cols="2m,1m,5a"]
-|===
-|Property | Type | Description
-
-| runtime.enabled
-| bool
-| Can be used to enable or disable a trait. All traits share this common 
property.
-
-| runtime.properties
-| []string
-| A list of properties to be provided to the Integration runtime
-
-|===
-
-// End of autogenerated code - DO NOT EDIT! (configuration)
diff --git a/e2e/common/cli/duplicate_parameters_test.go 
b/e2e/common/cli/duplicate_parameters_test.go
index 7cb2ac2..dbda549 100644
--- a/e2e/common/cli/duplicate_parameters_test.go
+++ b/e2e/common/cli/duplicate_parameters_test.go
@@ -46,6 +46,6 @@ func TestDuplicateParameters(t *testing.T) {
        // the command is executed inside GetOutputString function
        commOutput := GetOutputString(comm)
 
-       outParams := 
`"traits":{"affinity":{"configuration":{"enabled":true}},"configuration":{"configuration":{"properties":["prop1
 = true","prop2 = true","foo = 
bar"]}},"pull-secret":{"configuration":{"enabled":true}},"tracing":{"configuration":{"enabled":true}}}`
+       outParams := 
`"traits":{"affinity":{"configuration":{"enabled":true}},"camel":{"configuration":{"properties":["prop1
 = true","prop2 = true","foo = 
bar"]}},"pull-secret":{"configuration":{"enabled":true}},"tracing":{"configuration":{"enabled":true}}}`
        Expect(commOutput).To(ContainSubstring(outParams))
 }
diff --git a/pkg/cmd/run.go b/pkg/cmd/run.go
index f2fcd07..8b48dd9 100644
--- a/pkg/cmd/run.go
+++ b/pkg/cmd/run.go
@@ -582,7 +582,7 @@ func (o *runCmdOptions) createOrUpdateIntegration(cmd 
*cobra.Command, c client.C
        }
        for _, key := range props.Keys() {
                kv := fmt.Sprintf("%s=%s", key, props.GetString(key, ""))
-               if propsTraits, err := convertToTraitParameter(kv, 
"runtime.properties"); err != nil {
+               if propsTraits, err := convertToTraitParameter(kv, 
"camel.properties"); err != nil {
                        return nil, err
                } else {
                        o.Traits = append(o.Traits, propsTraits...)
diff --git a/pkg/trait/camel.go b/pkg/trait/camel.go
index 47a66f2..1836329 100644
--- a/pkg/trait/camel.go
+++ b/pkg/trait/camel.go
@@ -20,13 +20,18 @@ package trait
 import (
        "context"
        "fmt"
+       "strconv"
        "strings"
 
        "github.com/pkg/errors"
+       corev1 "k8s.io/api/core/v1"
+       metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+       ctrl "sigs.k8s.io/controller-runtime/pkg/client"
 
        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/maven"
+       "github.com/apache/camel-k/pkg/util/property"
 )
 
 // The Camel trait can be used to configure versions of Apache Camel K runtime 
and related libraries, it cannot be disabled.
@@ -36,6 +41,8 @@ type camelTrait struct {
        BaseTrait `property:",squash"`
        // The camel-k-runtime version to use for the integration. It overrides 
the default version set in the Integration Platform.
        RuntimeVersion string `property:"runtime-version" 
json:"runtimeVersion,omitempty"`
+       // A list of properties to be provided to the Integration runtime
+       Properties []string `property:"properties" json:"properties,omitempty"`
 }
 
 func newCamelTrait() Trait {
@@ -73,6 +80,17 @@ func (t *camelTrait) Apply(e *Environment) error {
                e.IntegrationKit.Status.RuntimeProvider = 
e.CamelCatalog.Runtime.Provider
        }
 
+       if e.InPhase(v1.IntegrationKitPhaseReady, v1.IntegrationPhaseDeploying) 
||
+               e.InPhase(v1.IntegrationKitPhaseReady, 
v1.IntegrationPhaseRunning) {
+               // Get all resources
+               maps := t.computeConfigMaps(e)
+               if t.Properties != nil {
+                       // Only user.properties
+                       maps = append(maps, t.computeUserProperties(e)...)
+               }
+               e.Resources.AddAll(maps)
+       }
+
        return nil
 }
 
@@ -152,3 +170,159 @@ func (t *camelTrait) determineRuntimeVersion(e 
*Environment) string {
 func (t *camelTrait) IsPlatformTrait() bool {
        return true
 }
+
+func (t *camelTrait) computeConfigMaps(e *Environment) []ctrl.Object {
+       sources := e.Integration.Sources()
+       maps := make([]ctrl.Object, 0, len(sources)+1)
+
+       // combine properties of integration with kit, integration
+       // properties have the priority
+       userProperties := ""
+
+       for _, prop := range e.collectConfigurationPairs("property") {
+               // properties in resource configuration are expected to be 
pre-encoded using properties format
+               userProperties += fmt.Sprintf("%s=%s\n", prop.Name, prop.Value)
+       }
+
+       if userProperties != "" {
+               maps = append(
+                       maps,
+                       &corev1.ConfigMap{
+                               TypeMeta: metav1.TypeMeta{
+                                       Kind:       "ConfigMap",
+                                       APIVersion: "v1",
+                               },
+                               ObjectMeta: metav1.ObjectMeta{
+                                       Name:      e.Integration.Name + 
"-user-properties",
+                                       Namespace: e.Integration.Namespace,
+                                       Labels: map[string]string{
+                                               v1.IntegrationLabel:            
    e.Integration.Name,
+                                               
"camel.apache.org/properties.type": "user",
+                                       },
+                               },
+                               Data: map[string]string{
+                                       "application.properties": 
userProperties,
+                               },
+                       },
+               )
+       }
+
+       for i, s := range sources {
+               if s.ContentRef != "" {
+                       continue
+               }
+
+               cm := corev1.ConfigMap{
+                       TypeMeta: metav1.TypeMeta{
+                               Kind:       "ConfigMap",
+                               APIVersion: "v1",
+                       },
+                       ObjectMeta: metav1.ObjectMeta{
+                               Name:      fmt.Sprintf("%s-source-%03d", 
e.Integration.Name, i),
+                               Namespace: e.Integration.Namespace,
+                               Labels: map[string]string{
+                                       v1.IntegrationLabel: e.Integration.Name,
+                               },
+                               Annotations: map[string]string{
+                                       "camel.apache.org/source.language":    
string(s.InferLanguage()),
+                                       "camel.apache.org/source.loader":      
s.Loader,
+                                       "camel.apache.org/source.name":        
s.Name,
+                                       "camel.apache.org/source.compression": 
strconv.FormatBool(s.Compression),
+                               },
+                       },
+                       Data: map[string]string{
+                               "content": s.Content,
+                       },
+               }
+
+               maps = append(maps, &cm)
+       }
+
+       for i, r := range e.Integration.Spec.Resources {
+               if r.Type == v1.ResourceTypeOpenAPI {
+                       continue
+               }
+               if r.ContentRef != "" {
+                       continue
+               }
+
+               cmKey := "content"
+               if r.ContentKey != "" {
+                       cmKey = r.ContentKey
+               }
+
+               cm := corev1.ConfigMap{
+                       TypeMeta: metav1.TypeMeta{
+                               Kind:       "ConfigMap",
+                               APIVersion: "v1",
+                       },
+                       ObjectMeta: metav1.ObjectMeta{
+                               Name:      fmt.Sprintf("%s-resource-%03d", 
e.Integration.Name, i),
+                               Namespace: e.Integration.Namespace,
+                               Labels: map[string]string{
+                                       "camel.apache.org/integration": 
e.Integration.Name,
+                               },
+                               Annotations: map[string]string{
+                                       "camel.apache.org/resource.name":       
 r.Name,
+                                       
"camel.apache.org/resource.compression": strconv.FormatBool(r.Compression),
+                               },
+                       },
+               }
+
+               if r.ContentType != "" {
+                       
cm.Annotations["camel.apache.org/resource.content-type"] = r.ContentType
+               }
+
+               if r.RawContent != nil {
+                       cm.BinaryData = map[string][]byte{
+                               cmKey: r.RawContent,
+                       }
+               } else {
+                       cm.Data = map[string]string{
+                               cmKey: r.Content,
+                       }
+               }
+
+               maps = append(maps, &cm)
+       }
+
+       return maps
+}
+
+func (t *camelTrait) computeUserProperties(e *Environment) []ctrl.Object {
+       maps := make([]ctrl.Object, 0)
+
+       // combine properties of integration with kit, integration
+       // properties have the priority
+       userProperties := ""
+
+       for _, prop := range t.Properties {
+               k, v := property.SplitPropertyFileEntry(prop)
+               userProperties += fmt.Sprintf("%s=%s\n", k, v)
+       }
+
+       if userProperties != "" {
+               maps = append(
+                       maps,
+                       &corev1.ConfigMap{
+                               TypeMeta: metav1.TypeMeta{
+                                       Kind:       "ConfigMap",
+                                       APIVersion: "v1",
+                               },
+                               ObjectMeta: metav1.ObjectMeta{
+                                       Name:      e.Integration.Name + 
"-user-properties",
+                                       Namespace: e.Integration.Namespace,
+                                       Labels: map[string]string{
+                                               v1.IntegrationLabel:            
    e.Integration.Name,
+                                               
"camel.apache.org/properties.type": "user",
+                                       },
+                               },
+                               Data: map[string]string{
+                                       "application.properties": 
userProperties,
+                               },
+                       },
+               )
+       }
+
+       return maps
+}
diff --git a/pkg/trait/camel_test.go b/pkg/trait/camel_test.go
index 2932660..e773b10 100644
--- a/pkg/trait/camel_test.go
+++ b/pkg/trait/camel_test.go
@@ -21,10 +21,12 @@ import (
        "context"
        "testing"
 
+       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"
@@ -90,12 +92,42 @@ func createNominalCamelTest() (*camelTrait, *Environment) {
                        ObjectMeta: metav1.ObjectMeta{
                                Namespace: "namespace",
                        },
+                       Spec: v1.IntegrationSpec{
+                               Traits: make(map[string]v1.TraitSpec),
+                       },
                        Status: v1.IntegrationStatus{
                                RuntimeVersion: "0.0.1",
+                               Phase:          v1.IntegrationPhaseDeploying,
+                       },
+               },
+               IntegrationKit: &v1.IntegrationKit{
+                       Status: v1.IntegrationKitStatus{
+                               Phase: v1.IntegrationKitPhaseReady,
                        },
                },
-               IntegrationKit: &v1.IntegrationKit{},
+               Platform: &v1.IntegrationPlatform{
+                       ObjectMeta: metav1.ObjectMeta{
+                               Namespace: "namespace",
+                       },
+               },
+               Resources:             kubernetes.NewCollection(),
+               ApplicationProperties: make(map[string]string),
        }
 
        return trait, environment
 }
+
+func TestApplyCamelTraitWithProperties(t *testing.T) {
+       camelTrait, environment := createNominalCamelTest()
+       camelTrait.Properties = []string{"a=b", "c=d"}
+       err := camelTrait.Apply(environment)
+       assert.Nil(t, err)
+
+       userPropertiesCm := environment.Resources.GetConfigMap(func(cm 
*corev1.ConfigMap) bool {
+               return cm.Labels["camel.apache.org/properties.type"] == "user"
+       })
+       assert.NotNil(t, userPropertiesCm)
+       assert.Equal(t, map[string]string{
+               "application.properties": "a=b\nc=d\n",
+       }, userPropertiesCm.Data)
+}
diff --git a/pkg/trait/runtime.go b/pkg/trait/runtime.go
deleted file mode 100644
index a4cee7f..0000000
--- a/pkg/trait/runtime.go
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
-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.
-*/
-
-package trait
-
-import (
-       "fmt"
-
-       v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
-       "github.com/apache/camel-k/pkg/util/property"
-       corev1 "k8s.io/api/core/v1"
-       metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-       ctrl "sigs.k8s.io/controller-runtime/pkg/client"
-)
-
-// The runtime trait is used to customize the Integration runtime 
configuration such as properties and resources.
-//
-// +camel-k:trait=runtime
-type runtimeTrait struct {
-       BaseTrait `property:",squash"`
-       // A list of properties to be provided to the Integration runtime
-       Properties []string `property:"properties" json:"properties,omitempty"`
-}
-
-func newRuntimeTrait() Trait {
-       return &runtimeTrait{
-               BaseTrait: NewBaseTrait("runtime", 700),
-       }
-}
-
-func (t *runtimeTrait) Configure(e *Environment) (bool, error) {
-       if t.Enabled != nil && !*t.Enabled {
-               return false, nil
-       }
-
-       return true, nil
-}
-
-func (t *runtimeTrait) Apply(e *Environment) error {
-       if e.InPhase(v1.IntegrationKitPhaseReady, v1.IntegrationPhaseDeploying) 
||
-               e.InPhase(v1.IntegrationKitPhaseReady, 
v1.IntegrationPhaseRunning) {
-               // Get all resources
-               maps := e.computeConfigMaps()
-               if t.Properties != nil {
-                       // Only user.properties
-                       maps = append(maps, t.computeUserProperties(e)...)
-               }
-               e.Resources.AddAll(maps)
-       }
-
-       return nil
-}
-
-func (t *runtimeTrait) IsPlatformTrait() bool {
-       return true
-}
-
-func (t *runtimeTrait) computeUserProperties(e *Environment) []ctrl.Object {
-       maps := make([]ctrl.Object, 0)
-
-       // combine properties of integration with kit, integration
-       // properties have the priority
-       userProperties := ""
-
-       for _, prop := range t.Properties {
-               k, v := property.SplitPropertyFileEntry(prop)
-               userProperties += fmt.Sprintf("%s=%s\n", k, v)
-       }
-
-       if userProperties != "" {
-               maps = append(
-                       maps,
-                       &corev1.ConfigMap{
-                               TypeMeta: metav1.TypeMeta{
-                                       Kind:       "ConfigMap",
-                                       APIVersion: "v1",
-                               },
-                               ObjectMeta: metav1.ObjectMeta{
-                                       Name:      e.Integration.Name + 
"-user-properties",
-                                       Namespace: e.Integration.Namespace,
-                                       Labels: map[string]string{
-                                               v1.IntegrationLabel:            
    e.Integration.Name,
-                                               
"camel.apache.org/properties.type": "user",
-                                       },
-                               },
-                               Data: map[string]string{
-                                       "application.properties": 
userProperties,
-                               },
-                       },
-               )
-       }
-
-       return maps
-}
diff --git a/pkg/trait/runtime_test.go b/pkg/trait/runtime_test.go
deleted file mode 100644
index b4f6108..0000000
--- a/pkg/trait/runtime_test.go
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
-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.
-*/
-
-package trait
-
-import (
-       "testing"
-
-       v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
-       "github.com/apache/camel-k/pkg/util/kubernetes"
-       "github.com/apache/camel-k/pkg/util/test"
-
-       "github.com/stretchr/testify/assert"
-
-       appsv1 "k8s.io/api/apps/v1"
-       corev1 "k8s.io/api/core/v1"
-       metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-)
-
-func TestApplyruntimeTraitWithProperties(t *testing.T) {
-       runtimeTrait, environment := createNominalRuntimeTest()
-       runtimeTrait.Properties = []string{"a=b", "c=d"}
-       err := runtimeTrait.Apply(environment)
-       assert.Nil(t, err)
-
-       userPropertiesCm := environment.Resources.GetConfigMap(func(cm 
*corev1.ConfigMap) bool {
-               return cm.Labels["camel.apache.org/properties.type"] == "user"
-       })
-       assert.NotNil(t, userPropertiesCm)
-       assert.Equal(t, map[string]string{
-               "application.properties": "a=b\nc=d\n",
-       }, userPropertiesCm.Data)
-}
-
-func createNominalRuntimeTest() (*runtimeTrait, *Environment) {
-       trait := newRuntimeTrait().(*runtimeTrait)
-       trait.Enabled = BoolP(true)
-       trait.Client, _ = test.NewFakeClient(&appsv1.Deployment{
-               ObjectMeta: metav1.ObjectMeta{
-                       Name:      "integration-name",
-                       Namespace: "namespace",
-                       Labels: map[string]string{
-                               v1.IntegrationLabel: "integration-name",
-                       },
-               },
-       })
-
-       replicas := int32(3)
-
-       environment := &Environment{
-               Catalog: NewCatalog(nil),
-               Integration: &v1.Integration{
-                       ObjectMeta: metav1.ObjectMeta{
-                               Name: "integration-name",
-                       },
-                       Spec: v1.IntegrationSpec{
-                               Replicas: &replicas,
-                               Traits:   make(map[string]v1.TraitSpec),
-                       },
-                       Status: v1.IntegrationStatus{
-                               Phase: v1.IntegrationPhaseDeploying,
-                       },
-               },
-               IntegrationKit: &v1.IntegrationKit{
-                       Status: v1.IntegrationKitStatus{
-                               Phase: v1.IntegrationKitPhaseReady,
-                       },
-               },
-               Platform: &v1.IntegrationPlatform{
-                       ObjectMeta: metav1.ObjectMeta{
-                               Namespace: "namespace",
-                       },
-                       Spec: v1.IntegrationPlatformSpec{
-                               Cluster: v1.IntegrationPlatformClusterOpenShift,
-                               Profile: v1.TraitProfileKnative,
-                       },
-               },
-               Resources:             kubernetes.NewCollection(),
-               ApplicationProperties: make(map[string]string),
-       }
-       environment.Platform.ResyncStatusFullConfig()
-
-       return trait, environment
-}
diff --git a/pkg/trait/trait_register.go b/pkg/trait/trait_register.go
index 1a3fe4c..64e8a39 100644
--- a/pkg/trait/trait_register.go
+++ b/pkg/trait/trait_register.go
@@ -49,7 +49,6 @@ func init() {
        AddToTraits(newPullSecretTrait)
        AddToTraits(newQuarkusTrait)
        AddToTraits(newRouteTrait)
-       AddToTraits(newRuntimeTrait)
        AddToTraits(newServiceTrait)
        AddToTraits(newServiceBindingTrait)
        AddToTraits(newTolerationTrait)
diff --git a/pkg/trait/trait_test.go b/pkg/trait/trait_test.go
index cad1028..888ed71 100644
--- a/pkg/trait/trait_test.go
+++ b/pkg/trait/trait_test.go
@@ -277,31 +277,19 @@ func 
TestConfigureVolumesAndMountsTextResourcesAndProperties(t *testing.T) {
        vols := make([]corev1.Volume, 0)
        mnts := make([]corev1.VolumeMount, 0)
 
-       env.Resources.AddAll(env.computeConfigMaps())
        env.configureVolumesAndMounts(&vols, &mnts)
 
-       assert.Len(t, vols, 8)
-       assert.Len(t, mnts, 8)
+       assert.Len(t, vols, 7)
+       assert.Len(t, mnts, 7)
 
-       v := findVolume(vols, func(v corev1.Volume) bool { return 
v.ConfigMap.Name == "test-user-properties" })
-       assert.NotNil(t, v)
-       assert.NotNil(t, v.VolumeSource.ConfigMap)
-       assert.Len(t, v.VolumeSource.ConfigMap.Items, 1)
-       assert.Equal(t, "application.properties", 
v.VolumeSource.ConfigMap.Items[0].Key)
-       assert.Equal(t, "user.properties", 
v.VolumeSource.ConfigMap.Items[0].Path)
-
-       m := findVVolumeMount(mnts, func(m corev1.VolumeMount) bool { return 
m.Name == v.Name })
-       assert.NotNil(t, m)
-       assert.Equal(t, "/etc/camel/conf.d/user.properties", m.MountPath)
-
-       v = findVolume(vols, func(v corev1.Volume) bool { return 
v.ConfigMap.Name == "my-cm1" })
+       v := findVolume(vols, func(v corev1.Volume) bool { return 
v.ConfigMap.Name == "my-cm1" })
        assert.NotNil(t, v)
        assert.NotNil(t, v.VolumeSource.ConfigMap)
        assert.Len(t, v.VolumeSource.ConfigMap.Items, 1)
        assert.Equal(t, "my-key1", v.VolumeSource.ConfigMap.Items[0].Key)
        assert.Equal(t, "res1.txt", v.VolumeSource.ConfigMap.Items[0].Path)
 
-       m = findVVolumeMount(mnts, func(m corev1.VolumeMount) bool { return 
m.Name == "i-resource-000" })
+       m := findVVolumeMount(mnts, func(m corev1.VolumeMount) bool { return 
m.Name == "i-resource-000" })
        assert.NotNil(t, m)
        assert.Equal(t, "/etc/m1", m.MountPath)
 
@@ -401,7 +389,6 @@ func TestConfigureVolumesAndMountsSources(t *testing.T) {
        vols := make([]corev1.Volume, 0)
        mnts := make([]corev1.VolumeMount, 0)
 
-       env.Resources.AddAll(env.computeConfigMaps())
        env.configureVolumesAndMounts(&vols, &mnts)
 
        assert.Len(t, vols, 2)
@@ -464,7 +451,6 @@ func TestConfigureVolumesAndMountsBinaryAndTextResources(t 
*testing.T) {
        vols := make([]corev1.Volume, 0)
        mnts := make([]corev1.VolumeMount, 0)
 
-       env.Resources.AddAll(env.computeConfigMaps())
        env.configureVolumesAndMounts(&vols, &mnts)
 
        assert.Len(t, vols, 2)
diff --git a/pkg/trait/trait_types.go b/pkg/trait/trait_types.go
index f3708c8..b549f13 100644
--- a/pkg/trait/trait_types.go
+++ b/pkg/trait/trait_types.go
@@ -22,7 +22,6 @@ import (
        "fmt"
        "path"
        "sort"
-       "strconv"
        "strings"
 
        "github.com/pkg/errors"
@@ -34,8 +33,6 @@ import (
 
        serving "knative.dev/serving/pkg/apis/serving/v1"
 
-       ctrl "sigs.k8s.io/controller-runtime/pkg/client"
-
        v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
        "github.com/apache/camel-k/pkg/client"
        "github.com/apache/camel-k/pkg/platform"
@@ -400,124 +397,6 @@ func (e *Environment) computeApplicationProperties() 
(*corev1.ConfigMap, error)
        return nil, nil
 }
 
-func (e *Environment) computeConfigMaps() []ctrl.Object {
-       sources := e.Integration.Sources()
-       maps := make([]ctrl.Object, 0, len(sources)+1)
-
-       // combine properties of integration with kit, integration
-       // properties have the priority
-       userProperties := ""
-
-       for _, prop := range e.collectConfigurationPairs("property") {
-               // properties in resource configuration are expected to be 
pre-encoded using properties format
-               userProperties += fmt.Sprintf("%s=%s\n", prop.Name, prop.Value)
-       }
-
-       if userProperties != "" {
-               maps = append(
-                       maps,
-                       &corev1.ConfigMap{
-                               TypeMeta: metav1.TypeMeta{
-                                       Kind:       "ConfigMap",
-                                       APIVersion: "v1",
-                               },
-                               ObjectMeta: metav1.ObjectMeta{
-                                       Name:      e.Integration.Name + 
"-user-properties",
-                                       Namespace: e.Integration.Namespace,
-                                       Labels: map[string]string{
-                                               v1.IntegrationLabel:            
    e.Integration.Name,
-                                               
"camel.apache.org/properties.type": "user",
-                                       },
-                               },
-                               Data: map[string]string{
-                                       "application.properties": 
userProperties,
-                               },
-                       },
-               )
-       }
-
-       for i, s := range sources {
-               if s.ContentRef != "" {
-                       continue
-               }
-
-               cm := corev1.ConfigMap{
-                       TypeMeta: metav1.TypeMeta{
-                               Kind:       "ConfigMap",
-                               APIVersion: "v1",
-                       },
-                       ObjectMeta: metav1.ObjectMeta{
-                               Name:      fmt.Sprintf("%s-source-%03d", 
e.Integration.Name, i),
-                               Namespace: e.Integration.Namespace,
-                               Labels: map[string]string{
-                                       v1.IntegrationLabel: e.Integration.Name,
-                               },
-                               Annotations: map[string]string{
-                                       "camel.apache.org/source.language":    
string(s.InferLanguage()),
-                                       "camel.apache.org/source.loader":      
s.Loader,
-                                       "camel.apache.org/source.name":        
s.Name,
-                                       "camel.apache.org/source.compression": 
strconv.FormatBool(s.Compression),
-                               },
-                       },
-                       Data: map[string]string{
-                               "content": s.Content,
-                       },
-               }
-
-               maps = append(maps, &cm)
-       }
-
-       for i, r := range e.Integration.Spec.Resources {
-               if r.Type == v1.ResourceTypeOpenAPI {
-                       continue
-               }
-               if r.ContentRef != "" {
-                       continue
-               }
-
-               cmKey := "content"
-               if r.ContentKey != "" {
-                       cmKey = r.ContentKey
-               }
-
-               cm := corev1.ConfigMap{
-                       TypeMeta: metav1.TypeMeta{
-                               Kind:       "ConfigMap",
-                               APIVersion: "v1",
-                       },
-                       ObjectMeta: metav1.ObjectMeta{
-                               Name:      fmt.Sprintf("%s-resource-%03d", 
e.Integration.Name, i),
-                               Namespace: e.Integration.Namespace,
-                               Labels: map[string]string{
-                                       "camel.apache.org/integration": 
e.Integration.Name,
-                               },
-                               Annotations: map[string]string{
-                                       "camel.apache.org/resource.name":       
 r.Name,
-                                       
"camel.apache.org/resource.compression": strconv.FormatBool(r.Compression),
-                               },
-                       },
-               }
-
-               if r.ContentType != "" {
-                       
cm.Annotations["camel.apache.org/resource.content-type"] = r.ContentType
-               }
-
-               if r.RawContent != nil {
-                       cm.BinaryData = map[string][]byte{
-                               cmKey: r.RawContent,
-                       }
-               } else {
-                       cm.Data = map[string]string{
-                               cmKey: r.Content,
-                       }
-               }
-
-               maps = append(maps, &cm)
-       }
-
-       return maps
-}
-
 func (e *Environment) addSourcesProperties() {
        if e.ApplicationProperties == nil {
                e.ApplicationProperties = make(map[string]string)
diff --git a/resources/traits.yaml b/resources/traits.yaml
index 92be833..36b9031 100755
--- a/resources/traits.yaml
+++ b/resources/traits.yaml
@@ -73,6 +73,9 @@ traits:
     type: string
     description: The camel-k-runtime version to use for the integration. It 
overrides
       the default version set in the Integration Platform.
+  - name: properties
+    type: '[]string'
+    description: A list of properties to be provided to the Integration runtime
 - name: container
   platform: true
   profiles:
@@ -322,7 +325,7 @@ traits:
     description: Can be used to enable or disable a trait. All traits share 
this common
       property.
   - name: discovery-cache
-    type: github.com/apache/camel-k/pkg/trait.discoveryCacheType
+    type: ./pkg/trait.discoveryCacheType
     description: Discovery client cache to be used, either `disabled`, `disk` 
or `memory`
       (default `memory`)
 - name: ingress
@@ -351,7 +354,7 @@ traits:
   - Kubernetes
   - Knative
   - OpenShift
-  description: The Istio trait allows to configure properties related to the 
Istio
+  description: The Istio trait allows configuring properties related to the 
Istio
     service mesh, such as sidecar injection and outbound IP ranges.
   properties:
   - name: enabled
@@ -912,22 +915,6 @@ traits:
     description: To configure how to deal with insecure traffic, e.g. `Allow`, 
`Disable`
       or `Redirect` traffic.Refer to the OpenShift route documentation for 
additional
       information.
-- name: runtime
-  platform: true
-  profiles:
-  - Kubernetes
-  - Knative
-  - OpenShift
-  description: The runtime trait is used to customize the Integration runtime 
configuration
-    such as properties and resources.
-  properties:
-  - name: enabled
-    type: bool
-    description: Can be used to enable or disable a trait. All traits share 
this common
-      property.
-  - name: properties
-    type: '[]string'
-    description: A list of properties to be provided to the Integration runtime
 - name: service-binding
   platform: false
   profiles:

Reply via email to