You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by as...@apache.org on 2021/09/28 06:02:02 UTC
[camel-k] 04/06: chore(trait): changing configuration to runtime
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 1b844f856f2973b7cf10c773c498654f8b435057
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Thu Sep 16 10:36:54 2021 +0200
chore(trait): changing configuration to runtime
---
docs/modules/ROOT/nav.adoc | 2 +-
docs/modules/traits/pages/runtime.adoc | 36 ++++++++++++++++++++++
pkg/cmd/run.go | 2 +-
pkg/trait/{configuration.go => runtime.go} | 20 ++++++------
.../{configuration_test.go => runtime_test.go} | 12 ++++----
pkg/trait/trait_register.go | 2 +-
pkg/trait/trait_test.go | 2 +-
resources/traits.yaml | 32 +++++++++----------
8 files changed, 72 insertions(+), 36 deletions(-)
diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc
index 620e5cb..3ff11a4 100644
--- a/docs/modules/ROOT/nav.adoc
+++ b/docs/modules/ROOT/nav.adoc
@@ -45,7 +45,6 @@
** xref:traits:affinity.adoc[Affinity]
** xref:traits:builder.adoc[Builder]
** xref:traits:camel.adoc[Camel]
-** xref:traits:configuration.adoc[Configuration]
** xref:traits:container.adoc[Container]
** xref:traits:cron.adoc[Cron]
** xref:traits:dependencies.adoc[Dependencies]
@@ -72,6 +71,7 @@
** 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/runtime.adoc b/docs/modules/traits/pages/runtime.adoc
new file mode 100755
index 0000000..7e9bbfb
--- /dev/null
+++ b/docs/modules/traits/pages/runtime.adoc
@@ -0,0 +1,36 @@
+= 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/pkg/cmd/run.go b/pkg/cmd/run.go
index 52971bd..f2fcd07 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, "configuration.properties"); err != nil {
+ if propsTraits, err := convertToTraitParameter(kv, "runtime.properties"); err != nil {
return nil, err
} else {
o.Traits = append(o.Traits, propsTraits...)
diff --git a/pkg/trait/configuration.go b/pkg/trait/runtime.go
similarity index 81%
rename from pkg/trait/configuration.go
rename to pkg/trait/runtime.go
index 74c2f10..a4cee7f 100644
--- a/pkg/trait/configuration.go
+++ b/pkg/trait/runtime.go
@@ -27,22 +27,22 @@ import (
ctrl "sigs.k8s.io/controller-runtime/pkg/client"
)
-// The configuration trait is used to customize the Integration configuration such as properties and resources.
+// The runtime trait is used to customize the Integration runtime configuration such as properties and resources.
//
-// +camel-k:trait=configuration
-type configurationTrait struct {
+// +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 newConfigurationTrait() Trait {
- return &configurationTrait{
- BaseTrait: NewBaseTrait("configuration", 700),
+func newRuntimeTrait() Trait {
+ return &runtimeTrait{
+ BaseTrait: NewBaseTrait("runtime", 700),
}
}
-func (t *configurationTrait) Configure(e *Environment) (bool, error) {
+func (t *runtimeTrait) Configure(e *Environment) (bool, error) {
if t.Enabled != nil && !*t.Enabled {
return false, nil
}
@@ -50,7 +50,7 @@ func (t *configurationTrait) Configure(e *Environment) (bool, error) {
return true, nil
}
-func (t *configurationTrait) Apply(e *Environment) error {
+func (t *runtimeTrait) Apply(e *Environment) error {
if e.InPhase(v1.IntegrationKitPhaseReady, v1.IntegrationPhaseDeploying) ||
e.InPhase(v1.IntegrationKitPhaseReady, v1.IntegrationPhaseRunning) {
// Get all resources
@@ -65,11 +65,11 @@ func (t *configurationTrait) Apply(e *Environment) error {
return nil
}
-func (t *configurationTrait) IsPlatformTrait() bool {
+func (t *runtimeTrait) IsPlatformTrait() bool {
return true
}
-func (t *configurationTrait) computeUserProperties(e *Environment) []ctrl.Object {
+func (t *runtimeTrait) computeUserProperties(e *Environment) []ctrl.Object {
maps := make([]ctrl.Object, 0)
// combine properties of integration with kit, integration
diff --git a/pkg/trait/configuration_test.go b/pkg/trait/runtime_test.go
similarity index 87%
rename from pkg/trait/configuration_test.go
rename to pkg/trait/runtime_test.go
index 4e457c8..b4f6108 100644
--- a/pkg/trait/configuration_test.go
+++ b/pkg/trait/runtime_test.go
@@ -31,10 +31,10 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
-func TestApplyConfigurationTraitWithProperties(t *testing.T) {
- configurationTrait, environment := createNominalConfigurationTest()
- configurationTrait.Properties = []string{"a=b", "c=d"}
- err := configurationTrait.Apply(environment)
+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 {
@@ -46,8 +46,8 @@ func TestApplyConfigurationTraitWithProperties(t *testing.T) {
}, userPropertiesCm.Data)
}
-func createNominalConfigurationTest() (*configurationTrait, *Environment) {
- trait := newConfigurationTrait().(*configurationTrait)
+func createNominalRuntimeTest() (*runtimeTrait, *Environment) {
+ trait := newRuntimeTrait().(*runtimeTrait)
trait.Enabled = BoolP(true)
trait.Client, _ = test.NewFakeClient(&appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
diff --git a/pkg/trait/trait_register.go b/pkg/trait/trait_register.go
index 530953d..1a3fe4c 100644
--- a/pkg/trait/trait_register.go
+++ b/pkg/trait/trait_register.go
@@ -23,7 +23,6 @@ func init() {
AddToTraits(newAffinityTrait)
AddToTraits(newBuilderTrait)
AddToTraits(newCamelTrait)
- AddToTraits(newConfigurationTrait)
AddToTraits(newContainerTrait)
AddToTraits(newCronTrait)
AddToTraits(newDependenciesTrait)
@@ -50,6 +49,7 @@ 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 2936ca6..cad1028 100644
--- a/pkg/trait/trait_test.go
+++ b/pkg/trait/trait_test.go
@@ -508,7 +508,7 @@ func TestOnlySomeTraitsInfluenceBuild(t *testing.T) {
func TestOnlySomeTraitsArePlatform(t *testing.T) {
c := NewTraitTestCatalog()
- platformTraits := []string{"builder", "camel", "jvm", "configuration", "container", "dependencies", "deployer",
+ platformTraits := []string{"builder", "camel", "jvm", "runtime", "container", "dependencies", "deployer",
"deployment", "environment", "error-handler", "kamelets", "openapi", "owner", "platform", "quarkus"}
for _, trait := range c.AllTraits() {
diff --git a/resources/traits.yaml b/resources/traits.yaml
index 6556217..92be833 100755
--- a/resources/traits.yaml
+++ b/resources/traits.yaml
@@ -73,22 +73,6 @@ 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: configuration
- platform: true
- profiles:
- - Kubernetes
- - Knative
- - OpenShift
- description: The configuration trait is used to customize the Integration 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: container
platform: true
profiles:
@@ -928,6 +912,22 @@ 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: