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 2022/07/11 15:29:55 UTC
[camel-k] branch main updated (b680d5dff -> 0e51e5bdf)
This is an automated email from the ASF dual-hosted git repository.
astefanutti pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
from b680d5dff fix(doc): fix gen-crd-api-reference-docs and regen API doc with Traits
new d6da80d52 Fix #2177: Cosmetic changes
new ee137fedc Fix #2177: Use operator id by default
new c2302fa9b Fix #2177: Align namespace operator lease with operator id
new 4f48c99ca Fix #2177: Make sure to properly reinitialize integration
new 656bb0672 Fix #2177: Ensure unique operator id during install
new 417b7b873 Fix #2177: Ensure valid operator id when running integrations
new c33e0cc18 Fix #2177: Use operator id in KameletBindings
new 4e6a2db16 Fix #2177: Introduce integration platform viewer role
new a3be4d23b Fix #2177: Create proper integration platform as part of the operator
new ad6a74900 Fix #2177: Improve operator version lookup
new 734dc8354 Fix #2177: Fix golangci-lint errors
new aadc81640 Fix #2177: Fix e2e tests
new 93245fd35 Fix #2177: Update docs
new 1c2426732 fix(#2177): Reduce duplicate code
new a1f6fc77b fix(#2177): Add `-x` shorthand to `--operator-id` kamel CLI option
new fb172cc4a fix(#2177): Fix preflight test script and e2e upgrade tests
new 0e51e5bdf fix(#2177): Remove obsolete kamel-install GitHub action
The 17 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.github/actions/e2e-knative-yaks/action.yml | 9 +-
.github/actions/kamel-install-yaks/action.yml | 5 +-
.../actions/kamel-preflight-test/preflight-test.sh | 4 +-
.github/workflows/upgrade.yml | 2 +-
addons/threescale/3scale.go | 12 +-
config/manager/operator-deployment.yaml | 2 +
docs/modules/ROOT/pages/architecture/operator.adoc | 21 ++-
.../ROOT/pages/installation/advanced/multi.adoc | 31 +++--
e2e/global/builder/build_test.go | 4 +-
e2e/global/builder/docker_hub_test.go | 5 +-
e2e/global/builder/github_packages_test.go | 5 +-
e2e/global/common/build/incremental_build_test.go | 7 +-
e2e/global/common/build/maven_ca_secret_test.go | 5 +-
e2e/global/common/build/maven_repository_test.go | 5 +-
e2e/global/common/config/config_test.go | 44 +++---
e2e/global/common/cron_test.go | 13 +-
e2e/global/common/integration_fail_test.go | 5 +-
e2e/global/common/kamelet_binding_test.go | 3 +-
e2e/global/common/kamelet_test.go | 5 +-
e2e/global/common/kamelet_update_test.go | 3 +-
e2e/global/common/languages/groovy_test.go | 5 +-
e2e/global/common/languages/init_test_support.go | 2 +-
e2e/global/common/languages/java_test.go | 7 +-
e2e/global/common/languages/js_test.go | 5 +-
e2e/global/common/languages/kotlin_test.go | 5 +-
e2e/global/common/languages/polyglot_test.go | 5 +-
e2e/global/common/languages/xml_test.go | 5 +-
e2e/global/common/languages/yaml_test.go | 5 +-
e2e/global/common/operator_metrics_test.go | 5 +-
e2e/global/common/platformless_run_test.go | 5 +-
e2e/global/common/promote_test.go | 6 +-
e2e/global/common/reset_test.go | 14 +-
e2e/global/common/rest_test.go | 7 +-
e2e/global/common/scale_binding_test.go | 5 +-
e2e/global/common/scale_integration_test.go | 7 +-
e2e/global/common/secondary_platform_test.go | 9 +-
e2e/global/common/structured_logs_test.go | 5 +-
e2e/global/common/traits/affinity_test.go | 9 +-
e2e/global/common/traits/error_handler_test.go | 5 +-
e2e/global/common/traits/health_test.go | 5 +-
e2e/global/common/traits/istio_test.go | 5 +-
e2e/global/common/traits/jolokia_test.go | 5 +-
e2e/global/common/traits/jvm_test.go | 5 +-
e2e/global/common/traits/master_test.go | 9 +-
e2e/global/common/traits/openapi_test.go | 14 +-
e2e/global/common/traits/pdb_test.go | 5 +-
e2e/global/common/traits/pod_test.go | 5 +-
e2e/global/common/traits/prometheus_test.go | 5 +-
e2e/global/common/traits/pull_secret_test.go | 9 +-
e2e/global/common/traits/route_test.go | 13 +-
e2e/global/common/traits/service_test.go | 7 +-
e2e/global/common/traits/toleration_test.go | 9 +-
e2e/global/knative/kamelet_test.go | 5 +-
e2e/global/knative/knative_platform_test.go | 7 +-
e2e/global/knative/knative_test.go | 49 ++++---
e2e/global/knative/openapi_test.go | 14 +-
e2e/global/knative/pod_test.go | 7 +-
e2e/global/registry/registry_maven_wagon_test.go | 18 +--
.../service_binding_kamelet_test.go | 8 +-
e2e/global/service-binding/service_binding_test.go | 6 +-
e2e/namespace/install/cli/bind_test.go | 11 +-
e2e/namespace/install/cli/delete_test.go | 17 +--
e2e/namespace/install/cli/describe_test.go | 5 +-
e2e/namespace/install/cli/dev_mode_test.go | 48 +++++--
e2e/namespace/install/cli/dump_test.go | 5 +-
e2e/namespace/install/cli/get_test.go | 9 +-
e2e/namespace/install/cli/global_kamelet_test.go | 12 +-
e2e/namespace/install/cli/global_test.go | 26 ++--
e2e/namespace/install/cli/install_test.go | 25 ++--
e2e/namespace/install/cli/log_test.go | 5 +-
e2e/namespace/install/cli/run_test.go | 19 +--
e2e/namespace/install/cli/uninstall_test.go | 22 ++-
e2e/namespace/install/environment_test.go | 9 +-
e2e/namespace/install/maven_http_proxy_test.go | 9 +-
.../install/operator_id_filtering_test.go | 14 +-
e2e/namespace/native/native_test.go | 7 +-
e2e/namespace/upgrade/cli_upgrade_test.go | 8 +-
e2e/namespace/upgrade/olm_upgrade_test.go | 6 +-
e2e/support/test_support.go | 147 +++++++++++++++------
e2e/support/util/dump.go | 8 ++
.../common/apache-kamelet-catalog/yaks-config.yaml | 6 +-
e2e/yaks/common/kamelet-beans/yaks-config.yaml | 6 +-
.../kamelet-binding-autoload/yaks-config.yaml | 6 +-
.../common/kamelet-binding-broker/yaks-config.yaml | 6 +-
.../common/kamelet-binding-http/yaks-config.yaml | 6 +-
.../yaks-config.yaml | 6 +-
e2e/yaks/common/kamelet-binding/yaks-config.yaml | 6 +-
.../kamelet-no-properties/kamelet-no-props.feature | 1 -
.../common/kamelet-no-properties/yaks-config.yaml | 6 +-
e2e/yaks/common/kamelet-steps/yaks-config.yaml | 6 +-
e2e/yaks/common/kamelet/yaks-config.yaml | 6 +-
e2e/yaks/common/knative-broker/yaks-config.yaml | 6 +-
.../common/knative-sinkbinding/yaks-config.yaml | 6 +-
pkg/apis/camel/v1/common_types_support.go | 24 ++++
pkg/apis/camel/v1/integration_types_support.go | 5 +
pkg/apis/camel/v1/integrationkit_types_support.go | 5 +
.../camel/v1/integrationplatform_types_support.go | 5 +
.../v1alpha1/kamelet_binding_types_support.go | 5 +
pkg/cmd/bind.go | 41 ++++++
pkg/cmd/bind_test.go | 19 ++-
pkg/cmd/install.go | 56 +++++++-
pkg/cmd/operator.go | 17 ++-
pkg/cmd/operator/operator.go | 34 +++++
pkg/cmd/root_test.go | 11 +-
pkg/cmd/run.go | 30 ++++-
pkg/cmd/run_test.go | 10 +-
pkg/cmd/uninstall.go | 4 +-
pkg/cmd/util.go | 23 +++-
pkg/cmd/version.go | 24 ++--
pkg/controller/build/build_controller.go | 2 +-
.../integration/integration_controller.go | 14 +-
pkg/controller/integration/monitor.go | 63 +++++++--
.../integrationkit/integrationkit_controller.go | 2 +-
.../integrationplatform_controller.go | 2 +-
pkg/controller/kamelet/kamelet_controller.go | 2 +-
.../kameletbinding/kamelet_binding_controller.go | 2 +-
pkg/controller/kameletbinding/monitor.go | 7 +-
pkg/install/operator.go | 10 +-
pkg/install/platform.go | 32 +++++
pkg/platform/operator.go | 94 +++++++++++--
pkg/platform/platform.go | 33 ++++-
pkg/resources/resources.go | 20 ++-
pkg/trait/container.go | 10 +-
pkg/trait/environment.go | 2 +
pkg/trait/platform.go | 21 ++-
pkg/trait/pod_test.go | 5 +-
pkg/trait/quarkus.go | 7 +-
pkg/util/digest/digest.go | 10 ++
pkg/util/kubernetes/replace.go | 15 +--
... user-global-platform-viewer-role-binding.yaml} | 6 +-
....yaml => user-global-platform-viewer-role.yaml} | 6 +-
131 files changed, 1206 insertions(+), 473 deletions(-)
create mode 100644 pkg/install/platform.go
copy resources/viewer/{user-global-kamelet-viewer-role-binding.yaml => user-global-platform-viewer-role-binding.yaml} (91%)
copy resources/viewer/{user-global-kamelet-viewer-role.yaml => user-global-platform-viewer-role.yaml} (90%)
[camel-k] 04/17: Fix #2177: Make sure to properly reinitialize integration
Posted by as...@apache.org.
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 4f48c99cad20d682ee5c5640b74fbe83cd449d66
Author: Christoph Deppisch <cd...@redhat.com>
AuthorDate: Fri Jun 3 21:01:49 2022 +0200
Fix #2177: Make sure to properly reinitialize integration
- Reinitialize integration when operator id annotation has changed
- Remove IntegrationKit reference for integration that has a new operator id annotation
- Add operator id annotation to relevant fields that determine the integration digest hash
- Add common utility method to get the operator id annotation from a resource
- Allow default operator (id="camel-k") to handle legacy resources that are missing proper operator id annotations
- Allow operators that use a proper id to reconcile resources on any namespace (regardless of operator mode global vs. local and regardless of existing namespace lease)
---
pkg/apis/camel/v1/common_types_support.go | 15 ++++
pkg/controller/build/build_controller.go | 2 +-
.../integration/integration_controller.go | 14 ++--
pkg/controller/integration/monitor.go | 18 +++--
.../integrationkit/integrationkit_controller.go | 2 +-
.../integrationplatform_controller.go | 2 +-
pkg/controller/kamelet/kamelet_controller.go | 2 +-
.../kameletbinding/kamelet_binding_controller.go | 2 +-
pkg/platform/operator.go | 93 ++++++++++++++++++----
pkg/trait/platform.go | 4 +-
pkg/util/digest/digest.go | 6 ++
11 files changed, 125 insertions(+), 35 deletions(-)
diff --git a/pkg/apis/camel/v1/common_types_support.go b/pkg/apis/camel/v1/common_types_support.go
index aec43a183..bb93121b8 100644
--- a/pkg/apis/camel/v1/common_types_support.go
+++ b/pkg/apis/camel/v1/common_types_support.go
@@ -21,6 +21,8 @@ import (
"encoding/json"
"errors"
"fmt"
+
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
func (in *Artifact) String() string {
@@ -67,5 +69,18 @@ func (m *RawMessage) UnmarshalJSON(data []byte) error {
return nil
}
+// GetOperatorIDAnnotation to safely get the operator id annotation value
+func GetOperatorIDAnnotation(obj metav1.Object) string {
+ if obj == nil || obj.GetAnnotations() == nil {
+ return ""
+ }
+
+ if operatorId, ok := obj.GetAnnotations()[OperatorIDAnnotation]; ok {
+ return operatorId
+ }
+
+ return ""
+}
+
var _ json.Marshaler = (*RawMessage)(nil)
var _ json.Unmarshaler = (*RawMessage)(nil)
diff --git a/pkg/controller/build/build_controller.go b/pkg/controller/build/build_controller.go
index 51269b2c8..117ccaa1e 100644
--- a/pkg/controller/build/build_controller.go
+++ b/pkg/controller/build/build_controller.go
@@ -136,7 +136,7 @@ func (r *reconcileBuild) Reconcile(ctx context.Context, request reconcile.Reques
}
// Only process resources assigned to the operator
- if !platform.IsOperatorHandler(&instance) {
+ if !platform.IsOperatorHandlerConsideringLock(ctx, r.client, request.Namespace, &instance) {
rlog.Info("Ignoring request because resource is not assigned to current operator")
return reconcile.Result{}, nil
}
diff --git a/pkg/controller/integration/integration_controller.go b/pkg/controller/integration/integration_controller.go
index 11eb81641..c17a1babf 100644
--- a/pkg/controller/integration/integration_controller.go
+++ b/pkg/controller/integration/integration_controller.go
@@ -288,7 +288,7 @@ func (r *reconcileIntegration) Reconcile(ctx context.Context, request reconcile.
}
// Only process resources assigned to the operator
- if !platform.IsOperatorHandler(&instance) {
+ if !platform.IsOperatorHandlerConsideringLock(ctx, r.client, request.Namespace, &instance) {
rlog.Info("Ignoring request because resource is not assigned to current operator")
return reconcile.Result{}, nil
}
@@ -317,9 +317,9 @@ func (r *reconcileIntegration) Reconcile(ctx context.Context, request reconcile.
}
if newTarget != nil {
- if res, err := r.update(ctx, &instance, newTarget); err != nil {
+ if err := r.update(ctx, &instance, newTarget); err != nil {
camelevent.NotifyIntegrationError(ctx, r.client, r.recorder, &instance, newTarget, err)
- return res, err
+ return reconcile.Result{}, err
}
if newTarget.Status.Phase != instance.Status.Phase {
@@ -341,16 +341,14 @@ func (r *reconcileIntegration) Reconcile(ctx context.Context, request reconcile.
return reconcile.Result{}, nil
}
-func (r *reconcileIntegration) update(ctx context.Context, base *v1.Integration, target *v1.Integration) (reconcile.Result, error) {
+func (r *reconcileIntegration) update(ctx context.Context, base *v1.Integration, target *v1.Integration) error {
d, err := digest.ComputeForIntegration(target)
if err != nil {
- return reconcile.Result{}, err
+ return err
}
target.Status.Digest = d
target.Status.ObservedGeneration = base.Generation
- err = r.client.Status().Patch(ctx, target, ctrl.MergeFrom(base))
-
- return reconcile.Result{}, err
+ return r.client.Status().Patch(ctx, target, ctrl.MergeFrom(base))
}
diff --git a/pkg/controller/integration/monitor.go b/pkg/controller/integration/monitor.go
index 3e68a3a24..412c07cef 100644
--- a/pkg/controller/integration/monitor.go
+++ b/pkg/controller/integration/monitor.go
@@ -69,6 +69,11 @@ func (action *monitorAction) Handle(ctx context.Context, integration *v1.Integra
return nil, fmt.Errorf("no kit set on integration %s", integration.Name)
}
+ kit, err := kubernetes.GetIntegrationKit(ctx, action.client, integration.Status.IntegrationKit.Name, integration.Status.IntegrationKit.Namespace)
+ if err != nil {
+ return nil, fmt.Errorf("unable to find integration kit %s/%s: %w", integration.Status.IntegrationKit.Namespace, integration.Status.IntegrationKit.Name, err)
+ }
+
// Check if the Integration requires a rebuild
hash, err := digest.ComputeForIntegration(integration)
if err != nil {
@@ -76,7 +81,13 @@ func (action *monitorAction) Handle(ctx context.Context, integration *v1.Integra
}
if hash != integration.Status.Digest {
- action.L.Info("Integration needs a rebuild")
+ action.L.Info("Monitor: Integration needs a rebuild")
+
+ if v1.GetOperatorIDAnnotation(integration) != "" &&
+ (v1.GetOperatorIDAnnotation(integration) != v1.GetOperatorIDAnnotation(kit)) {
+ // Operator to reconcile the integration has changed. Reset integration kit so new operator can handle the kit reference
+ integration.SetIntegrationKit(nil)
+ }
integration.Initialize()
integration.Status.Digest = hash
@@ -84,11 +95,6 @@ func (action *monitorAction) Handle(ctx context.Context, integration *v1.Integra
return integration, nil
}
- kit, err := kubernetes.GetIntegrationKit(ctx, action.client, integration.Status.IntegrationKit.Name, integration.Status.IntegrationKit.Namespace)
- if err != nil {
- return nil, fmt.Errorf("unable to find integration kit %s/%s: %w", integration.Status.IntegrationKit.Namespace, integration.Status.IntegrationKit.Name, err)
- }
-
// Check if an IntegrationKit with higher priority is ready
priority, ok := kit.Labels[v1.IntegrationKitPriorityLabel]
if !ok {
diff --git a/pkg/controller/integrationkit/integrationkit_controller.go b/pkg/controller/integrationkit/integrationkit_controller.go
index bc4225cf1..c1f839636 100644
--- a/pkg/controller/integrationkit/integrationkit_controller.go
+++ b/pkg/controller/integrationkit/integrationkit_controller.go
@@ -219,7 +219,7 @@ func (r *reconcileIntegrationKit) Reconcile(ctx context.Context, request reconci
}
// Only process resources assigned to the operator
- if !platform.IsOperatorHandler(&instance) {
+ if !platform.IsOperatorHandlerConsideringLock(ctx, r.client, request.Namespace, &instance) {
rlog.Info("Ignoring request because resource is not assigned to current operator")
return reconcile.Result{}, nil
}
diff --git a/pkg/controller/integrationplatform/integrationplatform_controller.go b/pkg/controller/integrationplatform/integrationplatform_controller.go
index 9768be424..44257e0a3 100644
--- a/pkg/controller/integrationplatform/integrationplatform_controller.go
+++ b/pkg/controller/integrationplatform/integrationplatform_controller.go
@@ -155,7 +155,7 @@ func (r *reconcileIntegrationPlatform) Reconcile(ctx context.Context, request re
}
// Only process resources assigned to the operator
- if !platform.IsOperatorHandler(&instance) {
+ if !platform.IsOperatorHandlerConsideringLock(ctx, r.client, request.Namespace, &instance) {
rlog.Info("Ignoring request because resource is not assigned to current operator")
return reconcile.Result{}, nil
}
diff --git a/pkg/controller/kamelet/kamelet_controller.go b/pkg/controller/kamelet/kamelet_controller.go
index 19a1375c0..5abee9855 100644
--- a/pkg/controller/kamelet/kamelet_controller.go
+++ b/pkg/controller/kamelet/kamelet_controller.go
@@ -143,7 +143,7 @@ func (r *reconcileKamelet) Reconcile(ctx context.Context, request reconcile.Requ
}
// Only process resources assigned to the operator
- if !platform.IsOperatorHandler(&instance) {
+ if !platform.IsOperatorHandlerConsideringLock(ctx, r.client, request.Namespace, &instance) {
rlog.Info("Ignoring request because resource is not assigned to current operator")
return reconcile.Result{}, nil
}
diff --git a/pkg/controller/kameletbinding/kamelet_binding_controller.go b/pkg/controller/kameletbinding/kamelet_binding_controller.go
index 2ace3da23..8cd8bebb1 100644
--- a/pkg/controller/kameletbinding/kamelet_binding_controller.go
+++ b/pkg/controller/kameletbinding/kamelet_binding_controller.go
@@ -160,7 +160,7 @@ func (r *ReconcileKameletBinding) Reconcile(ctx context.Context, request reconci
}
// Only process resources assigned to the operator
- if !platform.IsOperatorHandler(&instance) {
+ if !platform.IsOperatorHandlerConsideringLock(ctx, r.client, request.Namespace, &instance) {
rlog.Info("Ignoring request because resource is not assigned to current operator")
return reconcile.Result{}, nil
}
diff --git a/pkg/platform/operator.go b/pkg/platform/operator.go
index 602a99105..95e3bad68 100644
--- a/pkg/platform/operator.go
+++ b/pkg/platform/operator.go
@@ -81,27 +81,41 @@ func IsNamespaceLocked(ctx context.Context, c ctrl.Reader, namespace string) (bo
return false, nil
}
- var operatorLockName string
- if defaults.OperatorID() != "" {
- operatorLockName = fmt.Sprintf("%s-lock", defaults.OperatorID())
- } else {
- operatorLockName = OperatorLockName
+ platforms, err := ListPrimaryPlatforms(ctx, c, namespace)
+ if err != nil {
+ return true, err
}
- lease := coordination.Lease{}
- if err := c.Get(ctx, ctrl.ObjectKey{Namespace: namespace, Name: operatorLockName}, &lease); err != nil && k8serrors.IsNotFound(err) {
- return false, nil
- } else if err != nil {
- return true, err
+ for _, platform := range platforms.Items {
+ lease := coordination.Lease{}
+
+ var operatorLockName string
+ if platform.Name != "" {
+ operatorLockName = fmt.Sprintf("%s-lock", platform.Name)
+ } else {
+ operatorLockName = OperatorLockName
+ }
+
+ if err := c.Get(ctx, ctrl.ObjectKey{Namespace: namespace, Name: operatorLockName}, &lease); err == nil || !k8serrors.IsNotFound(err) {
+ return true, err
+ }
}
- return true, nil
+
+ return false, nil
}
// IsOperatorAllowedOnNamespace returns true if the current operator is allowed to react on changes in the given namespace.
func IsOperatorAllowedOnNamespace(ctx context.Context, c ctrl.Reader, namespace string) (bool, error) {
+ // allow all local operators
if !IsCurrentOperatorGlobal() {
return true, nil
}
+
+ // allow global operators that use a proper operator id
+ if defaults.OperatorID() != "" {
+ return true, nil
+ }
+
operatorNamespace := GetOperatorNamespace()
if operatorNamespace == namespace {
// Global operator is allowed on its own namespace
@@ -114,13 +128,64 @@ func IsOperatorAllowedOnNamespace(ctx context.Context, c ctrl.Reader, namespace
return !alreadyOwned, nil
}
+// IsOperatorHandler checks on resource operator id annotation and this operator instance id.
+// Operators matching the annotation operator id are allowed to reconcile.
+// For legacy resources that are missing a proper operator id annotation the default global operator or the local
+// operator in this namespace are candidates for reconciliation.
func IsOperatorHandler(object ctrl.Object) bool {
if object == nil {
return true
}
- resourceID := object.GetAnnotations()[camelv1.OperatorIDAnnotation]
+ resourceID := camelv1.GetOperatorIDAnnotation(object)
operatorID := defaults.OperatorID()
- return resourceID == operatorID
+
+ // allow operator with matching id to handle the resource
+ if resourceID == operatorID {
+ return true
+ }
+
+ // check if we are dealing with resource that is missing a proper operator id annotation
+ if resourceID == "" {
+ // allow default global operator to handle legacy resources (missing proper operator id annotations)
+ if operatorID == DefaultPlatformName {
+ return true
+ }
+
+ // allow local operators to handle legacy resources (missing proper operator id annotations)
+ if !IsCurrentOperatorGlobal() {
+ return true
+ }
+ }
+
+ return false
+}
+
+// IsOperatorHandlerConsideringLock uses normal IsOperatorHandler checks and adds additional check for legacy resources
+// that are missing a proper operator id annotation. In general two kind of operators race for reconcile these legacy resources.
+// The local operator for this namespace and the default global operator instance. Based on the existence of a namespace
+// lock the current local operator has precedence. When no lock exists the default global operator should reconcile.
+func IsOperatorHandlerConsideringLock(ctx context.Context, c ctrl.Reader, namespace string, object ctrl.Object) bool {
+ isHandler := IsOperatorHandler(object)
+ if !isHandler {
+ return false
+ }
+
+ resourceID := camelv1.GetOperatorIDAnnotation(object)
+ // add additional check on resources missing an operator id
+ if resourceID == "" {
+ operatorNamespace := GetOperatorNamespace()
+ if operatorNamespace == namespace {
+ // Global operator is allowed on its own namespace
+ return true
+ }
+
+ if locked, err := IsNamespaceLocked(ctx, c, namespace); err != nil || locked {
+ // namespace is locked so local operators do have precedence
+ return !IsCurrentOperatorGlobal()
+ }
+ }
+
+ return true
}
// FilteringFuncs do preliminary checks to determine if certain events should be handled by the controller
@@ -165,7 +230,7 @@ func (f FilteringFuncs) Update(e event.UpdateEvent) bool {
return false
}
if e.ObjectOld != nil && e.ObjectNew != nil &&
- e.ObjectOld.GetAnnotations()[camelv1.OperatorIDAnnotation] != e.ObjectNew.GetAnnotations()[camelv1.OperatorIDAnnotation] {
+ camelv1.GetOperatorIDAnnotation(e.ObjectOld) != camelv1.GetOperatorIDAnnotation(e.ObjectNew) {
// Always force reconciliation when the object becomes managed by the current operator
return true
}
diff --git a/pkg/trait/platform.go b/pkg/trait/platform.go
index 4cf7d5b65..263b76add 100644
--- a/pkg/trait/platform.go
+++ b/pkg/trait/platform.go
@@ -111,11 +111,11 @@ func (t *platformTrait) getOrCreatePlatform(e *Environment) (*v1.IntegrationPlat
}
defaultPlatform.Labels["camel.apache.org/platform.generated"] = True
// Cascade the operator id in charge to reconcile the Integration
- if e.Integration.Annotations != nil && e.Integration.Annotations[v1.OperatorIDAnnotation] != "" {
+ if v1.GetOperatorIDAnnotation(e.Integration) != "" {
if defaultPlatform.Annotations == nil {
defaultPlatform.Annotations = make(map[string]string)
}
- defaultPlatform.Annotations[v1.OperatorIDAnnotation] = e.Integration.Annotations[v1.OperatorIDAnnotation]
+ defaultPlatform.SetOperatorID(v1.GetOperatorIDAnnotation(e.Integration))
}
pl = &defaultPlatform
e.Resources.Add(pl)
diff --git a/pkg/util/digest/digest.go b/pkg/util/digest/digest.go
index 1ddda2059..3653b6ed9 100644
--- a/pkg/util/digest/digest.go
+++ b/pkg/util/digest/digest.go
@@ -46,6 +46,12 @@ func ComputeForIntegration(integration *v1.Integration) (string, error) {
if _, err := hash.Write([]byte(integration.Status.Version)); err != nil {
return "", err
}
+
+ // Integration operator id is relevant
+ if _, err := hash.Write([]byte(v1.GetOperatorIDAnnotation(integration))); err != nil {
+ return "", err
+ }
+
// Integration Kit is relevant
if integration.Spec.IntegrationKit != nil {
if _, err := hash.Write([]byte(fmt.Sprintf("%s/%s", integration.Spec.IntegrationKit.Namespace, integration.Spec.IntegrationKit.Name))); err != nil {
[camel-k] 05/17: Fix #2177: Ensure unique operator id during install
Posted by as...@apache.org.
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 656bb06729c41056ed0e7e90c1a554279f468031
Author: Christoph Deppisch <cd...@redhat.com>
AuthorDate: Thu Jun 2 16:49:04 2022 +0200
Fix #2177: Ensure unique operator id during install
- Make sure to not install same operator id twice
- Users must use --force option to overwrite existing operator with given id
- Searches for all integration platforms in any namespace and verify that platform name does not exist
---
pkg/cmd/install.go | 37 ++++++++++++++++++++++++++++++++-----
pkg/platform/platform.go | 21 +++++++++++++++++++++
2 files changed, 53 insertions(+), 5 deletions(-)
diff --git a/pkg/cmd/install.go b/pkg/cmd/install.go
index 0287d69f5..368eaeb31 100644
--- a/pkg/cmd/install.go
+++ b/pkg/cmd/install.go
@@ -20,12 +20,14 @@ package cmd
import (
"context"
"fmt"
+ "io"
"os"
"regexp"
"strconv"
"strings"
"time"
+ platformutil "github.com/apache/camel-k/pkg/platform"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/viper"
@@ -289,6 +291,11 @@ func (o *installCmdOptions) install(cobraCmd *cobra.Command, _ []string) error {
fmt.Fprintln(cobraCmd.OutOrStdout(), "Camel K cluster setup completed successfully")
}
} else {
+ operatorID, err := getOperatorID(o.EnvVars)
+ if err != nil {
+ return err
+ }
+
c, err := o.GetCmdClient()
if err != nil {
return err
@@ -296,7 +303,18 @@ func (o *installCmdOptions) install(cobraCmd *cobra.Command, _ []string) error {
namespace := o.Namespace
+ platformName := platformutil.DefaultPlatformName
+ if operatorID != "" {
+ platformName = operatorID
+ }
+
if !o.SkipOperatorSetup && !installViaOLM {
+ if ok, err := isInstallAllowed(o.Context, c, platformName, o.Force, cobraCmd.OutOrStdout()); err != nil {
+ return err
+ } else if !ok {
+ return errors.New(fmt.Sprintf("installation not allowed because operator with id '%s' already exists, use the --force option to skip this check", platformName))
+ }
+
cfg := install.OperatorConfiguration{
CustomImage: o.OperatorImage,
CustomImagePullPolicy: o.OperatorImagePullPolicy,
@@ -343,11 +361,7 @@ func (o *installCmdOptions) install(cobraCmd *cobra.Command, _ []string) error {
fmt.Fprintln(cobraCmd.OutOrStdout(), "Camel K operator registry setup skipped")
}
- operatorID, err := getOperatorID(o.EnvVars)
- if err != nil {
- return err
- }
- platform, err := install.NewPlatform(o.Context, c, o.ClusterType, o.SkipRegistrySetup, o.registry, operatorID)
+ platform, err := install.NewPlatform(o.Context, c, o.ClusterType, o.SkipRegistrySetup, o.registry, platformName)
if err != nil {
return err
}
@@ -505,6 +519,19 @@ func (o *installCmdOptions) install(cobraCmd *cobra.Command, _ []string) error {
return nil
}
+func isInstallAllowed(ctx context.Context, c client.Client, operatorID string, force bool, out io.Writer) (bool, error) {
+ // find existing platform with given name in any namespace
+ pl, err := platformutil.LookupForPlatformName(ctx, c, operatorID)
+
+ if pl != nil && force {
+ fmt.Fprintln(out, fmt.Sprintf("Overwriting existing operator with id '%s'", operatorID))
+ return true, nil
+ }
+
+ // only allow installation when platform with given name is not found
+ return pl == nil, err
+}
+
func getOperatorID(vars []string) (string, error) {
envs, _, _, err := env.ParseEnv(vars, nil)
if err != nil {
diff --git a/pkg/platform/platform.go b/pkg/platform/platform.go
index affba22b6..8d27391e4 100644
--- a/pkg/platform/platform.go
+++ b/pkg/platform/platform.go
@@ -31,6 +31,27 @@ const (
DefaultPlatformName = "camel-k"
)
+// LookupForPlatformName finds integration platform with given operator id as name in any namespace
+func LookupForPlatformName(ctx context.Context, c k8sclient.Reader, name string) (*v1.IntegrationPlatform, error) {
+ platformList := v1.NewIntegrationPlatformList()
+
+ // get all integration platform instances on the cluster
+ err := c.List(ctx, &platformList)
+ if err != nil {
+ return nil, err
+ }
+
+ // Check if platform with same name as given operator id already exists
+ for _, pl := range platformList.Items {
+ if pl.Name == name {
+ // platform already exists installation not allowed
+ return &pl, nil
+ }
+ }
+
+ return nil, nil
+}
+
func GetForResource(ctx context.Context, c k8sclient.Reader, o k8sclient.Object) (*v1.IntegrationPlatform, error) {
return GetOrFindForResource(ctx, c, o, true)
}
[camel-k] 15/17: fix(#2177): Add `-x` shorthand to `--operator-id` kamel CLI option
Posted by as...@apache.org.
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 a1f6fc77b45e8aa039d278c5804246b22e6e96a2
Author: Christoph Deppisch <cd...@redhat.com>
AuthorDate: Fri Jul 1 09:27:35 2022 +0200
fix(#2177): Add `-x` shorthand to `--operator-id` kamel CLI option
---
docs/modules/ROOT/pages/architecture/operator.adoc | 4 ++--
pkg/cmd/bind.go | 2 +-
pkg/cmd/install.go | 2 +-
pkg/cmd/run.go | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/docs/modules/ROOT/pages/architecture/operator.adoc b/docs/modules/ROOT/pages/architecture/operator.adoc
index 252487f21..2a3570705 100644
--- a/docs/modules/ROOT/pages/architecture/operator.adoc
+++ b/docs/modules/ROOT/pages/architecture/operator.adoc
@@ -50,7 +50,7 @@ Since the go language does not yet support generics, there is an `Action` defini
== Operator resource mapping
-By default the Camel K operator (global mode) will manage all Camel K resources on the cluster doing the reconciliation loops for the resources in order to apply the mentioned state machine.
+By default, the Camel K operator (global mode) will manage all Camel K resources on the cluster doing the reconciliation loops for the resources in order to apply the mentioned state machine.
For clusters with multiple Camel K tenants this approach is not going to work as user groups may want to separate the workloads with respective
authentication and authorization schemes. For multi tenancy the Camel K operator uses an operator id that can be applied to resources in the form of
@@ -59,7 +59,7 @@ an annotation. The annotation selects the operator that should handle the resour
This approach allows multiple Camel K installations and operators on the same cluster with each operator handling an explicit set of Camel K resources identified
by the operator id.
-By default the Camel K operator has the id `camel-k` and users with only one single installation on the cluster will not even notice the existence of this identifier. When an administrator wants to add more Camel K operator installations to the cluster the
+By default, the Camel K operator has the id `camel-k` and users with only one single installation on the cluster will not even notice the existence of this identifier. When an administrator wants to add more Camel K operator installations to the cluster the
operator id needs to be unique and resources should be annotated with the respective annotation `camel.apache.org/operator.id={operator-id}`. With this approach we make sure that only one single operator installation manages
a resource at a time.
diff --git a/pkg/cmd/bind.go b/pkg/cmd/bind.go
index 1effdf1e8..d92128cb6 100644
--- a/pkg/cmd/bind.go
+++ b/pkg/cmd/bind.go
@@ -60,7 +60,7 @@ func newCmdBind(rootCmdOptions *RootCmdOptions) (*cobra.Command, *bindCmdOptions
cmd.Flags().Bool("skip-checks", false, "Do not verify the binding for compliance with Kamelets and other Kubernetes resources")
cmd.Flags().StringArray("step", nil, `Add binding steps as Kubernetes resources. Endpoints are expected in the format "[[apigroup/]version:]kind:[namespace/]name", plain Camel URIs or Kamelet name.`)
cmd.Flags().StringArrayP("trait", "t", nil, `Add a trait to the corresponding Integration.`)
- cmd.Flags().String("operator-id", "camel-k", "Operator id selected to manage this Kamelet binding.")
+ cmd.Flags().StringP("operator-id", "x", "camel-k", "Operator id selected to manage this Kamelet binding.")
cmd.Flags().StringArray("annotation", nil, "Add an annotation to the Kamelet binding. E.g. \"--annotation my.company=hello\"")
cmd.Flags().Bool("force", false, "Force creation of Kamelet binding regardless of potential misconfiguration.")
diff --git a/pkg/cmd/install.go b/pkg/cmd/install.go
index 42e76c557..fe39cbbfb 100644
--- a/pkg/cmd/install.go
+++ b/pkg/cmd/install.go
@@ -103,7 +103,7 @@ func newCmdInstall(rootCmdOptions *RootCmdOptions) (*cobra.Command, *installCmdO
cmd.Flags().StringArrayP("property", "p", nil, "Add a camel property")
cmd.Flags().String("runtime-version", "", "Set the camel-k runtime version")
cmd.Flags().String("base-image", "", "Set the base Image used to run integrations")
- cmd.Flags().String("operator-id", "camel-k", "Set the operator id that is used to select the resources this operator should manage")
+ cmd.Flags().StringP("operator-id", "x", "camel-k", "Set the operator id that is used to select the resources this operator should manage")
cmd.Flags().String("operator-image", "", "Set the operator Image used for the operator deployment")
cmd.Flags().String("operator-image-pull-policy", "", "Set the operator ImagePullPolicy used for the operator deployment")
cmd.Flags().String("build-strategy", "", "Set the build strategy")
diff --git a/pkg/cmd/run.go b/pkg/cmd/run.go
index 5298680f7..27df5e167 100644
--- a/pkg/cmd/run.go
+++ b/pkg/cmd/run.go
@@ -106,7 +106,7 @@ func newCmdRun(rootCmdOptions *RootCmdOptions) (*cobra.Command, *runCmdOptions)
cmd.Flags().Bool("sync", false, "Synchronize the local source file with the cluster, republishing at each change")
cmd.Flags().Bool("dev", false, "Enable Dev mode (equivalent to \"-w --logs --sync\")")
cmd.Flags().Bool("use-flows", true, "Write yaml sources as Flow objects in the integration custom resource")
- cmd.Flags().String("operator-id", "camel-k", "Operator id selected to manage this integration.")
+ cmd.Flags().StringP("operator-id", "x", "camel-k", "Operator id selected to manage this integration.")
cmd.Flags().String("profile", "", "Trait profile used for deployment")
cmd.Flags().StringArrayP("trait", "t", nil, "Configure a trait. E.g. \"-t service.enabled=false\"")
cmd.Flags().StringP("output", "o", "", "Output format. One of: json|yaml")
[camel-k] 12/17: Fix #2177: Fix e2e tests
Posted by as...@apache.org.
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 aadc81640465ee170cce2e8e6ff08a29b25d7003
Author: Christoph Deppisch <cd...@redhat.com>
AuthorDate: Thu Jun 9 10:41:18 2022 +0200
Fix #2177: Fix e2e tests
- Handle forbidden error when user lacks privileges to list all integration platforms on cluster during install command
- Use unique operator id when installing operators in test namespaces
- Make sure to run integrations with respective operator id for selected reconciling
- Automatically uninstall operators after the test
- Introduce new GitHub action to install Camel K in global mode
- Run YAKS e2e tests with single global Camel K operator
- Use local operator with id camel-k-preflight in preflight test checks and remove operator once checks are done
- Update deployment ready logic with pod spec comparison based on integration digest and container image only
---
.github/actions/e2e-knative-yaks/action.yml | 9 +-
.github/actions/kamel-install-yaks/action.yml | 5 +-
.github/actions/kamel-install/action.yml | 64 ++++++++++
.github/actions/kamel-install/install.sh | 133 +++++++++++++++++++++
.../actions/kamel-preflight-test/preflight-test.sh | 13 +-
e2e/global/builder/build_test.go | 4 +-
e2e/global/builder/docker_hub_test.go | 5 +-
e2e/global/builder/github_packages_test.go | 5 +-
e2e/global/common/build/incremental_build_test.go | 7 +-
e2e/global/common/build/maven_ca_secret_test.go | 5 +-
e2e/global/common/build/maven_repository_test.go | 5 +-
e2e/global/common/config/config_test.go | 44 +++----
e2e/global/common/cron_test.go | 13 +-
e2e/global/common/integration_fail_test.go | 5 +-
e2e/global/common/kamelet_binding_test.go | 3 +-
e2e/global/common/kamelet_test.go | 5 +-
e2e/global/common/kamelet_update_test.go | 3 +-
e2e/global/common/languages/groovy_test.go | 5 +-
e2e/global/common/languages/init_test_support.go | 2 +-
e2e/global/common/languages/java_test.go | 7 +-
e2e/global/common/languages/js_test.go | 5 +-
e2e/global/common/languages/kotlin_test.go | 5 +-
e2e/global/common/languages/polyglot_test.go | 5 +-
e2e/global/common/languages/xml_test.go | 5 +-
e2e/global/common/languages/yaml_test.go | 5 +-
e2e/global/common/operator_metrics_test.go | 5 +-
e2e/global/common/platformless_run_test.go | 5 +-
e2e/global/common/promote_test.go | 6 +-
e2e/global/common/reset_test.go | 14 +--
e2e/global/common/rest_test.go | 7 +-
e2e/global/common/scale_binding_test.go | 5 +-
e2e/global/common/scale_integration_test.go | 7 +-
e2e/global/common/secondary_platform_test.go | 7 +-
e2e/global/common/structured_logs_test.go | 5 +-
e2e/global/common/traits/affinity_test.go | 9 +-
e2e/global/common/traits/error_handler_test.go | 5 +-
e2e/global/common/traits/health_test.go | 5 +-
e2e/global/common/traits/istio_test.go | 5 +-
e2e/global/common/traits/jolokia_test.go | 5 +-
e2e/global/common/traits/jvm_test.go | 5 +-
e2e/global/common/traits/master_test.go | 9 +-
e2e/global/common/traits/openapi_test.go | 14 +--
e2e/global/common/traits/pdb_test.go | 5 +-
e2e/global/common/traits/pod_test.go | 5 +-
e2e/global/common/traits/prometheus_test.go | 5 +-
e2e/global/common/traits/pull_secret_test.go | 9 +-
e2e/global/common/traits/route_test.go | 13 +-
e2e/global/common/traits/service_test.go | 7 +-
e2e/global/common/traits/toleration_test.go | 9 +-
e2e/global/knative/kamelet_test.go | 5 +-
e2e/global/knative/knative_platform_test.go | 7 +-
e2e/global/knative/knative_test.go | 49 ++++----
e2e/global/knative/openapi_test.go | 14 +--
e2e/global/knative/pod_test.go | 7 +-
e2e/global/registry/registry_maven_wagon_test.go | 18 ++-
.../service_binding_kamelet_test.go | 8 +-
e2e/global/service-binding/service_binding_test.go | 6 +-
e2e/namespace/install/cli/bind_test.go | 11 +-
e2e/namespace/install/cli/delete_test.go | 17 +--
e2e/namespace/install/cli/describe_test.go | 5 +-
e2e/namespace/install/cli/dev_mode_test.go | 48 ++++++--
e2e/namespace/install/cli/dump_test.go | 5 +-
e2e/namespace/install/cli/get_test.go | 9 +-
e2e/namespace/install/cli/global_kamelet_test.go | 12 +-
e2e/namespace/install/cli/global_test.go | 26 ++--
e2e/namespace/install/cli/install_test.go | 25 ++--
e2e/namespace/install/cli/log_test.go | 5 +-
e2e/namespace/install/cli/run_test.go | 19 +--
e2e/namespace/install/cli/uninstall_test.go | 22 ++--
e2e/namespace/install/environment_test.go | 9 +-
e2e/namespace/install/maven_http_proxy_test.go | 9 +-
.../install/operator_id_filtering_test.go | 14 ++-
e2e/namespace/native/native_test.go | 7 +-
e2e/namespace/upgrade/cli_upgrade_test.go | 10 +-
e2e/namespace/upgrade/olm_upgrade_test.go | 8 +-
e2e/support/test_support.go | 121 +++++++++++++++----
e2e/support/util/dump.go | 8 ++
.../common/apache-kamelet-catalog/yaks-config.yaml | 6 +-
e2e/yaks/common/kamelet-beans/yaks-config.yaml | 6 +-
.../kamelet-binding-autoload/yaks-config.yaml | 6 +-
.../common/kamelet-binding-broker/yaks-config.yaml | 6 +-
.../common/kamelet-binding-http/yaks-config.yaml | 6 +-
.../yaks-config.yaml | 6 +-
e2e/yaks/common/kamelet-binding/yaks-config.yaml | 6 +-
.../kamelet-no-properties/kamelet-no-props.feature | 1 -
.../common/kamelet-no-properties/yaks-config.yaml | 6 +-
e2e/yaks/common/kamelet-steps/yaks-config.yaml | 6 +-
e2e/yaks/common/kamelet/yaks-config.yaml | 6 +-
e2e/yaks/common/knative-broker/yaks-config.yaml | 6 +-
.../common/knative-sinkbinding/yaks-config.yaml | 6 +-
pkg/cmd/install.go | 6 +-
pkg/cmd/operator.go | 3 +-
pkg/cmd/uninstall.go | 4 +-
pkg/controller/integration/monitor.go | 45 ++++++-
pkg/platform/operator.go | 7 +-
pkg/platform/platform.go | 16 +--
pkg/trait/container.go | 3 +-
pkg/trait/pod_test.go | 5 +-
pkg/util/digest/digest.go | 4 +
99 files changed, 854 insertions(+), 354 deletions(-)
diff --git a/.github/actions/e2e-knative-yaks/action.yml b/.github/actions/e2e-knative-yaks/action.yml
index a6f18c458..56d13850a 100644
--- a/.github/actions/e2e-knative-yaks/action.yml
+++ b/.github/actions/e2e-knative-yaks/action.yml
@@ -94,7 +94,7 @@ runs:
uses: ./.github/actions/kamel-install-yaks
with:
image-name: "docker.io/yaks/yaks"
- version: 0.11.0-202204210858
+ version: 0.11.0-202206130041
- id: report-problematic
name: List Tests Marked As Problematic
@@ -116,6 +116,13 @@ runs:
-v "${{ steps.build-kamel.outputs.build-binary-local-image-version }}" \
-x "${{ env.CAMEL_K_TEST_SAVE_FAILED_TEST_NAMESPACE }}"
+ - id: it-report
+ name: YAKS Report
+ if: ${{ failure() }}
+ shell: bash
+ run: |
+ yaks report
+
- name: Cleanup
uses: ./.github/actions/kamel-cleanup
if: ${{ always() }}
diff --git a/.github/actions/kamel-install-yaks/action.yml b/.github/actions/kamel-install-yaks/action.yml
index 2c1590089..39f0f2f0b 100644
--- a/.github/actions/kamel-install-yaks/action.yml
+++ b/.github/actions/kamel-install-yaks/action.yml
@@ -21,7 +21,7 @@ description: 'Install YAKS artifacts'
inputs:
version:
description: "The YAKS version"
- default: 0.8.0
+ default: 0.10.0
required: false
image-name:
description: "The YAKS operator image name"
@@ -49,3 +49,6 @@ runs:
shell: bash
run: |
yaks install --operator-image ${{ inputs.image-name }}:${{ inputs.version }}
+
+ kubectl wait --for=condition=available --timeout=180s deployment/yaks-operator
+ kubectl wait --for condition=Ready --timeout=180s pod -l app=yaks
diff --git a/.github/actions/kamel-install/action.yml b/.github/actions/kamel-install/action.yml
new file mode 100644
index 000000000..235a78801
--- /dev/null
+++ b/.github/actions/kamel-install/action.yml
@@ -0,0 +1,64 @@
+# ---------------------------------------------------------------------------
+# 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.
+# ---------------------------------------------------------------------------
+
+name: kamel-install
+description: 'Execute kamel to install the Camel K operator'
+
+inputs:
+ kube-admin-user-ctx:
+ description: "The administration user context of the cluster"
+ required: true
+ build-catalog-source:
+ description: "The name of the bundle catalog (only installed in the cluster if OLM is used)"
+ required: false
+ image-namespace:
+ description: 'Namespace in which the image is stored'
+ required: true
+ image-registry-host:
+ description: 'Location of image registry host'
+ required: true
+ image-name:
+ description: 'Reference of the camel-k image'
+ required: true
+ image-registry-insecure:
+ description: "Whether the registry is insecure"
+ required: true
+ image-version:
+ description: "Reference of the camel-k image version"
+ required: true
+
+runs:
+ using: "composite"
+ steps:
+ - id: execute-kamel
+ name: Install Camel K
+ shell: bash
+ run: |
+ ./.github/actions/kamel-install/install.sh \
+ -a "${{ inputs.kube-admin-user-ctx }}" \
+ -c "${{ inputs.build-catalog-source }}" \
+ -i "${{ inputs.image-namespace }}" \
+ -l "${{ inputs.image-registry-host }}" \
+ -n "${{ inputs.image-name }}" \
+ -s "${{ inputs.image-registry-insecure }}" \
+ -v "${{ inputs.image-version }}"
+
+ - id: post-execution
+ shell: bash
+ run: |
+ rm -f /tmp/config
+ export -n KUBECONFIG
diff --git a/.github/actions/kamel-install/install.sh b/.github/actions/kamel-install/install.sh
new file mode 100755
index 000000000..3cc1ba5da
--- /dev/null
+++ b/.github/actions/kamel-install/install.sh
@@ -0,0 +1,133 @@
+#!/bin/bash
+
+# ---------------------------------------------------------------------------
+# 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.
+# ---------------------------------------------------------------------------
+
+####
+#
+# Install Camel K using the admin context
+#
+####
+
+set -e
+
+while getopts ":a:c:i:l:n:s:v:" opt; do
+ case "${opt}" in
+ a)
+ KUBE_ADMIN_CTX=${OPTARG}
+ ;;
+ c)
+ BUILD_CATALOG_SOURCE=${OPTARG}
+ ;;
+ i)
+ IMAGE_NAMESPACE=${OPTARG}
+ ;;
+ l)
+ REGISTRY_PULL_HOST=${OPTARG}
+ ;;
+ n)
+ IMAGE_NAME=${OPTARG}
+ ;;
+ s)
+ REGISTRY_INSECURE=${OPTARG}
+ ;;
+ v)
+ IMAGE_VERSION=${OPTARG}
+ ;;
+ :)
+ echo "ERROR: Option -$OPTARG requires an argument"
+ exit 1
+ ;;
+ \?)
+ echo "ERROR: Invalid option -$OPTARG"
+ exit 1
+ ;;
+ esac
+done
+shift $((OPTIND-1))
+
+if [ -z "${KUBE_ADMIN_CTX}" ]; then
+ echo "Error: kube-admin-user-ctx not defined"
+ exit 1
+fi
+
+if [ -z "${IMAGE_NAME}" ]; then
+ echo "Error: local-image-name not defined"
+ exit 1
+fi
+
+if [ -z "${IMAGE_VERSION}" ]; then
+ echo "Error: local-image-version not defined"
+ exit 1
+fi
+
+if [ -z "${IMAGE_NAMESPACE}" ]; then
+ echo "Error: image-namespace not defined"
+ exit 1
+fi
+
+if [ -z "${REGISTRY_PULL_HOST}" ]; then
+ echo "Error: image-registry-pull-host not defined"
+ exit 1
+fi
+
+if [ -z "${REGISTRY_INSECURE}" ]; then
+ echo "Error: image-registry-insecure not defined"
+ exit 1
+fi
+
+# Cluster environment
+export CUSTOM_IMAGE=${IMAGE_NAME}
+export CUSTOM_VERSION=${IMAGE_VERSION}
+
+#
+# If bundle has been built and installed then use it
+#
+if [ -n "${BUILD_CATALOG_SOURCE}" ]; then
+ export KAMEL_INSTALL_OLM_SOURCE_NAMESPACE=${IMAGE_NAMESPACE}
+ export KAMEL_INSTALL_OLM_SOURCE=${BUILD_CATALOG_SOURCE}
+fi
+
+export KAMEL_INSTALL_MAVEN_REPOSITORIES=$(make get-staging-repo)
+export KAMEL_INSTALL_REGISTRY=${REGISTRY_PULL_HOST}
+export KAMEL_INSTALL_REGISTRY_INSECURE=${REGISTRY_INSECURE}
+export KAMEL_INSTALL_OPERATOR_IMAGE=${CUSTOM_IMAGE}:${CUSTOM_VERSION}
+
+# Will only have an effect if olm=false
+# since, for OLM, the csv determines the policy.
+# (see kamel-build-bundle/build-bundle-image.sh)
+export KAMEL_INSTALL_OPERATOR_IMAGE_PULL_POLICY="Always"
+
+#
+# Get current context
+#
+ctx=$(kubectl config current-context)
+
+#
+# Need to be admin so switch to the admin context
+#
+kubectl config use-context "${KUBE_ADMIN_CTX}"
+
+#
+# Ensure built binary CRDs are always installed by turning off olm
+#
+kamel install --global --olm=false
+
+#
+# Change back to original context
+#
+kubectl config use-context "${ctx}"
diff --git a/.github/actions/kamel-preflight-test/preflight-test.sh b/.github/actions/kamel-preflight-test/preflight-test.sh
index f62e6fa69..ead05e1d7 100755
--- a/.github/actions/kamel-preflight-test/preflight-test.sh
+++ b/.github/actions/kamel-preflight-test/preflight-test.sh
@@ -198,9 +198,9 @@ export KAMEL_INSTALL_OPERATOR_IMAGE=${CUSTOM_IMAGE}:${CUSTOM_VERSION}
export KAMEL_INSTALL_OPERATOR_IMAGE_PULL_POLICY="Always"
#
-# Install the operator
+# Install the operator to local namespace
#
-kamel install -n ${NAMESPACE} --olm=${has_olm}
+kamel install -n ${NAMESPACE} --olm=${has_olm} --global=false --operator-id=camel-k-preflight
if [ $? != 0 ]; then
echo "Error: kamel install returned an error."
delns "${NAMESPACE}"
@@ -284,6 +284,15 @@ if [ $? != 0 ]; then
exit 1
fi
+#
+# Remove the operator from local namespace
+#
+kamel uninstall -n ${NAMESPACE}
+if [ $? != 0 ]; then
+ echo "Error: kamel uninstall returned an error."
+ exit 1
+fi
+
sleep 3
echo "Preflight Test: Success"
diff --git a/e2e/global/builder/build_test.go b/e2e/global/builder/build_test.go
index 60f548e9f..4e4abfb76 100644
--- a/e2e/global/builder/build_test.go
+++ b/e2e/global/builder/build_test.go
@@ -23,6 +23,7 @@ limitations under the License.
package builder
import (
+ "fmt"
"os"
"testing"
"time"
@@ -80,7 +81,8 @@ func doKitFullBuild(t *testing.T, name string, memoryLimit string, buildTimeout
args = append(args, "--operator-resources", "limits.memory="+memoryLimit)
}
- Expect(KamelInstall(ns, args...).Execute()).To(Succeed())
+ operatorID := fmt.Sprintf("camel-k-%s", ns)
+ Expect(KamelInstallWithID(operatorID, ns, args...).Execute()).To(Succeed())
buildKitArgs := []string{"kit", "create", name, "-n", ns}
for _, dependency := range options.dependencies {
diff --git a/e2e/global/builder/docker_hub_test.go b/e2e/global/builder/docker_hub_test.go
index 6a2903736..b838c988f 100644
--- a/e2e/global/builder/docker_hub_test.go
+++ b/e2e/global/builder/docker_hub_test.go
@@ -40,7 +40,8 @@ func TestRunWithDockerHubRegistry(t *testing.T) {
t.Skip("no docker hub credentials: skipping")
} else {
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns,
+ operatorID := "camel-k-docker-hub"
+ Expect(KamelInstallWithID(operatorID, ns,
"--registry", "docker.io",
"--organization", user,
"--registry-auth-username", user,
@@ -48,7 +49,7 @@ func TestRunWithDockerHubRegistry(t *testing.T) {
"--cluster-type", "kubernetes").
Execute()).To(Succeed())
- Expect(Kamel("run", "-n", ns, "files/groovy.groovy").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/groovy.groovy").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "groovy"), TestTimeoutLong).Should(Equal(v1.PodRunning))
Eventually(IntegrationLogs(ns, "groovy"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
Eventually(IntegrationPodImage(ns, "groovy"), TestTimeoutShort).Should(HavePrefix("docker.io"))
diff --git a/e2e/global/builder/github_packages_test.go b/e2e/global/builder/github_packages_test.go
index 781e7deb1..6d2554d44 100644
--- a/e2e/global/builder/github_packages_test.go
+++ b/e2e/global/builder/github_packages_test.go
@@ -41,7 +41,8 @@ func TestRunWithGithubPackagesRegistry(t *testing.T) {
t.Skip("no github packages data: skipping")
} else {
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns,
+ operatorID := "camel-k-github-registry"
+ Expect(KamelInstallWithID(operatorID, ns,
"--registry", "docker.pkg.github.com",
"--organization", repo,
"--registry-auth-username", user,
@@ -49,7 +50,7 @@ func TestRunWithGithubPackagesRegistry(t *testing.T) {
"--cluster-type", "kubernetes").
Execute()).To(Succeed())
- Expect(Kamel("run", "-n", ns, "files/groovy.groovy").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/groovy.groovy").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "groovy"), TestTimeoutLong).Should(Equal(v1.PodRunning))
Eventually(IntegrationLogs(ns, "groovy"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
Eventually(IntegrationPodImage(ns, "groovy"), TestTimeoutShort).Should(HavePrefix("docker.pkg.github.com"))
diff --git a/e2e/global/common/build/incremental_build_test.go b/e2e/global/common/build/incremental_build_test.go
index 88f373b25..2f31c8889 100644
--- a/e2e/global/common/build/incremental_build_test.go
+++ b/e2e/global/common/build/incremental_build_test.go
@@ -36,10 +36,11 @@ import (
func TestRunIncrementalBuild(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns).Execute()).To(Succeed())
+ operatorID := "camel-k-incremental-build"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
name := "java"
- Expect(Kamel("run", "-n", ns, "files/Java.java",
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
"--name", name,
).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
@@ -50,7 +51,7 @@ func TestRunIncrementalBuild(t *testing.T) {
// Another integration that should be built on top of the previous IntegrationKit
// just add a new random dependency
name2 := "java2"
- Expect(Kamel("run", "-n", ns, "files/Java.java",
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
"--name", name2,
"-d", "camel-zipfile",
).Execute()).To(Succeed())
diff --git a/e2e/global/common/build/maven_ca_secret_test.go b/e2e/global/common/build/maven_ca_secret_test.go
index 49e388432..386b443dc 100644
--- a/e2e/global/common/build/maven_ca_secret_test.go
+++ b/e2e/global/common/build/maven_ca_secret_test.go
@@ -420,7 +420,8 @@ ProxyPreserveHost On
})).To(Succeed())
// Install Camel K with the Maven Central Nexus proxy and the corresponding Maven CA secret
- Expect(KamelInstall(ns,
+ operatorID := "camel-k-maven-ca-secret"
+ Expect(KamelInstallWithID(operatorID, ns,
"--maven-repository", fmt.Sprintf(`https://%s/repository/maven-public/@id=central-internal@mirrorOf=central`, hostname),
"--maven-repository", fmt.Sprintf(`https://%s/repository/%s/%s`, hostname, stagingRepository.ID, strings.Join(getRepositoryAttributes(stagingRepository), "")),
"--maven-ca-secret", secret.Name+"/"+corev1.TLSCertKey,
@@ -432,7 +433,7 @@ ProxyPreserveHost On
// Run the Integration
name := "java"
- Expect(Kamel("run", "-n", ns, "files/Java.java", "--name", name).Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", name).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
diff --git a/e2e/global/common/build/maven_repository_test.go b/e2e/global/common/build/maven_repository_test.go
index abfce0b0a..7cee488b7 100644
--- a/e2e/global/common/build/maven_repository_test.go
+++ b/e2e/global/common/build/maven_repository_test.go
@@ -35,10 +35,11 @@ import (
func TestRunExtraRepository(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns).Execute()).To(Succeed())
+ operatorID := "camel-k-extra-repository"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
name := "java"
- Expect(Kamel("run", "-n", ns, "files/Java.java",
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
"--maven-repository", "https://maven.repository.redhat.com/ga@id=redhat",
"--dependency", "mvn:jakarta.annotation:jakarta.annotation-api:1.3.5.redhat-00002",
"--name", name,
diff --git a/e2e/global/common/config/config_test.go b/e2e/global/common/config/config_test.go
index e34902474..4dca6c1fd 100644
--- a/e2e/global/common/config/config_test.go
+++ b/e2e/global/common/config/config_test.go
@@ -23,6 +23,7 @@ limitations under the License.
package resources
import (
+ "fmt"
"io/ioutil"
"testing"
@@ -38,12 +39,13 @@ import (
func TestRunConfigExamples(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns).Execute()).To(Succeed())
+ operatorID := fmt.Sprintf("camel-k-%s", ns)
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
// Properties
t.Run("Simple property", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "./files/property-route.groovy", "-p", "my.message=test-property").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "./files/property-route.groovy", "-p", "my.message=test-property").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "property-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "property-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, "property-route"), TestTimeoutShort).Should(ContainSubstring("test-property"))
@@ -51,7 +53,7 @@ func TestRunConfigExamples(t *testing.T) {
})
t.Run("Property file", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "./files/property-file-route.groovy", "--property", "file:./files/my.properties").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "./files/property-file-route.groovy", "--property", "file:./files/my.properties").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "property-file-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "property-file-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, "property-file-route"), TestTimeoutShort).Should(ContainSubstring("hello world"))
@@ -59,7 +61,7 @@ func TestRunConfigExamples(t *testing.T) {
})
t.Run("Property precedence", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "./files/property-file-route.groovy", "-p", "my.key.2=universe", "-p", "file:./files/my.properties").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "./files/property-file-route.groovy", "-p", "my.key.2=universe", "-p", "file:./files/my.properties").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "property-file-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "property-file-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, "property-file-route"), TestTimeoutShort).Should(ContainSubstring("hello universe"))
@@ -80,7 +82,7 @@ func TestRunConfigExamples(t *testing.T) {
NewPlainTextConfigmap(ns, "my-cm-multi", cmDataMulti)
t.Run("Config configmap", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "./files/config-configmap-route.groovy", "--config", "configmap:my-cm").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "./files/config-configmap-route.groovy", "--config", "configmap:my-cm").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "config-configmap-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "config-configmap-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, "config-configmap-route"), TestTimeoutShort).Should(ContainSubstring(cmData["my-configmap-key"]))
@@ -90,7 +92,7 @@ func TestRunConfigExamples(t *testing.T) {
t.Run("Resource configmap", func(t *testing.T) {
// We can reuse the configmap created previously
- Expect(Kamel("run", "-n", ns, "./files/resource-configmap-route.groovy", "--resource", "configmap:my-cm").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "./files/resource-configmap-route.groovy", "--resource", "configmap:my-cm").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "resource-configmap-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "resource-configmap-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, "resource-configmap-route"), TestTimeoutShort).Should(ContainSubstring(cmData["my-configmap-key"]))
@@ -100,7 +102,7 @@ func TestRunConfigExamples(t *testing.T) {
t.Run("Resource configmap with destination", func(t *testing.T) {
// We can reuse the configmap created previously
- Expect(Kamel("run", "-n", ns, "./files/resource-configmap-location-route.groovy", "--resource", "configmap:my-cm@/tmp/app").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "./files/resource-configmap-location-route.groovy", "--resource", "configmap:my-cm@/tmp/app").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "resource-configmap-location-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "resource-configmap-location-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, "resource-configmap-location-route"), TestTimeoutShort).Should(ContainSubstring(cmData["my-configmap-key"]))
@@ -110,7 +112,7 @@ func TestRunConfigExamples(t *testing.T) {
t.Run("Resource configmap with filtered key and destination", func(t *testing.T) {
// We'll use the configmap contaning 2 values filtering only 1 key
- Expect(Kamel("run", "-n", ns, "./files/resource-configmap-key-location-route.groovy", "--resource", "configmap:my-cm-multi/my-configmap-key-2@/tmp/app/test.txt").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "./files/resource-configmap-key-location-route.groovy", "--resource", "configmap:my-cm-multi/my-configmap-key-2@/tmp/app/test.txt").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "resource-configmap-key-location-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "resource-configmap-key-location-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, "resource-configmap-key-location-route"), TestTimeoutShort).ShouldNot(ContainSubstring(cmDataMulti["my-configmap-key"]))
@@ -124,7 +126,7 @@ func TestRunConfigExamples(t *testing.T) {
NewPlainTextConfigmap(ns, "my-cm-properties", cmDataProps)
t.Run("Config configmap as property file", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "./files/config-configmap-properties-route.groovy", "--config", "configmap:my-cm-properties").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "./files/config-configmap-properties-route.groovy", "--config", "configmap:my-cm-properties").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "config-configmap-properties-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "config-configmap-properties-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, "config-configmap-properties-route"), TestTimeoutShort).Should(ContainSubstring("hello world"))
@@ -139,7 +141,7 @@ func TestRunConfigExamples(t *testing.T) {
NewPlainTextSecret(ns, "my-sec", secData)
t.Run("Config secret", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "./files/config-secret-route.groovy", "--config", "secret:my-sec").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "./files/config-secret-route.groovy", "--config", "secret:my-sec").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "config-secret-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "config-secret-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, "config-secret-route"), TestTimeoutShort).Should(ContainSubstring(secData["my-secret-key"]))
@@ -147,7 +149,7 @@ func TestRunConfigExamples(t *testing.T) {
})
t.Run("Resource secret", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "./files/resource-secret-route.groovy", "--resource", "secret:my-sec").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "./files/resource-secret-route.groovy", "--resource", "secret:my-sec").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "resource-secret-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "resource-secret-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, "resource-secret-route"), TestTimeoutShort).Should(ContainSubstring(secData["my-secret-key"]))
@@ -157,7 +159,7 @@ func TestRunConfigExamples(t *testing.T) {
// Config File
t.Run("Plain text configuration file", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "./files/config-file-route.groovy", "--config", "file:./files/resources-data.txt").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "./files/config-file-route.groovy", "--config", "file:./files/resources-data.txt").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "config-file-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "config-file-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, "config-file-route"), TestTimeoutShort).Should(ContainSubstring("the file body"))
@@ -168,7 +170,7 @@ func TestRunConfigExamples(t *testing.T) {
// Resource File
t.Run("Plain text resource file", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "./files/resource-file-route.groovy", "--resource", "file:./files/resources-data.txt").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "./files/resource-file-route.groovy", "--resource", "file:./files/resources-data.txt").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "resource-file-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "resource-file-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, "resource-file-route"), TestTimeoutShort).Should(ContainSubstring("the file body"))
@@ -177,7 +179,7 @@ func TestRunConfigExamples(t *testing.T) {
})
t.Run("Plain text resource file with destination path", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "./files/resource-file-location-route.groovy", "--resource", "file:./files/resources-data.txt@/tmp/file.txt").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "./files/resource-file-location-route.groovy", "--resource", "file:./files/resources-data.txt@/tmp/file.txt").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "resource-file-location-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "resource-file-location-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, "resource-file-location-route"), TestTimeoutShort).Should(ContainSubstring("the file body"))
@@ -186,7 +188,7 @@ func TestRunConfigExamples(t *testing.T) {
})
t.Run("Binary (zip) resource file", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "./files/resource-file-binary-route.groovy", "--resource", "file:./files/resources-data.zip", "-d", "camel-zipfile").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "./files/resource-file-binary-route.groovy", "--resource", "file:./files/resources-data.zip", "-d", "camel-zipfile").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "resource-file-binary-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "resource-file-binary-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, "resource-file-binary-route"), TestTimeoutShort).Should(ContainSubstring("the file body"))
@@ -201,7 +203,7 @@ func TestRunConfigExamples(t *testing.T) {
expectedBytes, err := gzip.CompressBase64([]byte(source))
assert.Nil(t, err)
- Expect(Kamel("run", "-n", ns, "./files/resource-file-base64-encoded-route.groovy", "--resource", "file:./files/resources-data.txt", "--compression=true").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "./files/resource-file-base64-encoded-route.groovy", "--resource", "file:./files/resources-data.txt", "--compression=true").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "resource-file-base64-encoded-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "resource-file-base64-encoded-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, "resource-file-base64-encoded-route"), TestTimeoutShort).Should(ContainSubstring(string(expectedBytes)))
@@ -210,7 +212,7 @@ func TestRunConfigExamples(t *testing.T) {
})
t.Run("Plain text resource file with same content", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "./files/resource-file-route.groovy", "--resource", "file:./files/resources-data.txt",
+ Expect(KamelRunWithID(operatorID, ns, "./files/resource-file-route.groovy", "--resource", "file:./files/resources-data.txt",
"--resource", "file:./files/resources-data-same.txt").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "resource-file-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "resource-file-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
@@ -221,7 +223,7 @@ func TestRunConfigExamples(t *testing.T) {
// Build-Properties
t.Run("Build time property", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "./files/build-property-route.groovy", "--build-property", "quarkus.application.name=my-super-application").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "./files/build-property-route.groovy", "--build-property", "quarkus.application.name=my-super-application").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "build-property-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "build-property-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, "build-property-route"), TestTimeoutShort).Should(ContainSubstring("my-super-application"))
@@ -230,7 +232,7 @@ func TestRunConfigExamples(t *testing.T) {
// We need to check also that the property (which is available in the IntegrationKit) is correctly replaced and we don't reuse the same kit
t.Run("Build time property updated", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "./files/build-property-route.groovy", "--name", "build-property-route-updated",
+ Expect(KamelRunWithID(operatorID, ns, "./files/build-property-route.groovy", "--name", "build-property-route-updated",
"--build-property", "quarkus.application.name=my-super-application-updated").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "build-property-route-updated"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "build-property-route-updated", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
@@ -242,7 +244,7 @@ func TestRunConfigExamples(t *testing.T) {
// Build-Properties file
t.Run("Build time property file", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "./files/build-property-file-route.groovy", "--build-property", "file:./files/quarkus.properties").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "./files/build-property-file-route.groovy", "--build-property", "file:./files/quarkus.properties").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "build-property-file-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "build-property-file-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, "build-property-file-route"), TestTimeoutShort).Should(ContainSubstring("my-super-application"))
@@ -250,7 +252,7 @@ func TestRunConfigExamples(t *testing.T) {
})
t.Run("Build time property file with precedence", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "./files/build-property-file-route.groovy", "--build-property", "quarkus.application.name=my-overridden-application", "--build-property", "file:./files/quarkus.properties").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "./files/build-property-file-route.groovy", "--build-property", "quarkus.application.name=my-overridden-application", "--build-property", "file:./files/quarkus.properties").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "build-property-file-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "build-property-file-route", v1.IntegrationConditionReady), TestTimeoutMedium).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, "build-property-file-route"), TestTimeoutMedium).Should(ContainSubstring("my-overridden-application"))
diff --git a/e2e/global/common/cron_test.go b/e2e/global/common/cron_test.go
index 920501370..26664a423 100644
--- a/e2e/global/common/cron_test.go
+++ b/e2e/global/common/cron_test.go
@@ -47,10 +47,11 @@ func TestRunCronExample(t *testing.T) {
}
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns).Execute()).To(Succeed())
+ operatorID := "camel-k-trait-cronjob"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
t.Run("cron", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "files/cron.yaml").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/cron.yaml").Execute()).To(Succeed())
Eventually(IntegrationCronJob(ns, "cron"), TestTimeoutMedium).ShouldNot(BeNil())
Eventually(IntegrationConditionStatus(ns, "cron", v1.IntegrationConditionReady), TestTimeoutMedium).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, "cron"), TestTimeoutMedium).Should(ContainSubstring("Magicstring!"))
@@ -58,7 +59,7 @@ func TestRunCronExample(t *testing.T) {
})
t.Run("cron-yaml", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "files/cron-yaml.yaml").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/cron-yaml.yaml").Execute()).To(Succeed())
Eventually(IntegrationCronJob(ns, "cron-yaml"), TestTimeoutMedium).ShouldNot(BeNil())
Eventually(IntegrationConditionStatus(ns, "cron-yaml", v1.IntegrationConditionReady), TestTimeoutMedium).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, "cron-yaml"), TestTimeoutMedium).Should(ContainSubstring("Magicstring!"))
@@ -66,7 +67,7 @@ func TestRunCronExample(t *testing.T) {
})
t.Run("cron-timer", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "files/cron-timer.yaml").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/cron-timer.yaml").Execute()).To(Succeed())
Eventually(IntegrationCronJob(ns, "cron-timer"), TestTimeoutMedium).ShouldNot(BeNil())
Eventually(IntegrationConditionStatus(ns, "cron-timer", v1.IntegrationConditionReady), TestTimeoutMedium).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, "cron-timer"), TestTimeoutMedium).Should(ContainSubstring("Magicstring!"))
@@ -74,7 +75,7 @@ func TestRunCronExample(t *testing.T) {
})
t.Run("cron-fallback", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "files/cron-fallback.yaml").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/cron-fallback.yaml").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "cron-fallback"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "cron-fallback", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, "cron-fallback"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
@@ -82,7 +83,7 @@ func TestRunCronExample(t *testing.T) {
})
t.Run("cron-quartz", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "files/cron-quartz.yaml").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/cron-quartz.yaml").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "cron-quartz"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "cron-quartz", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, "cron-quartz"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
diff --git a/e2e/global/common/integration_fail_test.go b/e2e/global/common/integration_fail_test.go
index b84e1ce08..4ae5d2ff2 100644
--- a/e2e/global/common/integration_fail_test.go
+++ b/e2e/global/common/integration_fail_test.go
@@ -36,12 +36,13 @@ import (
func TestBadRouteIntegration(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns).Execute()).To(Succeed())
+ operatorID := "camel-k-bad-route"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
t.Run("run bad java route", func(t *testing.T) {
RegisterTestingT(t)
name := "bad-route"
- Expect(Kamel("run", "-n", ns, "files/BadRoute.java", "--name", name).Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/BadRoute.java", "--name", name).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationPhase(ns, name), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseError))
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionFalse))
diff --git a/e2e/global/common/kamelet_binding_test.go b/e2e/global/common/kamelet_binding_test.go
index 6c34ed138..dab663ac1 100644
--- a/e2e/global/common/kamelet_binding_test.go
+++ b/e2e/global/common/kamelet_binding_test.go
@@ -35,7 +35,8 @@ import (
func TestErrorHandler(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns).Execute()).To(Succeed())
+ operatorID := "camel-k-kamelet-errorhandler"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
Expect(CreateErrorProducerKamelet(ns, "my-own-error-producer-source")()).To(Succeed())
Expect(CreateLogKamelet(ns, "my-own-log-sink")()).To(Succeed())
diff --git a/e2e/global/common/kamelet_test.go b/e2e/global/common/kamelet_test.go
index c1db86e45..d255f7319 100644
--- a/e2e/global/common/kamelet_test.go
+++ b/e2e/global/common/kamelet_test.go
@@ -33,14 +33,15 @@ import (
func TestKameletClasspathLoading(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns).Execute()).To(Succeed())
+ operatorID := "camel-k-kamelet"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
kameletName := "timer-source"
removeKamelet(kameletName, ns)
Eventually(Kamelet(kameletName, ns)).Should(BeNil())
- Expect(Kamel("run", "files/TimerKameletIntegration.java", "-n", ns, "-t", "kamelets.enabled=false",
+ Expect(KamelRunWithID(operatorID, ns, "files/TimerKameletIntegration.java", "-t", "kamelets.enabled=false",
"--resource", "file:files/timer-source.kamelet.yaml@/kamelets/timer-source.kamelet.yaml",
"-p camel.component.kamelet.location=file:/kamelets",
"-d", "camel:yaml-dsl",
diff --git a/e2e/global/common/kamelet_update_test.go b/e2e/global/common/kamelet_update_test.go
index 75c5cbd67..a5e1fc121 100644
--- a/e2e/global/common/kamelet_update_test.go
+++ b/e2e/global/common/kamelet_update_test.go
@@ -39,7 +39,8 @@ func TestBundleKameletUpdate(t *testing.T) {
Expect(createBundleKamelet(ns, "http-sink")()).To(Succeed()) // Going to be replaced
Expect(createUserKamelet(ns, "user-sink")()).To(Succeed()) // Left intact by the operator
- Expect(KamelInstall(ns).Execute()).To(Succeed())
+ operatorID := "camel-k-kamelet-update"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
Eventually(Kamelet("http-sink", ns)).
Should(WithTransform(KameletLabels, HaveKeyWithValue(customLabel, "true")))
diff --git a/e2e/global/common/languages/groovy_test.go b/e2e/global/common/languages/groovy_test.go
index c82a77921..17f8c896a 100644
--- a/e2e/global/common/languages/groovy_test.go
+++ b/e2e/global/common/languages/groovy_test.go
@@ -35,10 +35,11 @@ import (
func TestRunSimpleGroovyExamples(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns).Execute()).To(Succeed())
+ operatorID := "camel-k-examples-groovy"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
t.Run("run groovy", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "files/groovy.groovy").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/groovy.groovy").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "groovy"), TestTimeoutLong).Should(Equal(v1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "groovy", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
Eventually(IntegrationLogs(ns, "groovy"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
diff --git a/e2e/global/common/languages/init_test_support.go b/e2e/global/common/languages/init_test_support.go
index 6ff61152d..923c0badf 100644
--- a/e2e/global/common/languages/init_test_support.go
+++ b/e2e/global/common/languages/init_test_support.go
@@ -42,7 +42,7 @@ func RunInitGeneratedExample(lang camelv1.Language, ns string, t *testing.T) {
fileName := fmt.Sprintf("%s.%s", itName, string(lang)) // e.g. initjava.java
file := path.Join(dir, fileName)
Expect(Kamel("init", file).Execute()).To(Succeed())
- Expect(Kamel("run", "-n", ns, file).Execute()).To(Succeed())
+ Expect(KamelRun(ns, file).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, itName), TestTimeoutLong).Should(Equal(v1.PodRunning))
Eventually(IntegrationLogs(ns, itName), TestTimeoutShort).Should(ContainSubstring(languageInitExpectedString(lang)))
Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
diff --git a/e2e/global/common/languages/java_test.go b/e2e/global/common/languages/java_test.go
index 55fcf1ec9..ec7efd3c1 100644
--- a/e2e/global/common/languages/java_test.go
+++ b/e2e/global/common/languages/java_test.go
@@ -35,10 +35,11 @@ import (
func TestRunSimpleJavaExamples(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns).Execute()).To(Succeed())
+ operatorID := "camel-k-examples-java"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
t.Run("run java", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "files/Java.java").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutLong).Should(Equal(v1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "java", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
Eventually(IntegrationLogs(ns, "java"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
@@ -46,7 +47,7 @@ func TestRunSimpleJavaExamples(t *testing.T) {
})
t.Run("run java with properties", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "files/Prop.java", "--property", "file:files/prop.properties").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/Prop.java", "--property", "file:files/prop.properties").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "prop"), TestTimeoutLong).Should(Equal(v1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "prop", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
Eventually(IntegrationLogs(ns, "prop"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
diff --git a/e2e/global/common/languages/js_test.go b/e2e/global/common/languages/js_test.go
index 8cbaf656a..daeaa3d7d 100644
--- a/e2e/global/common/languages/js_test.go
+++ b/e2e/global/common/languages/js_test.go
@@ -35,10 +35,11 @@ import (
func TestRunSimpleJavaScriptExamples(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns).Execute()).To(Succeed())
+ operatorID := "camel-k-examples-js"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
t.Run("run js", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "files/js.js").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/js.js").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "js"), TestTimeoutLong).Should(Equal(v1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "js", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
Eventually(IntegrationLogs(ns, "js"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
diff --git a/e2e/global/common/languages/kotlin_test.go b/e2e/global/common/languages/kotlin_test.go
index fd58972c0..6e43a8153 100644
--- a/e2e/global/common/languages/kotlin_test.go
+++ b/e2e/global/common/languages/kotlin_test.go
@@ -35,10 +35,11 @@ import (
func TestRunSimpleKotlinExamples(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns).Execute()).To(Succeed())
+ operatorID := "camel-k-examples-kotlin"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
t.Run("run kotlin", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "files/kotlin.kts").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/kotlin.kts").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "kotlin"), TestTimeoutLong).Should(Equal(v1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "kotlin", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
Eventually(IntegrationLogs(ns, "kotlin"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
diff --git a/e2e/global/common/languages/polyglot_test.go b/e2e/global/common/languages/polyglot_test.go
index 3bbd11002..53a56e2ef 100644
--- a/e2e/global/common/languages/polyglot_test.go
+++ b/e2e/global/common/languages/polyglot_test.go
@@ -35,10 +35,11 @@ import (
func TestRunPolyglotExamples(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns).Execute()).To(Succeed())
+ operatorID := "camel-k-examples-polyglot"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
t.Run("run polyglot", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "--name", "polyglot", "files/js-polyglot.js", "files/yaml-polyglot.yaml").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "--name", "polyglot", "files/js-polyglot.js", "files/yaml-polyglot.yaml").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "polyglot"), TestTimeoutLong).Should(Equal(v1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "polyglot", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
Eventually(IntegrationLogs(ns, "polyglot"), TestTimeoutShort).Should(ContainSubstring("Magicpolyglot-yaml"))
diff --git a/e2e/global/common/languages/xml_test.go b/e2e/global/common/languages/xml_test.go
index 59362cdd5..a332f0af3 100644
--- a/e2e/global/common/languages/xml_test.go
+++ b/e2e/global/common/languages/xml_test.go
@@ -35,10 +35,11 @@ import (
func TestRunSimpleXmlExamples(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns).Execute()).To(Succeed())
+ operatorID := "camel-k-examples-xml"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
t.Run("run xml", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "files/xml.xml").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/xml.xml").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "xml"), TestTimeoutLong).Should(Equal(v1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "xml", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
Eventually(IntegrationLogs(ns, "xml"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
diff --git a/e2e/global/common/languages/yaml_test.go b/e2e/global/common/languages/yaml_test.go
index 09bf8431f..5a754e968 100644
--- a/e2e/global/common/languages/yaml_test.go
+++ b/e2e/global/common/languages/yaml_test.go
@@ -35,10 +35,11 @@ import (
func TestRunSimpleYamlExamples(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns).Execute()).To(Succeed())
+ operatorID := "camel-k-examples-yaml"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
t.Run("run yaml", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "files/yaml.yaml").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(v1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "yaml", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
Eventually(IntegrationLogs(ns, "yaml"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
diff --git a/e2e/global/common/operator_metrics_test.go b/e2e/global/common/operator_metrics_test.go
index 9b3dbd7d6..bd4658cb5 100644
--- a/e2e/global/common/operator_metrics_test.go
+++ b/e2e/global/common/operator_metrics_test.go
@@ -58,8 +58,9 @@ func TestMetrics(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
name := "java"
- Expect(KamelInstall(ns).Execute()).To(Succeed())
- Expect(Kamel("run", "-n", ns, "files/Java.java",
+ operatorID := "camel-k-metrics"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
"-t", "prometheus.enabled=true",
"-t", "prometheus.pod-monitor=false",
).Execute()).To(Succeed())
diff --git a/e2e/global/common/platformless_run_test.go b/e2e/global/common/platformless_run_test.go
index 052172f1e..cd9694c44 100644
--- a/e2e/global/common/platformless_run_test.go
+++ b/e2e/global/common/platformless_run_test.go
@@ -46,12 +46,13 @@ func TestPlatformlessRun(t *testing.T) {
}
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns).Execute()).To(Succeed())
+ operatorID := "camel-k-platform-missing"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
// Delete the platform from the namespace before running the integration
Eventually(DeletePlatform(ns)).Should(BeTrue())
- Expect(Kamel("run", "-n", ns, "files/yaml.yaml").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationLogs(ns, "yaml"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
diff --git a/e2e/global/common/promote_test.go b/e2e/global/common/promote_test.go
index e29af4637..ba9ac85e6 100644
--- a/e2e/global/common/promote_test.go
+++ b/e2e/global/common/promote_test.go
@@ -48,7 +48,7 @@ func TestKamelCLIPromote(t *testing.T) {
NewPlainTextSecret(nsDev, "my-sec", secData)
t.Run("plain integration dev", func(t *testing.T) {
- Expect(Kamel("run", "-n", nsDev, "./files/promote-route.groovy",
+ Expect(KamelRun(nsDev, "./files/promote-route.groovy",
"--config", "configmap:my-cm",
"--config", "secret:my-sec",
).Execute()).To(Succeed())
@@ -60,14 +60,14 @@ func TestKamelCLIPromote(t *testing.T) {
t.Run("kamelet integration dev", func(t *testing.T) {
Expect(CreateTimerKamelet(nsDev, "my-own-timer-source")()).To(Succeed())
- Expect(Kamel("run", "-n", nsDev, "files/timer-kamelet-usage.groovy").Execute()).To(Succeed())
+ Expect(KamelRun(nsDev, "files/timer-kamelet-usage.groovy").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(nsDev, "timer-kamelet-usage"), TestTimeoutMedium).Should(Equal(corev1.PodRunning))
Eventually(IntegrationLogs(nsDev, "timer-kamelet-usage"), TestTimeoutShort).Should(ContainSubstring("Hello world"))
})
t.Run("kamelet binding dev", func(t *testing.T) {
Expect(CreateTimerKamelet(nsDev, "kb-timer-source")()).To(Succeed())
- Expect(Kamel("bind", "kb-timer-source", "log:info", "-p", "source.message=my-kamelet-binding-rocks", "-n", nsDev).Execute()).To(Succeed())
+ Expect(KamelBind(nsDev, "kb-timer-source", "log:info", "-p", "source.message=my-kamelet-binding-rocks").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(nsDev, "kb-timer-source-to-log"), TestTimeoutMedium).Should(Equal(corev1.PodRunning))
Eventually(IntegrationLogs(nsDev, "kb-timer-source-to-log"), TestTimeoutShort).Should(ContainSubstring("my-kamelet-binding-rocks"))
})
diff --git a/e2e/global/common/reset_test.go b/e2e/global/common/reset_test.go
index 9c950ce94..a4cac09ff 100644
--- a/e2e/global/common/reset_test.go
+++ b/e2e/global/common/reset_test.go
@@ -33,12 +33,13 @@ import (
func TestKamelReset(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns).Execute()).To(Succeed())
+ operatorID := "camel-k-cli-reset"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
t.Run("Reset the whole platform", func(t *testing.T) {
name := "yaml1"
- Expect(Kamel("run", "-n", ns, "files/yaml.yaml", "--name", name).Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml", "--name", name).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutMedium).Should(Equal(corev1.PodRunning))
Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
@@ -49,13 +50,11 @@ func TestKamelReset(t *testing.T) {
Expect(Integration(ns, name)()).To(BeNil())
Expect(Kits(ns)()).To(HaveLen(0))
-
})
t.Run("Reset skip-integrations", func(t *testing.T) {
-
name := "yaml2"
- Expect(Kamel("run", "-n", ns, "files/yaml.yaml", "--name", name).Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml", "--name", name).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutMedium).Should(Equal(corev1.PodRunning))
Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
@@ -66,13 +65,11 @@ func TestKamelReset(t *testing.T) {
Expect(Integration(ns, name)()).To(Not(BeNil()))
Expect(Kits(ns)()).To(HaveLen(0))
-
})
t.Run("Reset skip-kits", func(t *testing.T) {
-
name := "yaml3"
- Expect(Kamel("run", "-n", ns, "files/yaml.yaml", "--name", name).Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml", "--name", name).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutMedium).Should(Equal(corev1.PodRunning))
Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
@@ -84,7 +81,6 @@ func TestKamelReset(t *testing.T) {
Expect(Integration(ns, name)()).To(BeNil())
Expect(Kit(ns, kitName)()).To(Not(BeNil()))
-
})
// Clean up
Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
diff --git a/e2e/global/common/rest_test.go b/e2e/global/common/rest_test.go
index 36d80962d..770377fc0 100644
--- a/e2e/global/common/rest_test.go
+++ b/e2e/global/common/rest_test.go
@@ -49,15 +49,16 @@ func TestRunRest(t *testing.T) {
profile = "Kubernetes"
}
- Expect(KamelInstall(ns, "--trait-profile", profile).Execute()).To(Succeed())
- Expect(Kamel("run", "-n", ns, "files/rest-consumer.yaml").Execute()).To(Succeed())
+ operatorID := "camel-k-rest"
+ Expect(KamelInstallWithID(operatorID, ns, "--trait-profile", profile).Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/rest-consumer.yaml").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "rest-consumer"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
t.Run("Service works", func(t *testing.T) {
name := "John"
service := Service(ns, "rest-consumer")
Eventually(service, TestTimeoutShort).ShouldNot(BeNil())
- Expect(Kamel("run", "-n", ns, "files/rest-producer.yaml", "-p", "serviceName=rest-consumer", "-p", "name="+name).Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/rest-producer.yaml", "-p", "serviceName=rest-consumer", "-p", "name="+name).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "rest-producer"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationLogs(ns, "rest-consumer"), TestTimeoutLong).Should(ContainSubstring(fmt.Sprintf("get %s", name)))
Eventually(IntegrationLogs(ns, "rest-producer"), TestTimeoutLong).Should(ContainSubstring(fmt.Sprintf("%s Doe", name)))
diff --git a/e2e/global/common/scale_binding_test.go b/e2e/global/common/scale_binding_test.go
index ad644fcff..2c1cf41d1 100644
--- a/e2e/global/common/scale_binding_test.go
+++ b/e2e/global/common/scale_binding_test.go
@@ -50,8 +50,9 @@ func TestKameletBindingScale(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
name := "binding"
- Expect(KamelInstall(ns, "-w").Execute()).To(Succeed())
- Expect(Kamel("bind", "timer-source?message=HelloBinding", "log-sink", "-n", ns, "--name", name).Execute()).To(Succeed())
+ operatorID := "camel-k-kamelet-scale"
+ Expect(KamelInstallWithID(operatorID, ns, "-w").Execute()).To(Succeed())
+ Expect(KamelBindWithID(operatorID, ns, "timer-source?message=HelloBinding", "log-sink", "--name", name).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(KameletBindingConditionStatus(ns, name, v1alpha1.KameletBindingConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
diff --git a/e2e/global/common/scale_integration_test.go b/e2e/global/common/scale_integration_test.go
index eb2df5639..e9789f2ce 100644
--- a/e2e/global/common/scale_integration_test.go
+++ b/e2e/global/common/scale_integration_test.go
@@ -41,8 +41,9 @@ import (
func TestIntegrationScale(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
name := "java"
- Expect(KamelInstall(ns).Execute()).To(Succeed())
- Expect(Kamel("run", "-n", ns, "files/Java.java", "--name", name).Execute()).To(Succeed())
+ operatorID := "camel-k-integration-scale"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", name).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
@@ -119,7 +120,7 @@ func TestIntegrationScale(t *testing.T) {
// Save resources by deleting the integration
Expect(Kamel("delete", name, "-n", ns).Execute()).To(Succeed())
- Expect(Kamel("run", "-n", ns, "files/Java.java", "--name", "pre-built", "-t", fmt.Sprintf("container.image=%s", image)).Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", "pre-built", "-t", fmt.Sprintf("container.image=%s", image)).Execute()).To(Succeed())
Eventually(IntegrationPhase(ns, "pre-built"), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseRunning))
Eventually(IntegrationPodPhase(ns, "pre-built"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Expect(ScaleIntegration(ns, "pre-built", 0)).To(Succeed())
diff --git a/e2e/global/common/secondary_platform_test.go b/e2e/global/common/secondary_platform_test.go
index beb714314..9bb6df2e7 100644
--- a/e2e/global/common/secondary_platform_test.go
+++ b/e2e/global/common/secondary_platform_test.go
@@ -36,7 +36,8 @@ import (
func TestSecondaryPlatform(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns).Execute()).To(Succeed())
+ operatorID := "camel-k-platform-secondary"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
Expect(ConfigureSecondaryPlatformWith(ns, func(p *v1.IntegrationPlatform) {
p.Name = "secondary"
p.Spec.Traits.Container = &traitv1.ContainerTrait{
@@ -48,7 +49,7 @@ func TestSecondaryPlatform(t *testing.T) {
}
})).To(Succeed())
- Expect(Kamel("run", "-n", ns, "--name", "limited", "--annotation", "camel.apache.org/platform.id=secondary", "files/yaml.yaml").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "--name", "limited", "--annotation", "camel.apache.org/platform.id=secondary", "files/yaml.yaml").Execute()).To(Succeed())
Eventually(IntegrationPod(ns, "limited"), TestTimeoutMedium).Should(Not(BeNil()))
Eventually(IntegrationPodHas(ns, "limited", func(pod *corev1.Pod) bool {
@@ -60,7 +61,7 @@ func TestSecondaryPlatform(t *testing.T) {
}), TestTimeoutShort).Should(BeTrue())
Expect(Kamel("delete", "limited", "-n", ns).Execute()).To(Succeed())
- Expect(Kamel("run", "-n", ns, "--name", "normal", "files/yaml.yaml").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "--name", "normal", "files/yaml.yaml").Execute()).To(Succeed())
Eventually(IntegrationPod(ns, "normal"), TestTimeoutShort).Should(Not(BeNil()))
Eventually(IntegrationPodHas(ns, "normal", func(pod *corev1.Pod) bool {
if len(pod.Spec.Containers) != 1 {
diff --git a/e2e/global/common/structured_logs_test.go b/e2e/global/common/structured_logs_test.go
index 6131d6099..c0abcdc08 100644
--- a/e2e/global/common/structured_logs_test.go
+++ b/e2e/global/common/structured_logs_test.go
@@ -36,8 +36,9 @@ import (
func TestStructuredLogs(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
name := "java"
- Expect(KamelInstall(ns).Execute()).To(Succeed())
- Expect(Kamel("run", "-n", ns, "files/Java.java",
+ operatorID := "camel-k-logging"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
"-t", "logging.format=json").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
diff --git a/e2e/global/common/traits/affinity_test.go b/e2e/global/common/traits/affinity_test.go
index 2285dfcee..f4584df6d 100644
--- a/e2e/global/common/traits/affinity_test.go
+++ b/e2e/global/common/traits/affinity_test.go
@@ -37,7 +37,8 @@ import (
func TestAffinityTrait(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns).Execute()).To(Succeed())
+ operatorID := "camel-k-trait-affinity"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
var hostname string
if node, err := selectSchedulableNode(); err == nil {
@@ -49,7 +50,7 @@ func TestAffinityTrait(t *testing.T) {
if hostname != "" {
t.Run("Run Java with node affinity", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "files/Java.java",
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
"--name", "java1",
"-t", "affinity.enabled=true",
"-t", fmt.Sprintf("affinity.node-affinity-labels=kubernetes.io/hostname in(%s)", hostname)).Execute()).To(Succeed())
@@ -69,7 +70,7 @@ func TestAffinityTrait(t *testing.T) {
}
t.Run("Run Java with pod affinity", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "files/Java.java",
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
"--name", "java2",
"-t", "affinity.enabled=true",
"-t", "affinity.pod-affinity-labels=camel.apache.org/integration").Execute()).To(Succeed())
@@ -89,7 +90,7 @@ func TestAffinityTrait(t *testing.T) {
})
t.Run("Run Java with pod anti affinity", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "files/Java.java",
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
"--name", "java3",
"-t", "affinity.enabled=true",
"-t", "affinity.pod-anti-affinity-labels=camel.apache.org/integration").Execute()).To(Succeed())
diff --git a/e2e/global/common/traits/error_handler_test.go b/e2e/global/common/traits/error_handler_test.go
index 1082d39da..36728da17 100644
--- a/e2e/global/common/traits/error_handler_test.go
+++ b/e2e/global/common/traits/error_handler_test.go
@@ -35,11 +35,12 @@ import (
func TestErrorHandlerTrait(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns).Execute()).To(Succeed())
+ operatorID := "camel-k-trait-errorhandler"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
t.Run("Run errored integration with error handler", func(t *testing.T) {
name := "error-handler"
- Expect(Kamel("run", "-n", ns, "files/ErroredRoute.java",
+ Expect(KamelRunWithID(operatorID, ns, "files/ErroredRoute.java",
"--name", name,
"-t", "error-handler.enabled=true",
"-t", "error-handler.ref=defaultErrorHandler",
diff --git a/e2e/global/common/traits/health_test.go b/e2e/global/common/traits/health_test.go
index 040357791..06a03dad7 100644
--- a/e2e/global/common/traits/health_test.go
+++ b/e2e/global/common/traits/health_test.go
@@ -48,10 +48,11 @@ func TestHealthTrait(t *testing.T) {
}
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns).Execute()).To(Succeed())
+ operatorID := "camel-k-trait-health"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
t.Run("Readiness condition with stopped route", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "files/Java.java",
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
"-t", "health.enabled=true",
// Enable Jolokia for the test to stop the Camel route
"-t", "jolokia.enabled=true",
diff --git a/e2e/global/common/traits/istio_test.go b/e2e/global/common/traits/istio_test.go
index 52d7e56ef..c3a640adf 100644
--- a/e2e/global/common/traits/istio_test.go
+++ b/e2e/global/common/traits/istio_test.go
@@ -35,10 +35,11 @@ import (
func TestIstioTrait(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns).Execute()).To(Succeed())
+ operatorID := "camel-k-trait-istio"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
t.Run("Run Java with Istio", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "files/Java.java",
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
"-t", "istio.enabled=true").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "java", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
diff --git a/e2e/global/common/traits/jolokia_test.go b/e2e/global/common/traits/jolokia_test.go
index 1d564f0de..533b306cf 100644
--- a/e2e/global/common/traits/jolokia_test.go
+++ b/e2e/global/common/traits/jolokia_test.go
@@ -36,10 +36,11 @@ import (
func TestJolokiaTrait(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns).Execute()).To(Succeed())
+ operatorID := "camel-k-trait-jolokia"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
t.Run("Run Java with Jolokia", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "files/Java.java",
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
"-t", "jolokia.enabled=true",
"-t", "jolokia.use-ssl-client-authentication=false",
"-t", "jolokia.protocol=http",
diff --git a/e2e/global/common/traits/jvm_test.go b/e2e/global/common/traits/jvm_test.go
index 12d3fe92b..b1ddae902 100644
--- a/e2e/global/common/traits/jvm_test.go
+++ b/e2e/global/common/traits/jvm_test.go
@@ -37,7 +37,8 @@ import (
func TestJVMTrait(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns).Execute()).To(Succeed())
+ operatorID := "camel-k-trait-jvm"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
// Store a configmap holding a jar
var cmData = make(map[string][]byte)
@@ -49,7 +50,7 @@ func TestJVMTrait(t *testing.T) {
assert.Nil(t, err)
t.Run("JVM trait classpath", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "./files/jvm/Classpath.java",
+ Expect(KamelRunWithID(operatorID, ns, "./files/jvm/Classpath.java",
"--resource", "configmap:my-deps",
"-t", "jvm.classpath=/etc/camel/resources/my-deps/sample-1.0.jar",
).Execute()).To(Succeed())
diff --git a/e2e/global/common/traits/master_test.go b/e2e/global/common/traits/master_test.go
index 852ce32c7..731ec7adf 100644
--- a/e2e/global/common/traits/master_test.go
+++ b/e2e/global/common/traits/master_test.go
@@ -48,17 +48,18 @@ func TestMasterTrait(t *testing.T) {
}
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns).Execute()).To(Succeed())
+ operatorID := "camel-k-trait-master"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
t.Run("master works", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "files/Master.java").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/Master.java").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "master"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationLogs(ns, "master"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
t.Run("only one integration with master runs", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "files/Master.java",
+ Expect(KamelRunWithID(operatorID, ns, "files/Master.java",
"--name", "first",
"--label", "leader-group=same",
"-t", "master.label-key=leader-group",
@@ -67,7 +68,7 @@ func TestMasterTrait(t *testing.T) {
Eventually(IntegrationPodPhase(ns, "first"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationLogs(ns, "first"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
// Start a second integration with the same lock (it should not start the route)
- Expect(Kamel("run", "-n", ns, "files/Master.java",
+ Expect(KamelRunWithID(operatorID, ns, "files/Master.java",
"--name", "second",
"--label", "leader-group=same",
"-t", "master.label-key=leader-group",
diff --git a/e2e/global/common/traits/openapi_test.go b/e2e/global/common/traits/openapi_test.go
index 4404a2d57..61f2d3256 100644
--- a/e2e/global/common/traits/openapi_test.go
+++ b/e2e/global/common/traits/openapi_test.go
@@ -48,11 +48,10 @@ func TestOpenAPI(t *testing.T) {
}
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns).Execute()).To(Succeed())
+ operatorID := "camel-k-trait-openapi"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
- Expect(Kamel(
- "run",
- "-n", ns,
+ Expect(KamelRunWithID(operatorID, ns,
"--name", "petstore",
"--open-api", "file:files/openapi/petstore-api.yaml",
"files/openapi/petstore.groovy",
@@ -87,7 +86,8 @@ func TestOpenAPIConfigmap(t *testing.T) {
}
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns).Execute()).To(Succeed())
+ operatorID := "camel-k-trait-openapi-configmap"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
openapiContent, err := ioutil.ReadFile("./files/openapi/petstore-api.yaml")
assert.Nil(t, err)
@@ -95,9 +95,7 @@ func TestOpenAPIConfigmap(t *testing.T) {
cmDataProps["petstore-api.yaml"] = string(openapiContent)
NewPlainTextConfigmap(ns, "my-openapi", cmDataProps)
- Expect(Kamel(
- "run",
- "-n", ns,
+ Expect(KamelRunWithID(operatorID, ns,
"--name", "petstore",
"--open-api", "configmap:my-openapi",
"files/openapi/petstore.groovy",
diff --git a/e2e/global/common/traits/pdb_test.go b/e2e/global/common/traits/pdb_test.go
index bcb8d0340..6a18b463a 100644
--- a/e2e/global/common/traits/pdb_test.go
+++ b/e2e/global/common/traits/pdb_test.go
@@ -55,8 +55,9 @@ func TestPodDisruptionBudgetTrait(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
name := "java"
- Expect(KamelInstall(ns).Execute()).To(Succeed())
- Expect(Kamel("run", "-n", ns, "files/Java.java",
+ operatorID := "camel-k-trait-pod-disruption"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
"--name", name,
"-t", "pdb.enabled=true",
"-t", "pdb.min-available=2",
diff --git a/e2e/global/common/traits/pod_test.go b/e2e/global/common/traits/pod_test.go
index be9f804f2..e27fd3166 100644
--- a/e2e/global/common/traits/pod_test.go
+++ b/e2e/global/common/traits/pod_test.go
@@ -77,7 +77,8 @@ func TestPodTrait(t *testing.T) {
}
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns).Execute()).To(Succeed())
+ operatorID := "camel-k-trait-pod-template"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
name := "pod-template-test"
@@ -85,7 +86,7 @@ func TestPodTrait(t *testing.T) {
test := tc[i]
t.Run(test.name, func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "files/PodTest.groovy",
+ Expect(KamelRunWithID(operatorID, ns, "files/PodTest.groovy",
"--name", name,
"--pod-template", test.templateName,
).Execute()).To(Succeed())
diff --git a/e2e/global/common/traits/prometheus_test.go b/e2e/global/common/traits/prometheus_test.go
index fee152474..f4a9a1709 100644
--- a/e2e/global/common/traits/prometheus_test.go
+++ b/e2e/global/common/traits/prometheus_test.go
@@ -49,9 +49,10 @@ func TestPrometheusTrait(t *testing.T) {
// Do not create PodMonitor for the time being as CI test runs on OCP 3.11
createPodMonitor := false
- Expect(KamelInstall(ns).Execute()).To(Succeed())
+ operatorID := "camel-k-trait-prometheus"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
- Expect(Kamel("run", "-n", ns, "files/Java.java",
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
"-t", "prometheus.enabled=true",
"-t", fmt.Sprintf("prometheus.pod-monitor=%v", createPodMonitor)).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
diff --git a/e2e/global/common/traits/pull_secret_test.go b/e2e/global/common/traits/pull_secret_test.go
index 7c4c693c5..6388204ce 100644
--- a/e2e/global/common/traits/pull_secret_test.go
+++ b/e2e/global/common/traits/pull_secret_test.go
@@ -39,11 +39,12 @@ func TestPullSecretTrait(t *testing.T) {
ocp, err := openshift.IsOpenShift(TestClient())
Expect(err).To(BeNil())
- Expect(KamelInstall(ns).Execute()).To(Succeed())
+ operatorID := "camel-k-trait-pull-secret"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
t.Run("Image pull secret is set on pod", func(t *testing.T) {
name := "java1"
- Expect(Kamel("run", "-n", ns, "files/Java.java", "--name", name,
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", name,
"-t", "pull-secret.enabled=true",
"-t", "pull-secret.secret-name=dummy-secret").Execute()).To(Succeed())
// pod may not run because the pull secret is dummy
@@ -56,7 +57,7 @@ func TestPullSecretTrait(t *testing.T) {
t.Run("Explicitly disable image pull secret", func(t *testing.T) {
name := "java2"
- Expect(Kamel("run", "-n", ns, "files/Java.java", "--name", name,
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", name,
"-t", "pull-secret.enabled=false").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
@@ -75,7 +76,7 @@ func TestPullSecretTrait(t *testing.T) {
// OpenShift always has an internal registry so image pull secret is set by default
t.Run("Image pull secret is automatically set by default", func(t *testing.T) {
name := "java3"
- Expect(Kamel("run", "-n", ns, "files/Java.java", "--name", name).Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", name).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
diff --git a/e2e/global/common/traits/route_test.go b/e2e/global/common/traits/route_test.go
index 115c6845d..fa24aa2a7 100644
--- a/e2e/global/common/traits/route_test.go
+++ b/e2e/global/common/traits/route_test.go
@@ -91,7 +91,8 @@ func TestRunRoutes(t *testing.T) {
}
assert.Nil(t, err)
- Expect(KamelInstall(ns, "--trait-profile=openshift").Execute()).To(Succeed())
+ operatorID := "camel-k-trait-route"
+ Expect(KamelInstallWithID(operatorID, ns, "--trait-profile=openshift").Execute()).To(Succeed())
// create a test secret of type tls with certificates
// this secret is used to setupt the route TLS object across diferent tests
@@ -106,7 +107,7 @@ func TestRunRoutes(t *testing.T) {
// Insecure Route / No TLS
// =============================
t.Run("Route unsecure http works", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "files/PlatformHttpServer.java").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/PlatformHttpServer.java").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, integrationName), TestTimeoutLong).Should(Equal(corev1.PodRunning))
route := Route(ns, integrationName)
Eventually(route, TestTimeoutMedium).ShouldNot(BeNil())
@@ -122,7 +123,7 @@ func TestRunRoutes(t *testing.T) {
// TLS Route Edge
// =============================
t.Run("Route Edge https works", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "files/PlatformHttpServer.java", "-t", "route.tls-termination=edge").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/PlatformHttpServer.java", "-t", "route.tls-termination=edge").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, integrationName), TestTimeoutLong).Should(Equal(corev1.PodRunning))
route := Route(ns, integrationName)
Eventually(route, TestTimeoutMedium).ShouldNot(BeNil())
@@ -138,7 +139,7 @@ func TestRunRoutes(t *testing.T) {
// TLS Route Edge with custom certificate
// =============================
t.Run("Route Edge (custom certificate) https works", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "files/PlatformHttpServer.java",
+ Expect(KamelRunWithID(operatorID, ns, "files/PlatformHttpServer.java",
"-t", "route.tls-termination=edge",
"-t", "route.tls-certificate-secret="+refCert,
"-t", "route.tls-key-secret="+refKey,
@@ -159,7 +160,7 @@ func TestRunRoutes(t *testing.T) {
// TLS Route Passthrough
// =============================
t.Run("Route passthrough https works", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "files/PlatformHttpServer.java",
+ Expect(KamelRunWithID(operatorID, ns, "files/PlatformHttpServer.java",
// the --resource mounts the certificates inside secret as files in the integration pod
"--resource", "secret:"+secretName+"@/etc/ssl/"+secretName,
// quarkus platform-http uses these two properties to setup the HTTP endpoint with TLS support
@@ -184,7 +185,7 @@ func TestRunRoutes(t *testing.T) {
// TLS Route Reencrypt
// =============================
t.Run("Route Reencrypt https works", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "files/PlatformHttpServer.java",
+ Expect(KamelRunWithID(operatorID, ns, "files/PlatformHttpServer.java",
// the --resource mounts the certificates inside secret as files in the integration pod
"--resource", "secret:"+secretName+"@/etc/ssl/"+secretName,
// quarkus platform-http uses these two properties to setup the HTTP endpoint with TLS support
diff --git a/e2e/global/common/traits/service_test.go b/e2e/global/common/traits/service_test.go
index 4f3508fc8..21fcd8fc7 100644
--- a/e2e/global/common/traits/service_test.go
+++ b/e2e/global/common/traits/service_test.go
@@ -34,10 +34,11 @@ import (
func TestServiceTraitNodePort(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns).Execute()).To(Succeed())
+ operatorID := "camel-k-trait-service"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
t.Run("NodePort service", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "files/PlatformHttpServer.java",
+ Expect(KamelRunWithID(operatorID, ns, "files/PlatformHttpServer.java",
"-t", "service.enabled=true",
"-t", "service.node-port=true").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "platform-http-server"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
@@ -59,7 +60,7 @@ func TestServiceTraitDefault(t *testing.T) {
t.Run("Default service (ClusterIP)", func(t *testing.T) {
// Service trait is enabled by default
- Expect(Kamel("run", "-n", ns, "files/PlatformHttpServer.java").Execute()).To(Succeed())
+ Expect(KamelRun(ns, "files/PlatformHttpServer.java").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "platform-http-server"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
//
diff --git a/e2e/global/common/traits/toleration_test.go b/e2e/global/common/traits/toleration_test.go
index f834deac6..60b0e7918 100644
--- a/e2e/global/common/traits/toleration_test.go
+++ b/e2e/global/common/traits/toleration_test.go
@@ -49,11 +49,12 @@ func TestTolerationTrait(t *testing.T) {
}
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns).Execute()).To(Succeed())
+ operatorID := "camel-k-trait-toleration"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
t.Run("Run Java with node toleration operation exists", func(t *testing.T) {
name := "java1"
- Expect(Kamel("run", "-n", ns, "files/Java.java",
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
"--name", name,
"-t", "toleration.enabled=true",
"-t", "toleration.taints=camel.apache.org/master:NoExecute:300",
@@ -75,7 +76,7 @@ func TestTolerationTrait(t *testing.T) {
t.Run("Run Java with node toleration operation equals", func(t *testing.T) {
name := "java2"
- Expect(Kamel("run", "-n", ns, "files/Java.java",
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
"--name", name,
"-t", "toleration.enabled=true",
"-t", "toleration.taints=camel.apache.org/master=test:NoExecute:300",
@@ -101,7 +102,7 @@ func TestTolerationTrait(t *testing.T) {
}
name := "java3"
- Expect(Kamel("run", "-n", ns, "files/Java.java",
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
"--name", name,
// Use the affinity trait to force the scheduling of the Integration pod onto a master node
"-t", "affinity.enabled=true",
diff --git a/e2e/global/knative/kamelet_test.go b/e2e/global/knative/kamelet_test.go
index c066a814d..7c5e6abe4 100644
--- a/e2e/global/knative/kamelet_test.go
+++ b/e2e/global/knative/kamelet_test.go
@@ -40,11 +40,12 @@ import (
// Test that a KameletBinding can be changed and the changes are propagated to the Integration
func TestKameletChange(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns).Execute()).To(Succeed())
+ operatorID := "camel-k-kamelet-change"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
Expect(CreateTimerKamelet(ns, "timer-source")()).To(Succeed())
Expect(CreateKnativeChannel(ns, "messages")()).To(Succeed())
- Expect(Kamel("run", "-n", ns, "files/display.groovy", "-w").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/display.groovy", "-w").Execute()).To(Succeed())
from := corev1.ObjectReference{
Kind: "Kamelet",
diff --git a/e2e/global/knative/knative_platform_test.go b/e2e/global/knative/knative_platform_test.go
index 9b80f74d4..d35c6867f 100644
--- a/e2e/global/knative/knative_platform_test.go
+++ b/e2e/global/knative/knative_platform_test.go
@@ -45,13 +45,14 @@ func TestKnativePlatform(t *testing.T) {
t.FailNow()
}
- Expect(KamelInstall(ns).Execute()).To(Succeed())
+ operatorID := "camel-k-knative"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
Eventually(PlatformPhase(ns), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady))
Eventually(PlatformProfile(ns), TestTimeoutShort).Should(Equal(v1.TraitProfile("")))
cluster := Platform(ns)().Status.Cluster
t.Run("run yaml on cluster profile", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "files/yaml.yaml", "--profile", string(cluster)).Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml", "--profile", string(cluster)).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationLogs(ns, "yaml"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
Eventually(IntegrationProfile(ns, "yaml"), TestTimeoutShort).Should(Equal(v1.TraitProfile(string(cluster))))
@@ -77,7 +78,7 @@ func TestKnativePlatform(t *testing.T) {
})
t.Run("run yaml on automatic profile", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "files/yaml.yaml").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationProfile(ns, "yaml"), TestTimeoutShort).Should(Equal(v1.TraitProfileKnative))
Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
diff --git a/e2e/global/knative/knative_test.go b/e2e/global/knative/knative_test.go
index f846aa314..b95bafb32 100644
--- a/e2e/global/knative/knative_test.go
+++ b/e2e/global/knative/knative_test.go
@@ -23,6 +23,7 @@ limitations under the License.
package knative
import (
+ "fmt"
"testing"
"time"
@@ -36,14 +37,15 @@ import (
func TestRunServiceCombo(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns, "--trait-profile", "knative").Execute()).To(Succeed())
- Expect(Kamel("run", "-n", ns, "files/knative2.groovy").Execute()).To(Succeed())
+ operatorID := fmt.Sprintf("camel-k-%s", ns)
+ Expect(KamelInstallWithID(operatorID, ns, "--trait-profile", "knative").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/knative2.groovy").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "knative2"), TestTimeoutLong).Should(Equal(v1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "knative2", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
- Expect(Kamel("run", "-n", ns, "files/knative3.groovy").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/knative3.groovy").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "knative3"), TestTimeoutLong).Should(Equal(v1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "knative3", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
- Expect(Kamel("run", "-n", ns, "files/knative1.groovy").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/knative1.groovy").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "knative1"), TestTimeoutLong).Should(Equal(v1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "knative1", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
// Correct logs
@@ -60,9 +62,10 @@ func TestRunServiceCombo(t *testing.T) {
func TestRunChannelComboV1Beta1(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
Expect(CreateKnativeChannel(ns, "messages")()).To(Succeed())
- Expect(KamelInstall(ns, "--trait-profile", "knative").Execute()).To(Succeed())
- Expect(Kamel("run", "-n", ns, "files/knativech2.groovy").Execute()).To(Succeed())
- Expect(Kamel("run", "-n", ns, "files/knativech1.groovy").Execute()).To(Succeed())
+ operatorID := fmt.Sprintf("camel-k-%s", ns)
+ Expect(KamelInstallWithID(operatorID, ns, "--trait-profile", "knative").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/knativech2.groovy").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/knativech1.groovy").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "knativech2"), TestTimeoutLong).Should(Equal(v1.PodRunning))
Eventually(IntegrationPodPhase(ns, "knativech1"), TestTimeoutLong).Should(Equal(v1.PodRunning))
Eventually(IntegrationLogs(ns, "knativech2"), TestTimeoutMedium).Should(ContainSubstring("Received: Hello from knativech1"))
@@ -73,9 +76,10 @@ func TestRunChannelComboV1Beta1(t *testing.T) {
func TestRunChannelComboGetToPost(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
Expect(CreateKnativeChannel(ns, "messages")()).To(Succeed())
- Expect(KamelInstall(ns, "--trait-profile", "knative").Execute()).To(Succeed())
- Expect(Kamel("run", "-n", ns, "files/knativegetpost2.groovy").Execute()).To(Succeed())
- Expect(Kamel("run", "-n", ns, "files/knativegetpost1.groovy").Execute()).To(Succeed())
+ operatorID := fmt.Sprintf("camel-k-%s", ns)
+ Expect(KamelInstallWithID(operatorID, ns, "--trait-profile", "knative").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/knativegetpost2.groovy").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/knativegetpost1.groovy").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "knativegetpost2"), TestTimeoutLong).Should(Equal(v1.PodRunning))
Eventually(IntegrationPodPhase(ns, "knativegetpost1"), TestTimeoutLong).Should(Equal(v1.PodRunning))
Eventually(IntegrationLogs(ns, "knativegetpost2"), TestTimeoutMedium).Should(ContainSubstring(`Received ""`))
@@ -87,10 +91,11 @@ func TestRunMultiChannelChain(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
Expect(CreateKnativeChannel(ns, "messages")()).To(Succeed())
Expect(CreateKnativeChannel(ns, "words")()).To(Succeed())
- Expect(KamelInstall(ns, "--trait-profile", "knative").Execute()).To(Succeed())
- Expect(Kamel("run", "-n", ns, "files/knativemultihop3.groovy").Execute()).To(Succeed())
- Expect(Kamel("run", "-n", ns, "files/knativemultihop2.groovy").Execute()).To(Succeed())
- Expect(Kamel("run", "-n", ns, "files/knativemultihop1.groovy").Execute()).To(Succeed())
+ operatorID := fmt.Sprintf("camel-k-%s", ns)
+ Expect(KamelInstallWithID(operatorID, ns, "--trait-profile", "knative").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/knativemultihop3.groovy").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/knativemultihop2.groovy").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/knativemultihop1.groovy").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "knativemultihop3"), TestTimeoutLong).Should(Equal(v1.PodRunning))
Eventually(IntegrationPodPhase(ns, "knativemultihop2"), TestTimeoutLong).Should(Equal(v1.PodRunning))
Eventually(IntegrationPodPhase(ns, "knativemultihop1"), TestTimeoutLong).Should(Equal(v1.PodRunning))
@@ -106,9 +111,10 @@ func TestRunMultiChannelChain(t *testing.T) {
func TestRunBroker(t *testing.T) {
WithNewTestNamespaceWithKnativeBroker(t, func(ns string) {
- Expect(KamelInstall(ns, "--trait-profile", "knative").Execute()).To(Succeed())
- Expect(Kamel("run", "-n", ns, "files/knativeevt1.groovy").Execute()).To(Succeed())
- Expect(Kamel("run", "-n", ns, "files/knativeevt2.groovy").Execute()).To(Succeed())
+ operatorID := fmt.Sprintf("camel-k-%s", ns)
+ Expect(KamelInstallWithID(operatorID, ns, "--trait-profile", "knative").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/knativeevt1.groovy").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/knativeevt2.groovy").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "knativeevt1"), TestTimeoutLong).Should(Equal(v1.PodRunning))
Eventually(IntegrationPodPhase(ns, "knativeevt2"), TestTimeoutLong).Should(Equal(v1.PodRunning))
Eventually(IntegrationLogs(ns, "knativeevt2"), TestTimeoutMedium).Should(ContainSubstring("Received 1: Hello 1"))
@@ -120,15 +126,16 @@ func TestRunBroker(t *testing.T) {
func TestRunFlow(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns, "--trait-profile", "knative").Execute()).To(Succeed())
- Expect(Kamel("run", "-n", ns, "files/flow.yaml").Execute()).To(Succeed())
+ operatorID := fmt.Sprintf("camel-k-%s", ns)
+ Expect(KamelInstallWithID(operatorID, ns, "--trait-profile", "knative").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/flow.yaml").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "flow"), TestTimeoutLong).Should(Equal(v1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "flow", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))
-
+
t.Run("Scale to zero", func(t *testing.T) {
Eventually(IntegrationPod(ns, "flow"), TestTimeoutLong).Should(BeNil())
})
-
+
Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
}
diff --git a/e2e/global/knative/openapi_test.go b/e2e/global/knative/openapi_test.go
index 03500384d..1c6e9fa2b 100644
--- a/e2e/global/knative/openapi_test.go
+++ b/e2e/global/knative/openapi_test.go
@@ -35,10 +35,9 @@ import (
func TestOpenAPIService(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns, "--trait-profile", string(v1.TraitProfileKnative)).Execute()).To(Succeed())
- Expect(Kamel(
- "run",
- "-n", ns,
+ operatorID := "camel-k-openapi-service"
+ Expect(KamelInstallWithID(operatorID, ns, "--trait-profile", string(v1.TraitProfileKnative)).Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns,
"--name", "petstore",
"--open-api", "file:files/petstore-api.yaml",
"files/petstore.groovy",
@@ -60,10 +59,9 @@ func TestOpenAPIService(t *testing.T) {
func TestOpenAPIDeployment(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns, "--trait-profile", string(v1.TraitProfileKubernetes)).Execute()).To(Succeed())
- Expect(Kamel(
- "run",
- "-n", ns,
+ operatorID := "camel-k-openapi-deployment"
+ Expect(KamelInstallWithID(operatorID, ns, "--trait-profile", string(v1.TraitProfileKubernetes)).Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns,
"--name", "petstore",
"--open-api", "file:files/petstore-api.yaml",
"files/petstore.groovy",
diff --git a/e2e/global/knative/pod_test.go b/e2e/global/knative/pod_test.go
index 4b0308769..f134a94d4 100644
--- a/e2e/global/knative/pod_test.go
+++ b/e2e/global/knative/pod_test.go
@@ -35,12 +35,13 @@ import (
func TestPodTraitWithKnative(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns).Execute()).To(Succeed())
- Expect(Kamel("run", "-n", ns, "files/podtest-knative2.groovy",
+ operatorID := "camel-k-trait-pod-knative"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/podtest-knative2.groovy",
"--pod-template", "files/template-knative.yaml").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "podtest-knative2"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "podtest-knative2", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Expect(Kamel("run", "-n", ns, "files/podtest-knative1.groovy").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/podtest-knative1.groovy").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "podtest-knative1"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "podtest-knative1", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
diff --git a/e2e/global/registry/registry_maven_wagon_test.go b/e2e/global/registry/registry_maven_wagon_test.go
index 40f55df07..8b2d2018e 100644
--- a/e2e/global/registry/registry_maven_wagon_test.go
+++ b/e2e/global/registry/registry_maven_wagon_test.go
@@ -45,7 +45,8 @@ func TestImageRegistryIsAMavenRepository(t *testing.T) {
t.Skip("Avoid running on OpenShift until CA and secret are injected client side")
return
}
- Expect(KamelInstall(ns, "--wait").Execute()).To(Succeed())
+ operatorID := "camel-k-maven-registry"
+ Expect(KamelInstallWithID(operatorID, ns, "--wait").Execute()).To(Succeed())
t.Run("image registry is a maven repository", func(t *testing.T) {
// Create integration that should decrypt an encrypted message to "foobar" and log it
@@ -55,11 +56,10 @@ func TestImageRegistryIsAMavenRepository(t *testing.T) {
pom, err := filepath.Abs("files/sample-decryption-1.0.pom")
assert.Nil(t, err)
- Expect(Kamel("run", "files/FoobarDecryption.java",
+ Expect(KamelRunWithID(operatorID, ns, "files/FoobarDecryption.java",
"--name", name,
"-d", fmt.Sprintf("file://%s", jar),
"-d", fmt.Sprintf("file://%s", pom),
- "-n", ns,
).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
@@ -70,11 +70,10 @@ func TestImageRegistryIsAMavenRepository(t *testing.T) {
t.Run("local files are mounted in the integration container at the default path", func(t *testing.T) {
name := "laughing-route-default-path"
- Expect(Kamel("run", "files/LaughingRoute.java",
+ Expect(KamelRunWithID(operatorID, ns, "files/LaughingRoute.java",
"--name", name,
"-p", "location=.?filename=laugh.txt",
"-d", "file://files/laugh.txt",
- "-n", ns,
).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
@@ -86,11 +85,10 @@ func TestImageRegistryIsAMavenRepository(t *testing.T) {
name := "laughing-route-custom-path"
customPath := "this/is/a/custom/path/"
- Expect(Kamel("run", "files/LaughingRoute.java",
+ Expect(KamelRunWithID(operatorID, ns, "files/LaughingRoute.java",
"--name", name,
"-p", fmt.Sprintf("location=%s", customPath),
"-d", fmt.Sprintf("file://files/laugh.txt?targetPath=%slaugh.txt", customPath),
- "-n", ns,
).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
@@ -101,11 +99,10 @@ func TestImageRegistryIsAMavenRepository(t *testing.T) {
t.Run("local directory is mounted in the integration container", func(t *testing.T) {
name := "laughing-route-directory"
- Expect(Kamel("run", "files/LaughingRoute.java",
+ Expect(KamelRunWithID(operatorID, ns, "files/LaughingRoute.java",
"--name", name,
"-p", "location=files/",
"-d", fmt.Sprintf("file://files/laughs/?targetPath=files/"),
- "-n", ns,
).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
@@ -120,10 +117,9 @@ func TestImageRegistryIsAMavenRepository(t *testing.T) {
jar, err := filepath.Abs("files/sample-decryption-1.0.jar")
assert.Nil(t, err)
- Expect(Kamel("run", "files/FoobarDecryption.java",
+ Expect(KamelRunWithID(operatorID, ns, "files/FoobarDecryption.java",
"--name", name,
"-d", fmt.Sprintf("file://%s", jar),
- "-n", ns,
).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
diff --git a/e2e/global/service-binding/service_binding_kamelet_test.go b/e2e/global/service-binding/service_binding_kamelet_test.go
index b2cbe67d5..83844e053 100644
--- a/e2e/global/service-binding/service_binding_kamelet_test.go
+++ b/e2e/global/service-binding/service_binding_kamelet_test.go
@@ -36,7 +36,8 @@ import (
func TestKameletServiceBindingTrait(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns).Execute()).To(Succeed())
+ operatorID := "camel-k-kamelet-service-binding"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
// Create our mock service config
message := "hello"
@@ -61,10 +62,9 @@ func TestKameletServiceBindingTrait(t *testing.T) {
Expect(CreateTimerKamelet(ns, "my-timer-source")()).To(Succeed())
- Expect(Kamel("bind", "my-timer-source", "log:info",
+ Expect(KamelBindWithID(operatorID, ns, "my-timer-source", "log:info",
"-p", "source.message=Hello+world",
- "--connect", serviceRef, "-n", ns).
- Execute()).To(Succeed())
+ "--connect", serviceRef).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "my-timer-source-to-log"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationLogs(ns, "my-timer-source-to-log")).Should(ContainSubstring("Body: Hello+world"))
diff --git a/e2e/global/service-binding/service_binding_test.go b/e2e/global/service-binding/service_binding_test.go
index 54c6968b1..834cce732 100644
--- a/e2e/global/service-binding/service_binding_test.go
+++ b/e2e/global/service-binding/service_binding_test.go
@@ -37,7 +37,8 @@ import (
func TestServiceBindingTrait(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(KamelInstall(ns).Execute()).To(Succeed())
+ operatorID := "camel-k-trait-service-binding"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
// Create our mock service config
host := "hostname"
@@ -65,10 +66,9 @@ func TestServiceBindingTrait(t *testing.T) {
// Create integration and bind it to our service
name := "service-binding"
- Expect(Kamel("run", "ServiceBinding.java",
+ Expect(KamelRunWithID(operatorID, ns, "ServiceBinding.java",
"--name", name,
"--connect", serviceRef,
- "-n", ns,
).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
diff --git a/e2e/namespace/install/cli/bind_test.go b/e2e/namespace/install/cli/bind_test.go
index d40d9be58..1bd527d5e 100644
--- a/e2e/namespace/install/cli/bind_test.go
+++ b/e2e/namespace/install/cli/bind_test.go
@@ -34,26 +34,27 @@ import (
func TestKamelCLIBind(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(Kamel("install", "-n", ns).Execute()).To(Succeed())
+ operatorID := "camel-k-cli-bind"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
Expect(CreateTimerKamelet(ns, "test-timer-source")()).To(Succeed())
t.Run("bind timer to log", func(t *testing.T) {
- Expect(Kamel("bind", "test-timer-source", "log:info", "-p", "source.message=helloTest", "-n", ns).Execute()).To(Succeed())
+ Expect(KamelBindWithID(operatorID, ns, "test-timer-source", "log:info", "-p", "source.message=helloTest").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "test-timer-source-to-log"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationLogs(ns, "test-timer-source-to-log")).Should(ContainSubstring("Body: helloTest"))
- Expect(Kamel("bind", "test-timer-source", "log:info", "-p", "source.message=newText", "-n", ns).Execute()).To(Succeed())
+ Expect(KamelBindWithID(operatorID, ns, "test-timer-source", "log:info", "-p", "source.message=newText").Execute()).To(Succeed())
Eventually(IntegrationLogs(ns, "test-timer-source-to-log")).Should(ContainSubstring("Body: newText"))
Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
t.Run("unsuccessful binding, no property", func(t *testing.T) {
- Expect(Kamel("bind", "timer-source", "log:info", "-n", ns).Execute()).NotTo(Succeed())
+ Expect(KamelBindWithID(operatorID, ns, "timer-source", "log:info").Execute()).NotTo(Succeed())
})
t.Run("bind uris", func(t *testing.T) {
- Expect(Kamel("bind", "timer:foo", "log:bar", "-n", ns).Execute()).To(Succeed())
+ Expect(KamelBindWithID(operatorID, ns, "timer:foo", "log:bar").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "timer-to-log"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationLogs(ns, "timer-to-log")).Should(ContainSubstring("Body is null"))
diff --git a/e2e/namespace/install/cli/delete_test.go b/e2e/namespace/install/cli/delete_test.go
index 6c223197b..ddee6b6c3 100644
--- a/e2e/namespace/install/cli/delete_test.go
+++ b/e2e/namespace/install/cli/delete_test.go
@@ -34,10 +34,11 @@ import (
func TestKamelCLIDelete(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(Kamel("install", "-n", ns).Execute()).To(Succeed())
+ operatorID := "camel-k-cli-delete"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
t.Run("delete running integration", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "../files/yaml.yaml").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "../files/yaml.yaml").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Expect(Kamel("delete", "yaml", "-n", ns).Execute()).To(Succeed())
Eventually(Integration(ns, "yaml")).Should(BeNil())
@@ -45,14 +46,14 @@ func TestKamelCLIDelete(t *testing.T) {
})
t.Run("delete building integration", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "../files/yaml.yaml").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "../files/yaml.yaml").Execute()).To(Succeed())
Expect(Kamel("delete", "yaml", "-n", ns).Execute()).To(Succeed())
Eventually(Integration(ns, "yaml")).Should(BeNil())
Eventually(IntegrationPod(ns, "yaml")).Should(BeNil())
})
t.Run("delete integration from csv", func(t *testing.T) {
- Expect(Kamel("run", "github:apache/camel-k/e2e/common/files/yaml.yaml", "-n", ns).Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "github:apache/camel-k/e2e/common/files/yaml.yaml").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Expect(Kamel("delete", "yaml", "-n", ns).Execute()).To(Succeed())
Eventually(Integration(ns, "yaml")).Should(BeNil())
@@ -60,8 +61,8 @@ func TestKamelCLIDelete(t *testing.T) {
})
t.Run("delete several integrations", func(t *testing.T) {
- Expect(Kamel("run", "../files/yaml.yaml", "-n", ns).Execute()).To(Succeed())
- Expect(Kamel("run", "../files/Java.java", "-n", ns).Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "../files/yaml.yaml").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "../files/Java.java").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Expect(Kamel("delete", "yaml", "-n", ns).Execute()).To(Succeed())
@@ -73,8 +74,8 @@ func TestKamelCLIDelete(t *testing.T) {
})
t.Run("delete all integrations", func(t *testing.T) {
- Expect(Kamel("run", "../files/yaml.yaml", "-n", ns).Execute()).To(Succeed())
- Expect(Kamel("run", "../files/Java.java", "-n", ns).Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "../files/yaml.yaml").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "../files/Java.java").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
diff --git a/e2e/namespace/install/cli/describe_test.go b/e2e/namespace/install/cli/describe_test.go
index b81c10962..b953b974a 100644
--- a/e2e/namespace/install/cli/describe_test.go
+++ b/e2e/namespace/install/cli/describe_test.go
@@ -36,8 +36,9 @@ import (
func TestKamelCliDescribe(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(Kamel("install", "-n", ns).Execute()).To(Succeed())
- Expect(Kamel("run", "-n", ns, "files/yaml.yaml").Execute()).To(Succeed())
+ operatorID := "camel-k-cli-describe"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
t.Run("Test kamel describe integration", func(t *testing.T) {
diff --git a/e2e/namespace/install/cli/dev_mode_test.go b/e2e/namespace/install/cli/dev_mode_test.go
index 2d6095db7..5decd8849 100644
--- a/e2e/namespace/install/cli/dev_mode_test.go
+++ b/e2e/namespace/install/cli/dev_mode_test.go
@@ -53,7 +53,8 @@ func TestRunDevMode(t *testing.T) {
}
WithNewTestNamespace(t, func(ns string) {
- Expect(Kamel("install", "-n", ns).Execute()).To(Succeed())
+ operatorID := "camel-k-dev-mode"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
t.Run("run yaml dev mode", func(t *testing.T) {
RegisterTestingT(t)
@@ -65,14 +66,20 @@ func TestRunDevMode(t *testing.T) {
file := util.MakeTempCopy(t, "files/yaml.yaml")
- kamelRun := KamelWithContext(ctx, "run", "-n", ns, file, "--dev")
+ kamelRun := KamelRunWithContext(ctx, operatorID, ns, file, "--dev")
kamelRun.SetOut(pipew)
logScanner := util.NewLogScanner(ctx, piper, `integration "yaml" in phase Running`, "Magicstring!", "Magicjordan!")
args := os.Args
defer func() { os.Args = args }()
- os.Args = []string{"kamel", "run", "-n", ns, file, "--dev"}
+
+ globalTest := os.Getenv("CAMEL_K_FORCE_GLOBAL_TEST") == "true"
+ if globalTest {
+ os.Args = []string{"kamel", "run", "-n", ns, file, "--dev"}
+ } else {
+ os.Args = []string{"kamel", "run", "-n", ns, "--operator-id", operatorID, file, "--dev"}
+ }
go kamelRun.Execute()
Eventually(logScanner.IsFound(`integration "yaml" in phase Running`), TestTimeoutMedium).Should(BeTrue())
@@ -92,14 +99,21 @@ func TestRunDevMode(t *testing.T) {
defer piper.Close()
remoteFile := "https://raw.githubusercontent.com/apache/camel-k/b29333f0a878d5d09fb3965be8fe586d77dd95d0/e2e/common/files/yaml.yaml"
- kamelRun := KamelWithContext(ctx, "run", "-n", ns, remoteFile, "--dev")
+ kamelRun := KamelRunWithContext(ctx, operatorID, ns, remoteFile, "--dev")
kamelRun.SetOut(pipew)
logScanner := util.NewLogScanner(ctx, piper, "Magicstring!")
args := os.Args
defer func() { os.Args = args }()
- os.Args = []string{"kamel", "-n", ns, "run", remoteFile, "--dev"}
+
+ globalTest := os.Getenv("CAMEL_K_FORCE_GLOBAL_TEST") == "true"
+ if globalTest {
+ os.Args = []string{"kamel", "run", "-n", ns, remoteFile, "--dev"}
+ } else {
+ os.Args = []string{"kamel", "run", "-n", ns, "--operator-id", operatorID, remoteFile, "--dev"}
+ }
+
go kamelRun.Execute()
Eventually(logScanner.IsFound("Magicstring!"), TestTimeoutMedium).Should(BeTrue())
@@ -123,7 +137,7 @@ func TestRunDevMode(t *testing.T) {
file := util.MakeTempCopy(t, "../config/files/resource-file-location-route.groovy")
- kamelRun := KamelWithContext(ctx, "run", "-n", ns, file, "--dev", "--resource", fmt.Sprintf("file:%s@/tmp/file.txt", tmpFile.Name()))
+ kamelRun := KamelRunWithContext(ctx, operatorID, ns, file, "--dev", "--resource", fmt.Sprintf("file:%s@/tmp/file.txt", tmpFile.Name()))
kamelRun.SetOut(pipew)
logScanner := util.NewLogScanner(ctx, piper, `integration "resource-file-location-route" in phase Running`,
@@ -131,7 +145,14 @@ func TestRunDevMode(t *testing.T) {
args := os.Args
defer func() { os.Args = args }()
- os.Args = []string{"kamel", "run", "-n", ns, file, "--dev", "--resource", fmt.Sprintf("file:%s@/tmp/file.txt", tmpFile.Name())}
+
+ globalTest := os.Getenv("CAMEL_K_FORCE_GLOBAL_TEST") == "true"
+ if globalTest {
+ os.Args = []string{"kamel", "run", "-n", ns, file, "--dev", "--resource", fmt.Sprintf("file:%s@/tmp/file.txt", tmpFile.Name())}
+ } else {
+ os.Args = []string{"kamel", "run", "-n", ns, "--operator-id", operatorID, file, "--dev", "--resource", fmt.Sprintf("file:%s@/tmp/file.txt", tmpFile.Name())}
+ }
+
go kamelRun.Execute()
Eventually(logScanner.IsFound(`integration "resource-file-location-route" in phase Running`), TestTimeoutMedium).Should(BeTrue())
@@ -159,7 +180,7 @@ func TestRunDevMode(t *testing.T) {
RegisterTestingT(t)
// First run (warm up)
- Expect(Kamel("run", "-n", ns, "files/yaml.yaml").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationLogs(ns, "yaml"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
Expect(Kamel("delete", "yaml", "-n", ns).Execute()).To(Succeed())
@@ -175,14 +196,21 @@ func TestRunDevMode(t *testing.T) {
file := util.MakeTempCopy(t, "files/yaml.yaml")
- kamelRun := KamelWithContext(ctx, "run", "-n", ns, file, "--dev")
+ kamelRun := KamelRunWithContext(ctx, operatorID, ns, file, "--dev")
kamelRun.SetOut(pipew)
logScanner := util.NewLogScanner(ctx, piper, `integration "yaml" in phase Running`, "Magicstring!")
args := os.Args
defer func() { os.Args = args }()
- os.Args = []string{"kamel", "run", "-n", ns, file, "--dev"}
+
+ globalTest := os.Getenv("CAMEL_K_FORCE_GLOBAL_TEST") == "true"
+ if globalTest {
+ os.Args = []string{"kamel", "run", "-n", ns, file, "--dev"}
+ } else {
+ os.Args = []string{"kamel", "run", "-n", ns, "--operator-id", operatorID, file, "--dev"}
+ }
+
go kamelRun.Execute()
// Second run should start up within a few seconds
diff --git a/e2e/namespace/install/cli/dump_test.go b/e2e/namespace/install/cli/dump_test.go
index dafecb957..611192d9e 100644
--- a/e2e/namespace/install/cli/dump_test.go
+++ b/e2e/namespace/install/cli/dump_test.go
@@ -42,8 +42,9 @@ func TestKamelCLIDump(t *testing.T) {
})
t.Run("dump non-empty namespace", func(t *testing.T) {
- Expect(Kamel("install", "-n", ns).Execute()).To(Succeed())
- Expect(Kamel("run", "files/yaml.yaml", "-n", ns).Execute()).To(Succeed())
+ operatorID := "camel-k-cli-dump"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationLogs(ns, "yaml")).Should(ContainSubstring("Magicstring!"))
diff --git a/e2e/namespace/install/cli/get_test.go b/e2e/namespace/install/cli/get_test.go
index 69cf6809b..2b9ad52bc 100644
--- a/e2e/namespace/install/cli/get_test.go
+++ b/e2e/namespace/install/cli/get_test.go
@@ -35,10 +35,11 @@ import (
func TestKamelCLIGet(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(Kamel("install", "-n", ns).Execute()).To(Succeed())
+ operatorID := "camel-k-cli-get"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
t.Run("get integration", func(t *testing.T) {
- Expect(Kamel("run", "../files/yaml.yaml", "-n", ns).Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "../files/yaml.yaml").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
// regex is used for the compatibility of tests between OC and vanilla K8
// kamel get may have different output depending og the platform
@@ -50,8 +51,8 @@ func TestKamelCLIGet(t *testing.T) {
})
t.Run("get several integrations", func(t *testing.T) {
- Expect(Kamel("run", "../files/yaml.yaml", "-n", ns).Execute()).To(Succeed())
- Expect(Kamel("run", "../files/Java.java", "-n", ns).Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "../files/yaml.yaml").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "../files/Java.java").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
diff --git a/e2e/namespace/install/cli/global_kamelet_test.go b/e2e/namespace/install/cli/global_kamelet_test.go
index a8c7387b4..b03f1d16b 100644
--- a/e2e/namespace/install/cli/global_kamelet_test.go
+++ b/e2e/namespace/install/cli/global_kamelet_test.go
@@ -47,7 +47,7 @@ func TestRunGlobalKamelet(t *testing.T) {
}
WithGlobalOperatorNamespace(t, func(operatorNamespace string) {
- Expect(Kamel("install", "-n", operatorNamespace, "--global", "--force").Execute()).To(Succeed())
+ Expect(KamelInstall(operatorNamespace, "--global", "--force").Execute()).To(Succeed())
t.Run("Global operator + namespaced kamelet test", func(t *testing.T) {
@@ -55,9 +55,10 @@ func TestRunGlobalKamelet(t *testing.T) {
WithNewTestNamespace(t, func(ns2 string) {
Expect(CreateTimerKamelet(ns2, "my-own-timer-source")()).To(Succeed())
- Expect(Kamel("install", "-n", ns2, "--skip-operator-setup", "--olm=false").Execute()).To(Succeed())
+ operatorID := "camel-k-local-ns2"
+ Expect(KamelInstallWithID(operatorID, ns2, "--skip-operator-setup", "--olm=false").Execute()).To(Succeed())
- Expect(Kamel("run", "-n", ns2, "files/timer-kamelet-usage.groovy").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns2, "files/timer-kamelet-usage.groovy").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns2, "timer-kamelet-usage"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationLogs(ns2, "timer-kamelet-usage"), TestTimeoutShort).Should(ContainSubstring("Hello world"))
Expect(Kamel("delete", "--all", "-n", ns2).Execute()).To(Succeed())
@@ -70,9 +71,10 @@ func TestRunGlobalKamelet(t *testing.T) {
// NS3: namespace without operator
WithNewTestNamespace(t, func(ns3 string) {
- Expect(Kamel("install", "-n", ns3, "--skip-operator-setup", "--olm=false").Execute()).To(Succeed())
+ operatorID := "camel-k-local-ns3"
+ Expect(KamelInstallWithID(operatorID, ns3, "--skip-operator-setup", "--olm=false").Execute()).To(Succeed())
- Expect(Kamel("run", "-n", ns3, "files/timer-kamelet-usage.groovy").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns3, "files/timer-kamelet-usage.groovy").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns3, "timer-kamelet-usage"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationLogs(ns3, "timer-kamelet-usage"), TestTimeoutShort).Should(ContainSubstring("Hello world"))
Expect(Kamel("delete", "--all", "-n", ns3).Execute()).To(Succeed())
diff --git a/e2e/namespace/install/cli/global_test.go b/e2e/namespace/install/cli/global_test.go
index fcfdcf53d..f96b76b32 100644
--- a/e2e/namespace/install/cli/global_test.go
+++ b/e2e/namespace/install/cli/global_test.go
@@ -56,10 +56,12 @@ func TestRunGlobalInstall(t *testing.T) {
Eventually(OperatorPodPhase(operatorNamespace), TestTimeoutMedium).Should(Equal(corev1.PodRunning))
t.Run("Global test on namespace with platform", func(t *testing.T) {
WithNewTestNamespace(t, func(ns2 string) {
- // Creating platform
- Expect(Kamel("install", "-n", ns2, "--skip-operator-setup", "--olm=false").Execute()).To(Succeed())
+ // Creating namespace local platform
+ Expect(KamelInstall(ns2, "--skip-operator-setup", "--olm=false").Execute()).To(Succeed())
+ Eventually(Platform(ns2)).ShouldNot(BeNil())
- Expect(Kamel("run", "-n", ns2, "files/Java.java").Execute()).To(Succeed())
+ // Run with global operator id
+ Expect(KamelRun(ns2, "files/Java.java").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns2, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationLogs(ns2, "java"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
Expect(IntegrationConditionMessage(IntegrationCondition(ns2, "java", v1.IntegrationConditionPlatformAvailable)())).To(MatchRegexp(ns2 + "\\/.*"))
@@ -68,19 +70,20 @@ func TestRunGlobalInstall(t *testing.T) {
Expect(Kits(ns2)()).Should(WithTransform(integrationKitsToNamesTransform(), ContainElement(kit)))
Expect(Kits(operatorNamespace)()).Should(WithTransform(integrationKitsToNamesTransform(), Not(ContainElement(kit))))
- Expect(Lease(ns2, platform.OperatorLockName)()).To(BeNil(), "No locking Leases expected")
+ Expect(Lease(ns2, platform.DefaultPlatformName)()).To(BeNil(), "No locking Leases expected")
})
})
t.Run("Global test on namespace with its own operator", func(t *testing.T) {
WithNewTestNamespace(t, func(ns3 string) {
+ operatorID := "camel-k-local-ns3"
if NoOlmOperatorImage != "" {
- Expect(Kamel("install", "-n", ns3, "--olm=false", "--operator-image", NoOlmOperatorImage).Execute()).To(Succeed())
+ Expect(KamelInstallWithID(operatorID, ns3, "--olm=false", "--operator-image", NoOlmOperatorImage).Execute()).To(Succeed())
} else {
- Expect(Kamel("install", "-n", ns3, "--olm=false").Execute()).To(Succeed())
+ Expect(KamelInstallWithID(operatorID, ns3, "--olm=false").Execute()).To(Succeed())
}
Eventually(OperatorPodPhase(ns3), TestTimeoutMedium).Should(Equal(corev1.PodRunning))
- Expect(Kamel("run", "-n", ns3, "files/Java.java").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns3, "files/Java.java").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns3, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationLogs(ns3, "java"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
Expect(IntegrationConditionMessage(IntegrationCondition(ns3, "java", v1.IntegrationConditionPlatformAvailable)())).To(MatchRegexp(ns3 + "\\/.*"))
@@ -88,7 +91,8 @@ func TestRunGlobalInstall(t *testing.T) {
Expect(Kits(ns3)()).Should(WithTransform(integrationKitsToNamesTransform(), ContainElement(kit)))
Expect(Kamel("delete", "--all", "-n", ns3).Execute()).To(Succeed())
- Expect(Lease(ns3, platform.OperatorLockName)()).ShouldNot(BeNil(),
+ Expect(Lease(ns3, platform.OperatorLockName)()).To(BeNil(), "No locking Leases expected")
+ Expect(Lease(ns3, platform.GetOperatorLockName(operatorID))()).ShouldNot(BeNil(),
"Controller Runtime is expected to use Leases for leader election: if this changes we should update our locking logic",
)
})
@@ -96,7 +100,7 @@ func TestRunGlobalInstall(t *testing.T) {
t.Run("Global test on namespace without platform", func(t *testing.T) {
WithNewTestNamespace(t, func(ns4 string) {
- Expect(Kamel("run", "-n", ns4, "files/Java.java").Execute()).To(Succeed())
+ Expect(KamelRun(ns4, "files/Java.java").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns4, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationLogs(ns4, "java"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
Expect(IntegrationConditionMessage(IntegrationCondition(ns4, "java", v1.IntegrationConditionPlatformAvailable)())).To(MatchRegexp(operatorNamespace + "\\/.*"))
@@ -111,7 +115,7 @@ func TestRunGlobalInstall(t *testing.T) {
t.Run("Global test on namespace without platform with external kit", func(t *testing.T) {
WithNewTestNamespace(t, func(ns5 string) {
- Expect(Kamel("run", "-n", ns5, "files/Java.java").Execute()).To(Succeed())
+ Expect(KamelRun(ns5, "files/Java.java").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns5, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationLogs(ns5, "java"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
Expect(IntegrationConditionMessage(IntegrationCondition(ns5, "java", v1.IntegrationConditionPlatformAvailable)())).To(MatchRegexp(operatorNamespace + "\\/.*"))
@@ -136,7 +140,7 @@ func TestRunGlobalInstall(t *testing.T) {
}
Expect(TestClient().Create(TestContext, &externalKit)).Should(BeNil())
- Expect(Kamel("run", "-n", ns5, "files/Java.java", "--name", "ext", "--kit", "external").Execute()).To(Succeed())
+ Expect(KamelRun(ns5, "files/Java.java", "--name", "ext", "--kit", "external").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns5, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationLogs(ns5, "ext"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
Expect(IntegrationKit(ns5, "ext")()).Should(Equal("external"))
diff --git a/e2e/namespace/install/cli/install_test.go b/e2e/namespace/install/cli/install_test.go
index c4e6d09af..1df50622d 100644
--- a/e2e/namespace/install/cli/install_test.go
+++ b/e2e/namespace/install/cli/install_test.go
@@ -24,6 +24,7 @@ package common
import (
"bytes"
+ "fmt"
"reflect"
"strings"
"testing"
@@ -44,7 +45,8 @@ import (
func TestBasicInstallation(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(Kamel("install", "-n", ns).Execute()).To(Succeed())
+ operatorID := fmt.Sprintf("camel-k-%s", ns)
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
Eventually(OperatorPod(ns)).ShouldNot(BeNil())
Eventually(Platform(ns)).ShouldNot(BeNil())
})
@@ -52,14 +54,16 @@ func TestBasicInstallation(t *testing.T) {
func TestAlternativeImageInstallation(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(Kamel("install", "-n", ns, "--olm=false", "--operator-image", "x/y:latest").Execute()).To(Succeed())
+ operatorID := fmt.Sprintf("camel-k-%s", ns)
+ Expect(KamelInstallWithID(operatorID, ns, "--olm=false", "--operator-image", "x/y:latest").Execute()).To(Succeed())
Eventually(OperatorImage(ns)).Should(Equal("x/y:latest"))
})
}
func TestKitMainInstallation(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(Kamel("install", "-n", ns).Execute()).To(Succeed())
+ operatorID := fmt.Sprintf("camel-k-%s", ns)
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
Expect(Kamel("kit", "create", "timer", "-d", "camel:timer", "-n", ns).Execute()).To(Succeed())
Eventually(Build(ns, "timer"), TestTimeoutMedium).ShouldNot(BeNil())
})
@@ -67,7 +71,8 @@ func TestKitMainInstallation(t *testing.T) {
func TestMavenRepositoryInstallation(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(Kamel("install", "-n", ns, "--maven-repository", "https://my.repo.org/public/").Execute()).To(Succeed())
+ operatorID := fmt.Sprintf("camel-k-%s", ns)
+ Expect(KamelInstallWithID(operatorID, ns, "--maven-repository", "https://my.repo.org/public/").Execute()).To(Succeed())
Eventually(Configmap(ns, "camel-k-maven-settings")).Should(Not(BeNil()))
Eventually(func() string {
return Configmap(ns, "camel-k-maven-settings")().Data["settings.xml"]
@@ -81,7 +86,8 @@ func TestMavenRepositoryInstallation(t *testing.T) {
*/
func TestSkipRegistryInstallation(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(Kamel("install", "-n", ns, "--skip-registry-setup").Execute()).To(Succeed())
+ operatorID := fmt.Sprintf("camel-k-%s", ns)
+ Expect(KamelInstallWithID(operatorID, ns, "--skip-registry-setup").Execute()).To(Succeed())
Eventually(Platform(ns)).ShouldNot(BeNil())
Eventually(func() v1.RegistrySpec {
return Platform(ns)().Spec.Build.Registry
@@ -120,7 +126,8 @@ func TestConsoleCliDownload(t *testing.T) {
Expect(TestClient().Delete(TestContext, cliDownload)).To(Succeed())
}
- Expect(Kamel("install", "-n", ns).Execute()).To(Succeed())
+ operatorID := fmt.Sprintf("camel-k-%s", ns)
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
Eventually(ConsoleCLIDownload(name), TestTimeoutMedium).Should(Not(BeNil()))
cliDownload = ConsoleCLIDownload(name)()
@@ -144,7 +151,8 @@ func TestConsoleCliDownload(t *testing.T) {
func TestInstallSkipDefaultKameletsInstallation(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(Kamel("install", "-n", ns, "--skip-default-kamelets-setup").Execute()).To(Succeed())
+ operatorID := fmt.Sprintf("camel-k-%s", ns)
+ Expect(KamelInstallWithID(operatorID, ns, "--skip-default-kamelets-setup").Execute()).To(Succeed())
Eventually(OperatorPod(ns)).ShouldNot(BeNil())
Expect(KameletList(ns)()).Should(BeEmpty())
})
@@ -152,7 +160,8 @@ func TestInstallSkipDefaultKameletsInstallation(t *testing.T) {
func TestInstallDebugLogging(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(Kamel("install", "-n", ns, "-z", "debug").Execute()).To(Succeed())
+ operatorID := fmt.Sprintf("camel-k-%s", ns)
+ Expect(KamelInstallWithID(operatorID, ns, "-z", "debug").Execute()).To(Succeed())
podFunc := OperatorPod(ns)
Eventually(podFunc).ShouldNot(BeNil())
diff --git a/e2e/namespace/install/cli/log_test.go b/e2e/namespace/install/cli/log_test.go
index ece7e38bf..5b696ac68 100644
--- a/e2e/namespace/install/cli/log_test.go
+++ b/e2e/namespace/install/cli/log_test.go
@@ -35,10 +35,11 @@ import (
func TestKamelCLILog(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(Kamel("install", "-n", ns).Execute()).To(Succeed())
+ operatorID := "camel-k-cli-log"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
t.Run("check integration log", func(t *testing.T) {
- Expect(Kamel("run", "../files/yaml.yaml", "-n", ns).Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "../files/yaml.yaml").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
// first line of the integration logs
logs := strings.Split(IntegrationLogs(ns, "yaml")(), "\n")[0]
diff --git a/e2e/namespace/install/cli/run_test.go b/e2e/namespace/install/cli/run_test.go
index db7e4663b..e483e6751 100644
--- a/e2e/namespace/install/cli/run_test.go
+++ b/e2e/namespace/install/cli/run_test.go
@@ -23,6 +23,7 @@ limitations under the License.
package common
import (
+ "fmt"
"testing"
. "github.com/onsi/gomega"
@@ -37,10 +38,11 @@ import (
func TestRunExamplesFromGitHub(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(Kamel("install", "-n", ns).Execute()).To(Succeed())
+ operatorID := fmt.Sprintf("camel-k-%s", ns)
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
t.Run("run java from GitHub", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "github:apache/camel-k/e2e/common/files/Java.java").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "github:apache/camel-k/e2e/common/files/Java.java").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "java", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, "java"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
@@ -48,7 +50,7 @@ func TestRunExamplesFromGitHub(t *testing.T) {
})
t.Run("run java from GitHub (RAW)", func(t *testing.T) {
- Expect(Kamel("run", "-n", ns, "https://raw.githubusercontent.com/apache/camel-k/main/e2e/common/files/Java.java").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "https://raw.githubusercontent.com/apache/camel-k/main/e2e/common/files/Java.java").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, "java", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, "java"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
@@ -57,7 +59,7 @@ func TestRunExamplesFromGitHub(t *testing.T) {
t.Run("run from GitHub Gist (ID)", func(t *testing.T) {
name := "github-gist-id"
- Expect(Kamel("run", "-n", ns, "--name", name, "gist:e2c3f9a5fd0d9e79b21b04809786f17a").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "--name", name, "gist:e2c3f9a5fd0d9e79b21b04809786f17a").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
@@ -67,7 +69,7 @@ func TestRunExamplesFromGitHub(t *testing.T) {
t.Run("run from GitHub Gist (URL)", func(t *testing.T) {
name := "github-gist-url"
- Expect(Kamel("run", "-n", ns, "--name", name, "https://gist.github.com/lburgazzoli/e2c3f9a5fd0d9e79b21b04809786f17a").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "--name", name, "https://gist.github.com/lburgazzoli/e2c3f9a5fd0d9e79b21b04809786f17a").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
@@ -82,16 +84,17 @@ func TestRunExamplesFromGitHub(t *testing.T) {
func TestRunAndUpdate(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(Kamel("install", "-n", ns).Execute()).To(Succeed())
+ operatorID := fmt.Sprintf("camel-k-%s", ns)
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
name := "run"
- Expect(Kamel("run", "-n", ns, "files/run.yaml", "--name", name).Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/run.yaml", "--name", name).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magic default"))
// Re-run the Integration with an updated configuration
- Expect(Kamel("run", "-n", ns, "files/run.yaml", "--name", name, "-p", "property=value").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "files/run.yaml", "--name", name, "-p", "property=value").Execute()).To(Succeed())
// Check the Deployment has progressed successfully
Eventually(DeploymentCondition(ns, name, appsv1.DeploymentProgressing), TestTimeoutShort).Should(MatchFields(IgnoreExtras, Fields{
diff --git a/e2e/namespace/install/cli/uninstall_test.go b/e2e/namespace/install/cli/uninstall_test.go
index 7eba807ee..73ce91c84 100644
--- a/e2e/namespace/install/cli/uninstall_test.go
+++ b/e2e/namespace/install/cli/uninstall_test.go
@@ -23,6 +23,7 @@ limitations under the License.
package common
import (
+ "fmt"
"testing"
. "github.com/onsi/gomega"
@@ -33,7 +34,8 @@ import (
func TestBasicUninstall(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
// a successful new installation
- Expect(Kamel("install", "-n", ns).Execute()).To(Succeed())
+ operatorID := fmt.Sprintf("camel-k-%s", ns)
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
Eventually(OperatorPod(ns)).ShouldNot(BeNil())
// should be completely removed on uninstall
@@ -50,7 +52,8 @@ func TestBasicUninstall(t *testing.T) {
func TestUninstallSkipOperator(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
// a successful new installation
- Expect(Kamel("install", "-n", ns).Execute()).To(Succeed())
+ operatorID := fmt.Sprintf("camel-k-%s", ns)
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
Eventually(OperatorPod(ns)).ShouldNot(BeNil())
// on uninstall it should remove everything except operator
Expect(Kamel("uninstall", "-n", ns, "--skip-crd", "--skip-cluster-roles", "--skip-operator").Execute()).To(Succeed())
@@ -61,7 +64,8 @@ func TestUninstallSkipOperator(t *testing.T) {
func TestUninstallSkipRole(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
// a successful new installation
- Expect(Kamel("install", "-n", ns, "--olm=false").Execute()).To(Succeed())
+ operatorID := fmt.Sprintf("camel-k-%s", ns)
+ Expect(KamelInstallWithID(operatorID, ns, "--olm=false").Execute()).To(Succeed())
Eventually(OperatorPod(ns)).ShouldNot(BeNil())
// on uninstall it should remove everything except roles
Expect(Kamel("uninstall", "-n", ns, "--skip-crd", "--skip-cluster-roles", "--skip-roles").Execute()).To(Succeed())
@@ -72,7 +76,8 @@ func TestUninstallSkipRole(t *testing.T) {
func TestUninstallSkipRoleBinding(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
// a successful new installation
- Expect(Kamel("install", "-n", ns, "--olm=false").Execute()).To(Succeed())
+ operatorID := fmt.Sprintf("camel-k-%s", ns)
+ Expect(KamelInstallWithID(operatorID, ns, "--olm=false").Execute()).To(Succeed())
Eventually(OperatorPod(ns)).ShouldNot(BeNil())
// on uninstall it should remove everything except role-bindings
Expect(Kamel("uninstall", "-n", ns, "--skip-crd", "--skip-cluster-roles", "--skip-role-bindings").Execute()).To(Succeed())
@@ -83,7 +88,8 @@ func TestUninstallSkipRoleBinding(t *testing.T) {
func TestUninstallSkipServiceAccounts(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
// a successful new installation
- Expect(Kamel("install", "-n", ns, "--olm=false").Execute()).To(Succeed())
+ operatorID := fmt.Sprintf("camel-k-%s", ns)
+ Expect(KamelInstallWithID(operatorID, ns, "--olm=false").Execute()).To(Succeed())
Eventually(OperatorPod(ns)).ShouldNot(BeNil())
// on uninstall it should remove everything except cluster-roles
Expect(Kamel("uninstall", "-n", ns, "--skip-crd", "--skip-cluster-roles", "--skip-service-accounts").Execute()).To(Succeed())
@@ -94,7 +100,8 @@ func TestUninstallSkipServiceAccounts(t *testing.T) {
func TestUninstallSkipIntegrationPlatform(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
// a successful new installation
- Expect(Kamel("install", "-n", ns).Execute()).To(Succeed())
+ operatorID := fmt.Sprintf("camel-k-%s", ns)
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
Eventually(OperatorPod(ns)).ShouldNot(BeNil())
// on uninstall it should remove everything except cluster-roles
// NOTE: skip CRDs is also required in addition to skip integration platform
@@ -106,7 +113,8 @@ func TestUninstallSkipIntegrationPlatform(t *testing.T) {
func TestUninstallSkipKamelets(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
// a successful new installation
- Expect(Kamel("install", "-n", ns).Execute()).To(Succeed())
+ operatorID := fmt.Sprintf("camel-k-%s", ns)
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
Eventually(OperatorPod(ns)).ShouldNot(BeNil())
Eventually(KameletList(ns)).ShouldNot(BeEmpty())
// on uninstall it should remove everything except kamelets
diff --git a/e2e/namespace/install/environment_test.go b/e2e/namespace/install/environment_test.go
index 1a4c34039..1ff40fab3 100644
--- a/e2e/namespace/install/environment_test.go
+++ b/e2e/namespace/install/environment_test.go
@@ -63,14 +63,15 @@ func TestEnvironmentTrait(t *testing.T) {
}
// Install Camel K with the HTTP proxy environment variable
- Expect(Kamel("install", "-n", ns,
+ operatorID := "camel-k-trait-environment"
+ Expect(KamelInstallWithID(operatorID, ns,
"--operator-env-vars", fmt.Sprintf("HTTP_PROXY=%s", httpProxy),
"--operator-env-vars", "NO_PROXY="+strings.Join(noProxy, ","),
).Execute()).To(Succeed())
t.Run("Run integration with default environment", func(t *testing.T) {
name := "java-default"
- Expect(Kamel("run", "-n", ns, "--name", name, "files/Java.java").Execute()).To(Succeed())
+ Expect(KamelRunWithID(operatorID, ns, "--name", name, "files/Java.java").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
@@ -96,7 +97,7 @@ func TestEnvironmentTrait(t *testing.T) {
t.Run("Run integration with custom environment", func(t *testing.T) {
name := "java-custom-proxy"
- Expect(Kamel("run", "-n", ns, "files/Java.java",
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
"--name", name,
"-t", "environment.vars=HTTP_PROXY=http://custom.proxy",
).Execute()).To(Succeed())
@@ -125,7 +126,7 @@ func TestEnvironmentTrait(t *testing.T) {
t.Run("Run integration without default HTTP proxy environment", func(t *testing.T) {
name := "java-no-proxy"
- Expect(Kamel("run", "-n", ns, "files/Java.java",
+ Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
"--name", name,
"-t", "environment.http-proxy=false",
).Execute()).To(Succeed())
diff --git a/e2e/namespace/install/maven_http_proxy_test.go b/e2e/namespace/install/maven_http_proxy_test.go
index 9cfb5c03e..3e0302366 100644
--- a/e2e/namespace/install/maven_http_proxy_test.go
+++ b/e2e/namespace/install/maven_http_proxy_test.go
@@ -176,10 +176,11 @@ func TestMavenProxy(t *testing.T) {
}()
// ENV values should be injected by the OLM
- Expect(Kamel("install", "-n", ns).Execute()).To(Succeed())
-
+ operatorID := "camel-k-maven-proxy"
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
} else {
- Expect(Kamel("install", "-n", ns,
+ operatorID := "camel-k-maven-proxy"
+ Expect(KamelInstallWithID(operatorID, ns,
"--operator-env-vars", fmt.Sprintf("HTTP_PROXY=http://%s", hostname),
// TODO: enable TLS for the HTTPS proxy when Maven supports it
// "--operator-env-vars", fmt.Sprintf("HTTPS_PROXY=https://%s", hostname),
@@ -192,7 +193,7 @@ func TestMavenProxy(t *testing.T) {
// Run the Integration
name := "java"
- Expect(Kamel("run", "-n", ns, "files/Java.java", "--name", name).Execute()).To(Succeed())
+ Expect(KamelRun(ns, "files/Java.java", "--name", name).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
diff --git a/e2e/namespace/install/operator_id_filtering_test.go b/e2e/namespace/install/operator_id_filtering_test.go
index 7df52e1c6..1f8fa0b0f 100644
--- a/e2e/namespace/install/operator_id_filtering_test.go
+++ b/e2e/namespace/install/operator_id_filtering_test.go
@@ -52,23 +52,25 @@ func TestOperatorIDFiltering(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
WithNewTestNamespace(t, func(nsop1 string) {
WithNewTestNamespace(t, func(nsop2 string) {
- Expect(Kamel("install", "-n", nsop1, "--operator-env-vars", "KAMEL_OPERATOR_ID=operator-1", "--global", "--force").Execute()).To(Succeed())
+ operator1 := "operator-1"
+ Expect(KamelInstallWithID(operator1, nsop1, "--global", "--force").Execute()).To(Succeed())
Eventually(PlatformPhase(nsop1), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady))
- Expect(Kamel("install", "-n", nsop2, "--operator-env-vars", "KAMEL_OPERATOR_ID=operator-2", "--global", "--force").Execute()).To(Succeed())
+ operator2 := "operator-2"
+ Expect(KamelInstallWithID(operator2, nsop2, "--global", "--force").Execute()).To(Succeed())
Eventually(PlatformPhase(nsop2), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady))
t.Run("Operators ignore non-scoped integrations", func(t *testing.T) {
RegisterTestingT(t)
- Expect(Kamel("run", "-n", ns, "files/yaml.yaml", "--name", "untouched").Execute()).To(Succeed())
+ Expect(KamelRun(ns, "files/yaml.yaml", "--name", "untouched").Execute()).To(Succeed())
Consistently(IntegrationPhase(ns, "untouched"), 10*time.Second).Should(BeEmpty())
})
t.Run("Operators run scoped integrations", func(t *testing.T) {
RegisterTestingT(t)
- Expect(Kamel("run", "-n", ns, "files/yaml.yaml", "--name", "moving").Execute()).To(Succeed())
+ Expect(KamelRun(ns, "files/yaml.yaml", "--name", "moving").Execute()).To(Succeed())
Expect(AssignIntegrationToOperator(ns, "moving", "operator-1")).To(Succeed())
Eventually(IntegrationPhase(ns, "moving"), TestTimeoutMedium).Should(Equal(v1.IntegrationPhaseRunning))
Eventually(IntegrationPodPhase(ns, "moving"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
@@ -105,7 +107,7 @@ func TestOperatorIDFiltering(t *testing.T) {
// Save resources by deleting "moving" integration
Expect(Kamel("delete", "moving", "-n", ns).Execute()).To(Succeed())
- Expect(Kamel("run", "-n", ns, "files/yaml.yaml", "--name", "pre-built", "-t", fmt.Sprintf("container.image=%s", image)).Execute()).To(Succeed())
+ Expect(KamelRun(ns, "files/yaml.yaml", "--name", "pre-built", "-t", fmt.Sprintf("container.image=%s", image)).Execute()).To(Succeed())
Consistently(IntegrationPhase(ns, "pre-built"), 10*time.Second).Should(BeEmpty())
Expect(AssignIntegrationToOperator(ns, "pre-built", "operator-2")).To(Succeed())
Eventually(IntegrationPhase(ns, "pre-built"), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseRunning))
@@ -117,7 +119,7 @@ func TestOperatorIDFiltering(t *testing.T) {
t.Run("Operators can run scoped kamelet bindings", func(t *testing.T) {
RegisterTestingT(t)
- Expect(Kamel("bind", "-n", ns, "timer-source?message=Hello", "log-sink", "--name", "klb").Execute()).To(Succeed())
+ Expect(KamelBind(ns, "timer-source?message=Hello", "log-sink", "--name", "klb").Execute()).To(Succeed())
Consistently(Integration(ns, "klb"), 10*time.Second).Should(BeNil())
Expect(AssignKameletBindingToOperator(ns, "klb", "operator-1")).To(Succeed())
diff --git a/e2e/namespace/native/native_test.go b/e2e/namespace/native/native_test.go
index 702d70617..91c2e939f 100644
--- a/e2e/namespace/native/native_test.go
+++ b/e2e/namespace/native/native_test.go
@@ -40,7 +40,8 @@ var (
func TestNativeIntegrations(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
- Expect(Kamel("install", "-n", ns,
+ operatorID := "camel-k-quarkus-native"
+ Expect(KamelInstallWithID(operatorID, ns,
"--build-timeout", "15m0s",
"--operator-resources", "limits.memory=4Gi",
).Execute()).To(Succeed())
@@ -48,7 +49,7 @@ func TestNativeIntegrations(t *testing.T) {
t.Run("unsupported integration source language", func(t *testing.T) {
name := "unsupported-java"
- Expect(Kamel("run", "-n", ns, "Java.java", "--name", name,
+ Expect(KamelRunWithID(operatorID, ns, "Java.java", "--name", name,
"-t", "quarkus.package-type=native",
).Execute()).To(Succeed())
@@ -58,7 +59,7 @@ func TestNativeIntegrations(t *testing.T) {
t.Run("automatic rollout deployment from fast-jar to native kit", func(t *testing.T) {
name := "jvm-to-native"
- Expect(Kamel("run", "-n", ns, "yaml.yaml", "--name", name,
+ Expect(KamelRunWithID(operatorID, ns, "yaml.yaml", "--name", name,
"-t", "quarkus.package-type=fast-jar",
"-t", "quarkus.package-type=native",
).Execute()).To(Succeed())
diff --git a/e2e/namespace/upgrade/cli_upgrade_test.go b/e2e/namespace/upgrade/cli_upgrade_test.go
index 6b6466abd..4c849cee4 100644
--- a/e2e/namespace/upgrade/cli_upgrade_test.go
+++ b/e2e/namespace/upgrade/cli_upgrade_test.go
@@ -51,7 +51,7 @@ func TestOperatorUpgrade(t *testing.T) {
Expect(os.Setenv("KAMEL_BIN", kamel)).To(Succeed())
// Should both install the CRDs and kamel in the given namespace
- Expect(Kamel("install", "--olm=false", "--force", "-n", ns).Execute()).To(Succeed())
+ Expect(Kamel("install", "-n", ns, "--olm=false", "--force").Execute()).To(Succeed())
// Check the operator pod is running
Eventually(OperatorPodPhase(ns), TestTimeoutMedium).Should(Equal(corev1.PodRunning))
@@ -64,9 +64,9 @@ func TestOperatorUpgrade(t *testing.T) {
// Run the Integration
name := "yaml"
- Expect(Kamel("run", "-n", ns, "files/yaml.yaml").Execute()).To(Succeed())
+ Expect(KamelRun(ns, "files/yaml.yaml").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutLong).Should(Equal(corev1.ConditionTrue))
// Check the Integration version
Eventually(IntegrationVersion(ns, name)).Should(Equal(version))
@@ -75,7 +75,7 @@ func TestOperatorUpgrade(t *testing.T) {
Expect(os.Setenv("KAMEL_BIN", "")).To(Succeed())
// Upgrade the operator by installing the current version
- Expect(Kamel("install", "-n", ns, "--olm=false", "--force", "--operator-image", image).Execute()).To(Succeed())
+ Expect(KamelInstall(ns, "--olm=false", "--force", "--operator-image", image).Execute()).To(Succeed())
// Check the operator image is the current built one
Eventually(OperatorImage(ns)).Should(Equal(image))
@@ -114,6 +114,6 @@ func TestOperatorUpgrade(t *testing.T) {
// Clean up
Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
- Expect(Kamel("uninstall", "--all", "--olm=false").Execute()).To(Succeed())
+ Expect(Kamel("uninstall", "--all", "-n", ns, "--olm=false").Execute()).To(Succeed())
})
}
diff --git a/e2e/namespace/upgrade/olm_upgrade_test.go b/e2e/namespace/upgrade/olm_upgrade_test.go
index 1a4427c52..cdcc5ef55 100644
--- a/e2e/namespace/upgrade/olm_upgrade_test.go
+++ b/e2e/namespace/upgrade/olm_upgrade_test.go
@@ -107,10 +107,10 @@ func TestOLMAutomaticUpgrade(t *testing.T) {
Eventually(PlatformVersion(ns)).Should(ContainSubstring(prevIPVersionPrefix))
name := "yaml"
- Expect(Kamel("run", "-n", ns, "files/yaml.yaml").Execute()).To(Succeed())
+ Expect(KamelRun(ns, "files/yaml.yaml").Execute()).To(Succeed())
// Check the Integration runs correctly
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutLong).Should(Equal(corev1.ConditionTrue))
// Check the Integration version matches that of the current operator
Expect(IntegrationVersion(ns, name)()).To(ContainSubstring(prevIPVersionPrefix))
@@ -193,13 +193,13 @@ func TestOLMAutomaticUpgrade(t *testing.T) {
// Check the Integration runs correctly
Eventually(IntegrationPodPhase(ns, name)).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutLong).Should(Equal(corev1.ConditionTrue))
// Clean up
Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
Expect(Kamel("uninstall", "-n", ns).Execute()).To(Succeed())
// Clean up cluster-wide resources that are not removed by OLM
- Expect(Kamel("uninstall", "--all", "--olm=false").Execute()).To(Succeed())
+ Expect(Kamel("uninstall", "--all", "-n", ns, "--olm=false").Execute()).To(Succeed())
})
})
}
diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index b7ab45f15..ec968fcb7 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -222,39 +222,95 @@ func Kamel(args ...string) *cobra.Command {
return KamelWithContext(TestContext, args...)
}
-func KamelInstall(ns string, opargs ...string) *cobra.Command {
- var args []string
+func KamelInstall(namespace string, args ...string) *cobra.Command {
+ return KamelInstallWithID(platform.DefaultPlatformName, namespace, args...)
+}
+
+func KamelInstallWithID(operatorID string, namespace string, args ...string) *cobra.Command {
+ return KamelInstallWithContext(TestContext, operatorID, namespace, args...)
+}
+
+func KamelInstallWithContext(ctx context.Context, operatorID string, namespace string, args ...string) *cobra.Command {
+ var installArgs []string
globalTest := os.Getenv("CAMEL_K_FORCE_GLOBAL_TEST") == "true"
if globalTest {
fmt.Printf("Executing as global test\n")
- opns := os.Getenv("CAMEL_K_GLOBAL_OPERATOR_NS")
- if opns == "" {
- err := errors.New("No operator namespace defined in CAMEL_K_GLOBAL_OPERATOR_NS")
+ if err := verifyGlobalOperator(); err != nil {
failTest(err)
}
- oppod := OperatorPod(opns)()
- if oppod == nil {
- err := fmt.Errorf("No operator pod detected in namespace %s. Operator install is a pre-requisite of the test", opns)
+ // Have a global operator pod watching all namespaces
+ // so ensure an integration platform is installed in target namespace
+ installArgs = []string{"install", "--skip-operator-setup", "-n", namespace}
+ } else {
+ // NOT global so proceed with local namespaced kamel install using the operator id
+ installArgs = []string{"install", "-n", namespace, "--operator-id", operatorID}
+ }
+
+ installArgs = append(installArgs, args...)
+ return KamelWithContext(ctx, installArgs...)
+}
+
+func KamelRun(namespace string, args ...string) *cobra.Command {
+ return KamelRunWithID(platform.DefaultPlatformName, namespace, args...)
+}
+
+func KamelRunWithID(operatorID string, namespace string, args ...string) *cobra.Command {
+ return KamelRunWithContext(TestContext, operatorID, namespace, args...)
+}
+
+func KamelRunWithContext(ctx context.Context, operatorID string, namespace string, args ...string) *cobra.Command {
+ return KamelCommandWithContext(ctx, "run", operatorID, namespace, args...)
+}
+
+func KamelBind(namespace string, args ...string) *cobra.Command {
+ return KamelBindWithID(platform.DefaultPlatformName, namespace, args...)
+}
+
+func KamelBindWithID(operatorID string, namespace string, args ...string) *cobra.Command {
+ return KamelBindWithContext(TestContext, operatorID, namespace, args...)
+}
+
+func KamelBindWithContext(ctx context.Context, operatorID string, namespace string, args ...string) *cobra.Command {
+ return KamelCommandWithContext(ctx, "bind", operatorID, namespace, args...)
+}
+
+func KamelCommandWithContext(ctx context.Context, command string, operatorID string, namespace string, args ...string) *cobra.Command {
+ var cmdArgs []string
+
+ globalTest := os.Getenv("CAMEL_K_FORCE_GLOBAL_TEST") == "true"
+ if globalTest {
+ fmt.Printf("Running as globally managed resource\n")
+
+ if err := verifyGlobalOperator(); err != nil {
failTest(err)
}
- //
- // Have a global operator pod watching all namespaces
- // so ensure an integration platform is installed in target namespace
- //
- args = []string{"install", "--skip-operator-setup", "-n", ns}
+ // Have a global operator reconciling the integration
+ cmdArgs = []string{command, "-n", namespace}
} else {
- //
- // NOT global so proceed with local namespaced kamel install
- //
- args = []string{"install", "-n", ns}
+ // NOT global so proceed with local namespaced operator reconciling the integration
+ cmdArgs = []string{command, "-n", namespace, "--operator-id", operatorID}
+ }
+
+ cmdArgs = append(cmdArgs, args...)
+ return KamelWithContext(ctx, cmdArgs...)
+}
+
+func verifyGlobalOperator() error {
+ opns := os.Getenv("CAMEL_K_GLOBAL_OPERATOR_NS")
+ if opns == "" {
+ return errors.New("No operator namespace defined in CAMEL_K_GLOBAL_OPERATOR_NS")
}
- args = append(args, opargs...)
- return Kamel(args...)
+ oppod := OperatorPod(opns)()
+ if oppod == nil {
+ return fmt.Errorf("No operator pod detected in namespace %s. Operator install is a pre-requisite of the test", opns)
+ }
+
+ return nil
}
func KamelWithContext(ctx context.Context, args ...string) *cobra.Command {
@@ -1218,6 +1274,16 @@ func BuildPhase(ns, name string) func() v1.BuildPhase {
}
}
+func HasPlatform(ns string) func() bool {
+ return func() bool {
+ lst := v1.NewIntegrationPlatformList()
+ if err := TestClient().List(TestContext, &lst, ctrl.InNamespace(ns)); err != nil {
+ return false
+ }
+ return len(lst.Items) > 0
+ }
+}
+
func Platform(ns string) func() *v1.IntegrationPlatform {
return func() *v1.IntegrationPlatform {
lst := v1.NewIntegrationPlatformList()
@@ -1847,13 +1913,26 @@ func userCleanup(t *testing.T) {
}
func invokeUserTestCode(t *testing.T, ns string, doRun func(string)) {
- defer func() {
+ globalTest := os.Getenv("CAMEL_K_FORCE_GLOBAL_TEST") == "true"
+
+ defer func(isGlobal bool) {
if t.Failed() {
if err := util.Dump(TestContext, TestClient(), ns, t); err != nil {
t.Logf("Error while dumping namespace %s: %v\n", ns, err)
}
}
- }()
+
+ // Try to clean up namespace
+ if !isGlobal && HasPlatform(ns)() {
+ t.Logf("Clean up test namespace: %s", ns)
+
+ if err := Kamel("uninstall", "-n", ns, "--skip-crd", "--skip-cluster-roles").Execute(); err != nil {
+ t.Logf("Error while cleaning up namespace %s: %v\n", ns, err)
+ }
+
+ t.Logf("Successfully cleaned up test namespace: %s", ns)
+ }
+ }(globalTest)
gomega.RegisterTestingT(t)
doRun(ns)
diff --git a/e2e/support/util/dump.go b/e2e/support/util/dump.go
index 79b007459..2a069c637 100644
--- a/e2e/support/util/dump.go
+++ b/e2e/support/util/dump.go
@@ -141,6 +141,14 @@ func Dump(ctx context.Context, c client.Client, ns string, t *testing.T) error {
t.Logf("\nFound %d pods:\n", len(lst.Items))
for _, pod := range lst.Items {
t.Logf("name=%s\n", pod.Name)
+
+ ref := pod
+ data, err := kubernetes.ToYAMLNoManagedFields(&ref)
+ if err != nil {
+ return err
+ }
+ t.Logf("---\n%s\n---\n", string(data))
+
dumpConditions(" ", pod.Status.Conditions, t)
t.Logf(" logs:\n")
var allContainers []corev1.Container
diff --git a/e2e/yaks/common/apache-kamelet-catalog/yaks-config.yaml b/e2e/yaks/common/apache-kamelet-catalog/yaks-config.yaml
index bbac09350..0f51eb08b 100644
--- a/e2e/yaks/common/apache-kamelet-catalog/yaks-config.yaml
+++ b/e2e/yaks/common/apache-kamelet-catalog/yaks-config.yaml
@@ -21,8 +21,12 @@ config:
pre:
- name: installation
run: |
- kamel install -w -n $YAKS_NAMESPACE
+ kamel install -w -n $YAKS_NAMESPACE --force
kubectl wait kamelets.camel.apache.org/timer-source --for=condition=Ready --timeout=120s -n $YAKS_NAMESPACE
kamel run logger.groovy -w -n $YAKS_NAMESPACE
+post:
+ - name: print dump
+ if: env:CI=true && failure()
+ run: yaks dump --includes app=camel-k
diff --git a/e2e/yaks/common/kamelet-beans/yaks-config.yaml b/e2e/yaks/common/kamelet-beans/yaks-config.yaml
index 22e1b0eaa..a4740932d 100644
--- a/e2e/yaks/common/kamelet-beans/yaks-config.yaml
+++ b/e2e/yaks/common/kamelet-beans/yaks-config.yaml
@@ -21,6 +21,10 @@ config:
pre:
- name: installation
run: |
- kamel install -n $YAKS_NAMESPACE
+ kamel install -n $YAKS_NAMESPACE --force
kubectl apply -f beans-source.kamelet.yaml -n $YAKS_NAMESPACE
+post:
+ - name: print dump
+ if: env:CI=true && failure()
+ run: yaks dump --includes app=camel-k
diff --git a/e2e/yaks/common/kamelet-binding-autoload/yaks-config.yaml b/e2e/yaks/common/kamelet-binding-autoload/yaks-config.yaml
index 378d23c32..aeb395279 100644
--- a/e2e/yaks/common/kamelet-binding-autoload/yaks-config.yaml
+++ b/e2e/yaks/common/kamelet-binding-autoload/yaks-config.yaml
@@ -21,9 +21,13 @@ config:
pre:
- name: installation
run: |
- kamel install -n $YAKS_NAMESPACE --operator-env-vars KAMEL_INSTALL_DEFAULT_KAMELETS=false
+ kamel install -n $YAKS_NAMESPACE --force --operator-env-vars KAMEL_INSTALL_DEFAULT_KAMELETS=false
kubectl apply -f secret-default.yaml -n $YAKS_NAMESPACE
kubectl apply -f secret-specific.yaml -n $YAKS_NAMESPACE
kubectl apply -f timer-source.kamelet.yaml -n $YAKS_NAMESPACE
+post:
+ - name: print dump
+ if: env:CI=true && failure()
+ run: yaks dump --includes app=camel-k
diff --git a/e2e/yaks/common/kamelet-binding-broker/yaks-config.yaml b/e2e/yaks/common/kamelet-binding-broker/yaks-config.yaml
index e1e609f07..c03bb0da8 100644
--- a/e2e/yaks/common/kamelet-binding-broker/yaks-config.yaml
+++ b/e2e/yaks/common/kamelet-binding-broker/yaks-config.yaml
@@ -25,7 +25,7 @@ pre:
oc label namespace $YAKS_NAMESPACE eventing.knative.dev/injection=enabled
oc label namespace $YAKS_NAMESPACE knative-eventing-injection=enabled
- kamel install -n $YAKS_NAMESPACE --operator-env-vars KAMEL_INSTALL_DEFAULT_KAMELETS=false
+ kamel install -n $YAKS_NAMESPACE --force --operator-env-vars KAMEL_INSTALL_DEFAULT_KAMELETS=false
kubectl apply -f timer-source.kamelet.yaml -n $YAKS_NAMESPACE
kubectl apply -f logger-sink.kamelet.yaml -n $YAKS_NAMESPACE
@@ -34,3 +34,7 @@ pre:
kubectl apply -f logger-sink-binding.yaml -n $YAKS_NAMESPACE
kubectl wait kameletbinding timer-source-binding --for=condition=Ready --timeout=15m -n $YAKS_NAMESPACE
kubectl wait kameletbinding logger-sink-binding --for=condition=Ready --timeout=15m -n $YAKS_NAMESPACE
+post:
+ - name: print dump
+ if: env:CI=true && failure()
+ run: yaks dump --includes app=camel-k
diff --git a/e2e/yaks/common/kamelet-binding-http/yaks-config.yaml b/e2e/yaks/common/kamelet-binding-http/yaks-config.yaml
index cf40990c7..0eb13b5a0 100644
--- a/e2e/yaks/common/kamelet-binding-http/yaks-config.yaml
+++ b/e2e/yaks/common/kamelet-binding-http/yaks-config.yaml
@@ -21,10 +21,14 @@ config:
pre:
- name: installation
run: |
- kamel install -n $YAKS_NAMESPACE --operator-env-vars KAMEL_INSTALL_DEFAULT_KAMELETS=false
+ kamel install -n $YAKS_NAMESPACE --force --operator-env-vars KAMEL_INSTALL_DEFAULT_KAMELETS=false
kubectl apply -f timer-source.kamelet.yaml -n $YAKS_NAMESPACE
kamel run display.groovy -w -n $YAKS_NAMESPACE
cat timer-source-binding-display.yaml | sed 's/{namespace}/'"${YAKS_NAMESPACE}"'/' | kubectl apply -n $YAKS_NAMESPACE -f -
kubectl wait kameletbinding timer-source-binding-display --for=condition=Ready --timeout=15m -n $YAKS_NAMESPACE
+post:
+ - name: print dump
+ if: env:CI=true && failure()
+ run: yaks dump --includes app=camel-k
diff --git a/e2e/yaks/common/kamelet-binding-property-encoding/yaks-config.yaml b/e2e/yaks/common/kamelet-binding-property-encoding/yaks-config.yaml
index 780da978f..3efa5ee15 100644
--- a/e2e/yaks/common/kamelet-binding-property-encoding/yaks-config.yaml
+++ b/e2e/yaks/common/kamelet-binding-property-encoding/yaks-config.yaml
@@ -21,7 +21,11 @@ config:
pre:
- name: installation
run: |
- kamel install -n $YAKS_NAMESPACE --operator-env-vars KAMEL_INSTALL_DEFAULT_KAMELETS=false
+ kamel install -n $YAKS_NAMESPACE --force --operator-env-vars KAMEL_INSTALL_DEFAULT_KAMELETS=false
kubectl apply -f timer-source.kamelet.yaml -n $YAKS_NAMESPACE
kubectl apply -f properties-binding.yaml -n $YAKS_NAMESPACE
+post:
+ - name: print dump
+ if: env:CI=true && failure()
+ run: yaks dump --includes app=camel-k
diff --git a/e2e/yaks/common/kamelet-binding/yaks-config.yaml b/e2e/yaks/common/kamelet-binding/yaks-config.yaml
index 9767a24e8..58f529385 100644
--- a/e2e/yaks/common/kamelet-binding/yaks-config.yaml
+++ b/e2e/yaks/common/kamelet-binding/yaks-config.yaml
@@ -21,7 +21,7 @@ config:
pre:
- name: installation
run: |
- kamel install -n $YAKS_NAMESPACE --operator-env-vars KAMEL_INSTALL_DEFAULT_KAMELETS=false
+ kamel install -n $YAKS_NAMESPACE --force --operator-env-vars KAMEL_INSTALL_DEFAULT_KAMELETS=false
kubectl apply -f messages-channel.yaml -n $YAKS_NAMESPACE
@@ -33,3 +33,7 @@ pre:
kubectl wait kameletbinding timer-source-binding --for=condition=Ready --timeout=10m -n $YAKS_NAMESPACE
kubectl wait kameletbinding logger-sink-binding --for=condition=Ready --timeout=10m -n $YAKS_NAMESPACE
+post:
+ - name: print dump
+ if: env:CI=true && failure()
+ run: yaks dump --includes app=camel-k
diff --git a/e2e/yaks/common/kamelet-no-properties/kamelet-no-props.feature b/e2e/yaks/common/kamelet-no-properties/kamelet-no-props.feature
index 17a01042e..6f6b42afc 100644
--- a/e2e/yaks/common/kamelet-no-properties/kamelet-no-props.feature
+++ b/e2e/yaks/common/kamelet-no-properties/kamelet-no-props.feature
@@ -19,7 +19,6 @@ from:
"""
Then Kamelet no-props-source should be available
-
Scenario: Bind Kamelet to service
Given create Kubernetes service greeting-service with target port 8080
And bind Kamelet no-props-source to uri log:info
diff --git a/e2e/yaks/common/kamelet-no-properties/yaks-config.yaml b/e2e/yaks/common/kamelet-no-properties/yaks-config.yaml
index 95d9bf95a..0848b4b3f 100644
--- a/e2e/yaks/common/kamelet-no-properties/yaks-config.yaml
+++ b/e2e/yaks/common/kamelet-no-properties/yaks-config.yaml
@@ -21,4 +21,8 @@ config:
pre:
- name: installation
run: |
- kamel install -n $YAKS_NAMESPACE
+ kamel install -n $YAKS_NAMESPACE --force
+post:
+ - name: print dump
+ if: env:CI=true && failure()
+ run: yaks dump --includes app=camel-k
diff --git a/e2e/yaks/common/kamelet-steps/yaks-config.yaml b/e2e/yaks/common/kamelet-steps/yaks-config.yaml
index 54886a467..04a18d74c 100644
--- a/e2e/yaks/common/kamelet-steps/yaks-config.yaml
+++ b/e2e/yaks/common/kamelet-steps/yaks-config.yaml
@@ -21,10 +21,14 @@ config:
pre:
- name: installation
run: |
- kamel install -n $YAKS_NAMESPACE --operator-env-vars KAMEL_INSTALL_DEFAULT_KAMELETS=false
+ kamel install -n $YAKS_NAMESPACE --force --operator-env-vars KAMEL_INSTALL_DEFAULT_KAMELETS=false
kubectl apply -f timer-source.kamelet.yaml -n $YAKS_NAMESPACE
kubectl apply -f prefix-action.kamelet.yaml -n $YAKS_NAMESPACE
kubectl apply -f steps-binding.yaml -n $YAKS_NAMESPACE
kubectl wait kameletbinding steps-binding --for=condition=Ready --timeout=10m -n $YAKS_NAMESPACE
+post:
+ - name: print dump
+ if: env:CI=true && failure()
+ run: yaks dump --includes app=camel-k
diff --git a/e2e/yaks/common/kamelet/yaks-config.yaml b/e2e/yaks/common/kamelet/yaks-config.yaml
index dd94f104d..51c3bcd1a 100644
--- a/e2e/yaks/common/kamelet/yaks-config.yaml
+++ b/e2e/yaks/common/kamelet/yaks-config.yaml
@@ -21,9 +21,13 @@ config:
pre:
- name: installation
run: |
- kamel install -n $YAKS_NAMESPACE --operator-env-vars KAMEL_INSTALL_DEFAULT_KAMELETS=false
+ kamel install -n $YAKS_NAMESPACE --operator-env-vars KAMEL_INSTALL_DEFAULT_KAMELETS=false --force
kubectl apply -f timer-source.kamelet.yaml -n $YAKS_NAMESPACE
kubectl apply -f echo-sink.kamelet.yaml -n $YAKS_NAMESPACE
kamel run source-sink.groovy -w -n $YAKS_NAMESPACE
+post:
+ - name: print dump
+ if: env:CI=true && failure()
+ run: yaks dump --includes app=camel-k
diff --git a/e2e/yaks/common/knative-broker/yaks-config.yaml b/e2e/yaks/common/knative-broker/yaks-config.yaml
index 95d9bf95a..0848b4b3f 100644
--- a/e2e/yaks/common/knative-broker/yaks-config.yaml
+++ b/e2e/yaks/common/knative-broker/yaks-config.yaml
@@ -21,4 +21,8 @@ config:
pre:
- name: installation
run: |
- kamel install -n $YAKS_NAMESPACE
+ kamel install -n $YAKS_NAMESPACE --force
+post:
+ - name: print dump
+ if: env:CI=true && failure()
+ run: yaks dump --includes app=camel-k
diff --git a/e2e/yaks/common/knative-sinkbinding/yaks-config.yaml b/e2e/yaks/common/knative-sinkbinding/yaks-config.yaml
index aed4c9471..deea4a8e5 100644
--- a/e2e/yaks/common/knative-sinkbinding/yaks-config.yaml
+++ b/e2e/yaks/common/knative-sinkbinding/yaks-config.yaml
@@ -21,7 +21,7 @@ config:
pre:
- name: installation
run: |
- kamel install -n $YAKS_NAMESPACE
+ kamel install -n $YAKS_NAMESPACE --force
kubectl apply -n $YAKS_NAMESPACE -f messages-channel.yaml
@@ -29,3 +29,7 @@ pre:
kamel run source.yaml -w -n $YAKS_NAMESPACE -t knative.sink-binding=true
kubectl wait integration --all --for=condition=Ready --timeout=10m -n $YAKS_NAMESPACE
+post:
+ - name: print dump
+ if: env:CI=true && failure()
+ run: yaks dump --includes app=camel-k
diff --git a/pkg/cmd/install.go b/pkg/cmd/install.go
index 2176f22db..42e76c557 100644
--- a/pkg/cmd/install.go
+++ b/pkg/cmd/install.go
@@ -312,7 +312,11 @@ func (o *installCmdOptions) install(cobraCmd *cobra.Command, _ []string) error {
if !o.SkipOperatorSetup && !installViaOLM {
if ok, err := isInstallAllowed(o.Context, c, platformName, o.Force, cobraCmd.OutOrStdout()); err != nil {
- return err
+ if k8serrors.IsForbidden(err) {
+ o.PrintfVerboseOutf(cobraCmd, "Unable to verify existence of operator id [%s] due to lack of user privileges\n", platformName)
+ } else {
+ return err
+ }
} else if !ok {
return fmt.Errorf("installation not allowed because operator with id '%s' already exists, use the --force option to skip this check", platformName)
}
diff --git a/pkg/cmd/operator.go b/pkg/cmd/operator.go
index 9bb66a51f..5a0129a71 100644
--- a/pkg/cmd/operator.go
+++ b/pkg/cmd/operator.go
@@ -18,7 +18,6 @@ limitations under the License.
package cmd
import (
- "fmt"
"github.com/apache/camel-k/pkg/platform"
"github.com/apache/camel-k/pkg/util/defaults"
"github.com/spf13/cobra"
@@ -60,7 +59,7 @@ func (o *operatorCmdOptions) run(_ *cobra.Command, _ []string) {
leaderElectionID := o.LeaderElectionID
if leaderElectionID == "" {
if defaults.OperatorID() != "" {
- leaderElectionID = fmt.Sprintf("%s-lock", defaults.OperatorID())
+ leaderElectionID = platform.GetOperatorLockName(defaults.OperatorID())
} else {
leaderElectionID = platform.OperatorLockName
}
diff --git a/pkg/cmd/uninstall.go b/pkg/cmd/uninstall.go
index e225ccc50..029ca2717 100644
--- a/pkg/cmd/uninstall.go
+++ b/pkg/cmd/uninstall.go
@@ -273,7 +273,7 @@ func (o *uninstallCmdOptions) uninstallNamespaceResources(ctx context.Context, c
if err := o.uninstallKamelets(ctx, c); err != nil {
return err
}
- fmt.Fprintln(cmd.OutOrStdout(), "Camel K platform Kamelets removed from namespace", o.Namespace)
+ fmt.Fprintln(cmd.OutOrStdout(), "Camel K Platform Kamelets removed from namespace", o.Namespace)
}
return nil
@@ -474,7 +474,7 @@ func (o *uninstallCmdOptions) uninstallKamelets(ctx context.Context, c client.Cl
}
for i := range kameletList.Items {
- // remove only platform Kamelets (use-defined Kamelets should be skipped)
+ // remove only platform Kamelets (user-defined Kamelets should be skipped)
if kameletList.Items[i].Labels[v1alpha1.KameletBundledLabel] == "true" {
err := c.Delete(ctx, &kameletList.Items[i])
if err != nil {
diff --git a/pkg/controller/integration/monitor.go b/pkg/controller/integration/monitor.go
index 412c07cef..c2f645948 100644
--- a/pkg/controller/integration/monitor.go
+++ b/pkg/controller/integration/monitor.go
@@ -27,7 +27,6 @@ import (
appsv1 "k8s.io/api/apps/v1"
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
- "k8s.io/apimachinery/pkg/api/equality"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/selection"
@@ -297,7 +296,7 @@ func filterPodsByReadyStatus(runningPods []corev1.Pod, podSpec corev1.PodSpec) (
for _, pod := range runningPods {
// We compare the Integration PodSpec to that of the Pod in order to make
// sure we account for up-to-date version.
- if !equality.Semantic.DeepDerivative(podSpec, pod.Spec) {
+ if !comparePodSpec(podSpec, pod.Spec) {
continue
}
ready := kubernetes.GetPodCondition(pod, corev1.PodReady)
@@ -319,6 +318,48 @@ func filterPodsByReadyStatus(runningPods []corev1.Pod, podSpec corev1.PodSpec) (
return readyPods, unreadyPods
}
+// comparePodSpec compares given pod spec according to integration specific information (e.g. digest, container image).
+func comparePodSpec(runningPodSpec corev1.PodSpec, referencePod corev1.PodSpec) bool {
+ runningPodContainer := findIntegrationContainer(runningPodSpec)
+ referencePodContainer := findIntegrationContainer(referencePod)
+
+ if runningPodContainer == nil || referencePodContainer == nil {
+ return false
+ }
+
+ // integration digest must be the same
+ if getIntegrationDigest(runningPodContainer.Env) != getIntegrationDigest(referencePodContainer.Env) {
+ return false
+ }
+
+ // integration container image must be the same (same integration kit)
+ if runningPodContainer.Image != referencePodContainer.Image {
+ return false
+ }
+
+ return true
+}
+
+func getIntegrationDigest(envs []corev1.EnvVar) string {
+ for _, env := range envs {
+ if env.Name == digest.IntegrationDigestEnvVar {
+ return env.Value
+ }
+ }
+
+ return ""
+}
+
+func findIntegrationContainer(spec corev1.PodSpec) *corev1.Container {
+ for _, c := range spec.Containers {
+ if c.Name == "integration" {
+ return &c
+ }
+ }
+
+ return nil
+}
+
// probeReadiness calls the readiness probes of the non-ready Pods directly to retrieve insights from the Camel runtime.
func (action *monitorAction) probeReadiness(ctx context.Context, environment *trait.Environment, integration *v1.Integration, unreadyPods []corev1.Pod) error {
var runtimeNotReadyMessages []string
diff --git a/pkg/platform/operator.go b/pkg/platform/operator.go
index 95e3bad68..2f6f2cff6 100644
--- a/pkg/platform/operator.go
+++ b/pkg/platform/operator.go
@@ -75,6 +75,11 @@ func GetOperatorPodName() string {
return ""
}
+// GetOperatorLockName returns the name of the lock lease that is electing a leader on the particular namepsace.
+func GetOperatorLockName(operatorID string) string {
+ return fmt.Sprintf("%s-lock", operatorID)
+}
+
// IsNamespaceLocked tells if the namespace contains a lock indicating that an operator owns it.
func IsNamespaceLocked(ctx context.Context, c ctrl.Reader, namespace string) (bool, error) {
if namespace == "" {
@@ -91,7 +96,7 @@ func IsNamespaceLocked(ctx context.Context, c ctrl.Reader, namespace string) (bo
var operatorLockName string
if platform.Name != "" {
- operatorLockName = fmt.Sprintf("%s-lock", platform.Name)
+ operatorLockName = GetOperatorLockName(platform.Name)
} else {
operatorLockName = OperatorLockName
}
diff --git a/pkg/platform/platform.go b/pkg/platform/platform.go
index 84119b696..83acfc3c8 100644
--- a/pkg/platform/platform.go
+++ b/pkg/platform/platform.go
@@ -21,7 +21,6 @@ import (
"context"
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
- "github.com/apache/camel-k/pkg/util/defaults"
"github.com/apache/camel-k/pkg/util/kubernetes"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
k8sclient "sigs.k8s.io/controller-runtime/pkg/client"
@@ -74,19 +73,10 @@ func getOrFindForResource(ctx context.Context, c k8sclient.Reader, o k8sclient.O
return get(ctx, c, o.GetNamespace(), selectedPlatform)
}
- platformName := defaults.OperatorID()
if it, ok := o.(*v1.Integration); ok {
- if it.Status.Platform != "" {
- platformName = it.Status.Platform
- }
-
- return getOrFind(ctx, c, it.Namespace, platformName, active, local)
+ return getOrFind(ctx, c, it.Namespace, it.Status.Platform, active, local)
} else if ik, ok := o.(*v1.IntegrationKit); ok {
- if ik.Status.Platform != "" {
- platformName = ik.Status.Platform
- }
-
- return getOrFind(ctx, c, ik.Namespace, platformName, active, local)
+ return getOrFind(ctx, c, ik.Namespace, ik.Status.Platform, active, local)
}
return find(ctx, c, o.GetNamespace(), active, local)
}
@@ -110,7 +100,7 @@ func getOrFindAny(ctx context.Context, c k8sclient.Reader, namespace string, nam
// getOrFindLocal returns the named platform or any other platform in the local namespace.
func getOrFindLocal(ctx context.Context, c k8sclient.Reader, namespace string, name string, active bool) (*v1.IntegrationPlatform, error) {
if name != "" {
- return kubernetes.GetIntegrationPlatform(ctx, c, name, namespace)
+ return get(ctx, c, name, namespace)
}
return findLocal(ctx, c, namespace, active)
diff --git a/pkg/trait/container.go b/pkg/trait/container.go
index 522120218..33ab614dc 100644
--- a/pkg/trait/container.go
+++ b/pkg/trait/container.go
@@ -35,6 +35,7 @@ import (
"github.com/apache/camel-k/pkg/util"
"github.com/apache/camel-k/pkg/util/camel"
"github.com/apache/camel-k/pkg/util/defaults"
+ "github.com/apache/camel-k/pkg/util/digest"
"github.com/apache/camel-k/pkg/util/envvar"
"github.com/apache/camel-k/pkg/util/kubernetes"
)
@@ -166,7 +167,7 @@ func (t *containerTrait) configureContainer(e *Environment) error {
envvar.SetVal(&container.Env, env.Name, env.Value)
}
- envvar.SetVal(&container.Env, "CAMEL_K_DIGEST", e.Integration.Status.Digest)
+ envvar.SetVal(&container.Env, digest.IntegrationDigestEnvVar, e.Integration.Status.Digest)
envvar.SetVal(&container.Env, "CAMEL_K_CONF", path.Join(camel.BasePath, "application.properties"))
envvar.SetVal(&container.Env, "CAMEL_K_CONF_D", camel.ConfDPath)
diff --git a/pkg/trait/pod_test.go b/pkg/trait/pod_test.go
index 20bb944b9..7c7c3422e 100755
--- a/pkg/trait/pod_test.go
+++ b/pkg/trait/pod_test.go
@@ -30,6 +30,7 @@ import (
"k8s.io/utils/pointer"
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
+ "github.com/apache/camel-k/pkg/util/digest"
"github.com/apache/camel-k/pkg/util/kubernetes"
)
@@ -85,7 +86,7 @@ func TestChangeEnvVariables(t *testing.T) {
assert.Equal(t, 3, len(getContainer(templateSpec.Spec.Containers, "second").Env))
// Check if env var was changed
- assert.Equal(t, containsEnvVariables(templateSpec, "integration", "CAMEL_K_DIGEST"), "new_value")
+ assert.Equal(t, containsEnvVariables(templateSpec, "integration", digest.IntegrationDigestEnvVar), "new_value")
}
func TestSupplementalGroup(t *testing.T) {
@@ -128,7 +129,7 @@ func createPodTest(podSpecTemplate string) (*podTrait, *Environment, *appsv1.Dep
Name: "integration",
Env: []corev1.EnvVar{
{
- Name: "CAMEL_K_DIGEST",
+ Name: digest.IntegrationDigestEnvVar,
Value: "vO3wwJHC7-uGEiFFVac0jq6rZT5EZNw56Ae5gKKFZZsk",
},
{
diff --git a/pkg/util/digest/digest.go b/pkg/util/digest/digest.go
index 3653b6ed9..02a060411 100644
--- a/pkg/util/digest/digest.go
+++ b/pkg/util/digest/digest.go
@@ -38,6 +38,10 @@ import (
"github.com/apache/camel-k/pkg/util/dsl"
)
+const (
+ IntegrationDigestEnvVar = "CAMEL_K_DIGEST"
+)
+
// ComputeForIntegration a digest of the fields that are relevant for the deployment
// Produces a digest that can be used as docker image tag.
func ComputeForIntegration(integration *v1.Integration) (string, error) {
[camel-k] 08/17: Fix #2177: Introduce integration platform viewer role
Posted by as...@apache.org.
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 4e6a2db1614901a65ad1df9858a957b26e0f91d2
Author: Christoph Deppisch <cd...@redhat.com>
AuthorDate: Fri Jun 3 21:04:59 2022 +0200
Fix #2177: Introduce integration platform viewer role
- Integration platforms need to be visible to authenticated users in order to verify operator ids
- Add integration platform viewer role in all namespaces that hold at least one integration platform so users can get and list these platform instances
- Automatically add the role during kamel CLI installation and in platform trait
---
pkg/cmd/install.go | 4 +++
pkg/install/platform.go | 32 +++++++++++++++++++
pkg/platform/platform.go | 13 +++++++-
pkg/resources/resources.go | 16 ++++++++++
pkg/trait/platform.go | 14 +++++++++
.../user-global-platform-viewer-role-binding.yaml | 35 +++++++++++++++++++++
.../viewer/user-global-platform-viewer-role.yaml | 36 ++++++++++++++++++++++
7 files changed, 149 insertions(+), 1 deletion(-)
diff --git a/pkg/cmd/install.go b/pkg/cmd/install.go
index 368eaeb31..1efba233e 100644
--- a/pkg/cmd/install.go
+++ b/pkg/cmd/install.go
@@ -485,6 +485,10 @@ func (o *installCmdOptions) install(cobraCmd *cobra.Command, _ []string) error {
return err
}
+ if err := install.IntegrationPlatformViewerRole(o.Context, c, namespace); err != nil && !k8serrors.IsAlreadyExists(err) {
+ return errors.Wrap(err, "Error while installing global IntegrationPlatform viewer role")
+ }
+
if o.ExampleSetup {
err = install.ExampleOrCollect(o.Context, c, namespace, collection, o.Force)
if err != nil {
diff --git a/pkg/install/platform.go b/pkg/install/platform.go
new file mode 100644
index 000000000..9a087d077
--- /dev/null
+++ b/pkg/install/platform.go
@@ -0,0 +1,32 @@
+/*
+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 install
+
+import (
+ "context"
+
+ "github.com/apache/camel-k/pkg/client"
+)
+
+// IntegrationPlatformViewerRole installs the role that allows any user ro access integrationplatforms in the global namespace.
+func IntegrationPlatformViewerRole(ctx context.Context, c client.Client, namespace string) error {
+ if err := Resource(ctx, c, namespace, true, IdentityResourceCustomizer, "/viewer/user-global-platform-viewer-role.yaml"); err != nil {
+ return err
+ }
+ return Resource(ctx, c, namespace, true, IdentityResourceCustomizer, "/viewer/user-global-platform-viewer-role-binding.yaml")
+}
diff --git a/pkg/platform/platform.go b/pkg/platform/platform.go
index 8d27391e4..8b5f5c9c1 100644
--- a/pkg/platform/platform.go
+++ b/pkg/platform/platform.go
@@ -21,6 +21,7 @@ import (
"context"
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
+ "github.com/apache/camel-k/pkg/util/defaults"
"github.com/apache/camel-k/pkg/util/kubernetes"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
k8sclient "sigs.k8s.io/controller-runtime/pkg/client"
@@ -68,9 +69,19 @@ func getOrFindForResource(ctx context.Context, c k8sclient.Reader, o k8sclient.O
if selectedPlatform, ok := o.GetAnnotations()[v1.PlatformSelectorAnnotation]; ok {
return get(ctx, c, o.GetNamespace(), selectedPlatform)
}
+
+ platformName := defaults.OperatorID()
if it, ok := o.(*v1.Integration); ok {
- return getOrFind(ctx, c, it.Namespace, it.Status.Platform, active, local)
+ if it.Status.Platform != "" {
+ platformName = it.Status.Platform
+ }
+
+ return getOrFind(ctx, c, it.Namespace, platformName, active, local)
} else if ik, ok := o.(*v1.IntegrationKit); ok {
+ if ik.Status.Platform != "" {
+ platformName = ik.Status.Platform
+ }
+
return getOrFind(ctx, c, ik.Namespace, ik.Status.Platform, active, local)
}
return find(ctx, c, o.GetNamespace(), active, local)
diff --git a/pkg/resources/resources.go b/pkg/resources/resources.go
index 2b685329a..ef9cad184 100644
--- a/pkg/resources/resources.go
+++ b/pkg/resources/resources.go
@@ -580,6 +580,20 @@ var assets = func() http.FileSystem {
compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xac\x53\x4d\x8f\xdb\x36\x14\xbc\xf3\x57\x0c\xac\x4b\x02\xac\xe5\xb6\xa7\xc2\x3d\xb9\x9b\xdd\x56\x68\x60\x03\x2b\xa7\x41\x8e\xcf\xd4\xb3\xf4\x60\x8a\x4f\x25\xa9\x55\xb6\xbf\xbe\xa0\x2c\x67\x37\xe8\x35\xbc\xf8\x43\xa3\x79\x33\x6f\x86\x05\xd6\x3f\xee\x98\x02\x1f\xc5\xb2\x8f\xdc\x20\x29\x52\xc7\xd8\x0d\x64\x3b\x46\xad\xe7\x34\x51\x60\x3c\xea\xe8\x1b\x4a\xa2\x1e\xef\x76\xf5\xe3\x7b\x8c\xbe\xe1\x00\xf5\x0c\x0d\xe8\x35\xb0\x [...]
},
+ "/viewer/user-global-platform-viewer-role-binding.yaml": &vfsgen۰CompressedFileInfo{
+ name: "user-global-platform-viewer-role-binding.yaml",
+ modTime: time.Time{},
+ uncompressedSize: 1348,
+
+ compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xac\x53\x4d\x8f\xdb\x36\x10\xbd\xf3\x57\x3c\x58\x97\x04\x58\xcb\x6d\x4f\x85\x7b\x72\x36\xbb\xad\xd0\xc0\x06\x2c\xa7\x41\x8e\x63\x6a\x2c\x4d\x97\x22\x59\x92\x5a\xc5\xfd\xf5\x05\xb9\x76\x76\x83\x02\x2d\x02\xac\x6e\x02\x87\xef\x63\xde\x63\x85\xe5\xeb\x7d\xaa\xc2\x07\xd1\x6c\x23\x77\x48\x0e\x69\x60\x6c\x3c\xe9\x81\xd1\xba\x53\x9a\x29\x30\xee\xdd\x64\x3b\x4a\xe2\x2c\xde\x6c\xda\xfb\xb7\x98\x6c\xc7\x01\xce\x32\x5c\xc0\xe8\x [...]
+ },
+ "/viewer/user-global-platform-viewer-role.yaml": &vfsgen۰CompressedFileInfo{
+ name: "user-global-platform-viewer-role.yaml",
+ modTime: time.Time{},
+ uncompressedSize: 1287,
+
+ compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xac\x53\xc1\x8e\xdb\x36\x14\xbc\xf3\x2b\x06\xd6\x25\x01\xd6\x72\xdb\x53\xe1\x9e\xdc\xcd\x6e\x2b\x34\xb0\x81\x95\xd3\x20\xc7\x67\xe9\x59\x7a\x58\x8a\x54\x1f\xa9\x55\xb6\x5f\x5f\x90\x96\xbb\x0e\xda\x63\x78\xb1\x05\x8d\xe6\xcd\xbc\x19\x16\x58\x7f\xbf\x63\x0a\x7c\x94\x86\x5d\xe0\x16\xd1\x23\xf6\x8c\xdd\x48\x4d\xcf\xa8\xfd\x39\xce\xa4\x8c\x47\x3f\xb9\x96\xa2\x78\x87\x77\xbb\xfa\xf1\x3d\x26\xd7\xb2\xc2\x3b\x86\x57\x0c\x5e\x [...]
+ },
"/camel-catalog-1.13.0.yaml": &vfsgen۰CompressedFileInfo{
name: "camel-catalog-1.13.0.yaml",
modTime: time.Time{},
@@ -707,6 +721,8 @@ var assets = func() http.FileSystem {
fs["/viewer"].(*vfsgen۰DirInfo).entries = []os.FileInfo{
fs["/viewer/user-global-kamelet-viewer-role-binding.yaml"].(os.FileInfo),
fs["/viewer/user-global-kamelet-viewer-role.yaml"].(os.FileInfo),
+ fs["/viewer/user-global-platform-viewer-role-binding.yaml"].(os.FileInfo),
+ fs["/viewer/user-global-platform-viewer-role.yaml"].(os.FileInfo),
}
return fs
diff --git a/pkg/trait/platform.go b/pkg/trait/platform.go
index 263b76add..5ee3759db 100644
--- a/pkg/trait/platform.go
+++ b/pkg/trait/platform.go
@@ -18,12 +18,16 @@ limitations under the License.
package trait
import (
+ "fmt"
+
k8serrors "k8s.io/apimachinery/pkg/api/errors"
"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"
+ "github.com/apache/camel-k/pkg/install"
"github.com/apache/camel-k/pkg/platform"
+ "github.com/apache/camel-k/pkg/util/defaults"
"github.com/apache/camel-k/pkg/util/openshift"
)
@@ -95,6 +99,10 @@ func (t *platformTrait) getOrCreatePlatform(e *Environment) (*v1.IntegrationPlat
if err != nil && k8serrors.IsNotFound(err) {
if pointer.BoolDeref(t.CreateDefault, false) {
platformName := e.Integration.Status.Platform
+ if platformName == "" {
+ platformName = defaults.OperatorID()
+ }
+
if platformName == "" {
platformName = platform.DefaultPlatformName
}
@@ -119,6 +127,12 @@ func (t *platformTrait) getOrCreatePlatform(e *Environment) (*v1.IntegrationPlat
}
pl = &defaultPlatform
e.Resources.Add(pl)
+
+ // Make sure that IntegrationPlatform installed in operator namespace can be seen by others
+ if err := install.IntegrationPlatformViewerRole(e.Ctx, t.Client, namespace); err != nil && !k8serrors.IsAlreadyExists(err) {
+ t.L.Info(fmt.Sprintf("Cannot install global IntegrationPlatform viewer role in namespace '%s': skipping.", namespace))
+ }
+
return pl, nil
}
}
diff --git a/resources/viewer/user-global-platform-viewer-role-binding.yaml b/resources/viewer/user-global-platform-viewer-role-binding.yaml
new file mode 100644
index 000000000..6d13f8a6b
--- /dev/null
+++ b/resources/viewer/user-global-platform-viewer-role-binding.yaml
@@ -0,0 +1,35 @@
+# ---------------------------------------------------------------------------
+# 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.
+# ---------------------------------------------------------------------------
+
+#
+# RoleBinding installed in the operator namespace
+# to allow access to integrationplatforms
+#
+apiVersion: rbac.authorization.k8s.io/v1
+kind: RoleBinding
+metadata:
+ name: camel-k-platform-viewer
+ labels:
+ app: "camel-k"
+roleRef:
+ apiGroup: rbac.authorization.k8s.io
+ kind: Role
+ name: camel-k-platform-viewer
+subjects:
+- apiGroup: rbac.authorization.k8s.io
+ kind: Group
+ name: system:authenticated
diff --git a/resources/viewer/user-global-platform-viewer-role.yaml b/resources/viewer/user-global-platform-viewer-role.yaml
new file mode 100644
index 000000000..d5a1b8e18
--- /dev/null
+++ b/resources/viewer/user-global-platform-viewer-role.yaml
@@ -0,0 +1,36 @@
+# ---------------------------------------------------------------------------
+# 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.
+# ---------------------------------------------------------------------------
+
+#
+# Role installed in the operator namespace
+# to allow access to operator installed integrationplatforms
+#
+apiVersion: rbac.authorization.k8s.io/v1
+kind: Role
+metadata:
+ name: camel-k-platform-viewer
+ labels:
+ app: "camel-k"
+rules:
+- apiGroups:
+ - "camel.apache.org"
+ resources:
+ - integrationplatforms
+ verbs:
+ - get
+ - list
+ - watch
[camel-k] 17/17: fix(#2177): Remove obsolete kamel-install GitHub action
Posted by as...@apache.org.
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 0e51e5bdfc788fefd32c2908d1af7efb73f4b912
Author: Christoph Deppisch <cd...@redhat.com>
AuthorDate: Tue Jul 5 15:59:12 2022 +0200
fix(#2177): Remove obsolete kamel-install GitHub action
In favor of using kamel-install-global-operator action
---
.github/actions/kamel-install/action.yml | 64 ---------------
.github/actions/kamel-install/install.sh | 133 -------------------------------
2 files changed, 197 deletions(-)
diff --git a/.github/actions/kamel-install/action.yml b/.github/actions/kamel-install/action.yml
deleted file mode 100644
index 235a78801..000000000
--- a/.github/actions/kamel-install/action.yml
+++ /dev/null
@@ -1,64 +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.
-# ---------------------------------------------------------------------------
-
-name: kamel-install
-description: 'Execute kamel to install the Camel K operator'
-
-inputs:
- kube-admin-user-ctx:
- description: "The administration user context of the cluster"
- required: true
- build-catalog-source:
- description: "The name of the bundle catalog (only installed in the cluster if OLM is used)"
- required: false
- image-namespace:
- description: 'Namespace in which the image is stored'
- required: true
- image-registry-host:
- description: 'Location of image registry host'
- required: true
- image-name:
- description: 'Reference of the camel-k image'
- required: true
- image-registry-insecure:
- description: "Whether the registry is insecure"
- required: true
- image-version:
- description: "Reference of the camel-k image version"
- required: true
-
-runs:
- using: "composite"
- steps:
- - id: execute-kamel
- name: Install Camel K
- shell: bash
- run: |
- ./.github/actions/kamel-install/install.sh \
- -a "${{ inputs.kube-admin-user-ctx }}" \
- -c "${{ inputs.build-catalog-source }}" \
- -i "${{ inputs.image-namespace }}" \
- -l "${{ inputs.image-registry-host }}" \
- -n "${{ inputs.image-name }}" \
- -s "${{ inputs.image-registry-insecure }}" \
- -v "${{ inputs.image-version }}"
-
- - id: post-execution
- shell: bash
- run: |
- rm -f /tmp/config
- export -n KUBECONFIG
diff --git a/.github/actions/kamel-install/install.sh b/.github/actions/kamel-install/install.sh
deleted file mode 100755
index 3cc1ba5da..000000000
--- a/.github/actions/kamel-install/install.sh
+++ /dev/null
@@ -1,133 +0,0 @@
-#!/bin/bash
-
-# ---------------------------------------------------------------------------
-# 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.
-# ---------------------------------------------------------------------------
-
-####
-#
-# Install Camel K using the admin context
-#
-####
-
-set -e
-
-while getopts ":a:c:i:l:n:s:v:" opt; do
- case "${opt}" in
- a)
- KUBE_ADMIN_CTX=${OPTARG}
- ;;
- c)
- BUILD_CATALOG_SOURCE=${OPTARG}
- ;;
- i)
- IMAGE_NAMESPACE=${OPTARG}
- ;;
- l)
- REGISTRY_PULL_HOST=${OPTARG}
- ;;
- n)
- IMAGE_NAME=${OPTARG}
- ;;
- s)
- REGISTRY_INSECURE=${OPTARG}
- ;;
- v)
- IMAGE_VERSION=${OPTARG}
- ;;
- :)
- echo "ERROR: Option -$OPTARG requires an argument"
- exit 1
- ;;
- \?)
- echo "ERROR: Invalid option -$OPTARG"
- exit 1
- ;;
- esac
-done
-shift $((OPTIND-1))
-
-if [ -z "${KUBE_ADMIN_CTX}" ]; then
- echo "Error: kube-admin-user-ctx not defined"
- exit 1
-fi
-
-if [ -z "${IMAGE_NAME}" ]; then
- echo "Error: local-image-name not defined"
- exit 1
-fi
-
-if [ -z "${IMAGE_VERSION}" ]; then
- echo "Error: local-image-version not defined"
- exit 1
-fi
-
-if [ -z "${IMAGE_NAMESPACE}" ]; then
- echo "Error: image-namespace not defined"
- exit 1
-fi
-
-if [ -z "${REGISTRY_PULL_HOST}" ]; then
- echo "Error: image-registry-pull-host not defined"
- exit 1
-fi
-
-if [ -z "${REGISTRY_INSECURE}" ]; then
- echo "Error: image-registry-insecure not defined"
- exit 1
-fi
-
-# Cluster environment
-export CUSTOM_IMAGE=${IMAGE_NAME}
-export CUSTOM_VERSION=${IMAGE_VERSION}
-
-#
-# If bundle has been built and installed then use it
-#
-if [ -n "${BUILD_CATALOG_SOURCE}" ]; then
- export KAMEL_INSTALL_OLM_SOURCE_NAMESPACE=${IMAGE_NAMESPACE}
- export KAMEL_INSTALL_OLM_SOURCE=${BUILD_CATALOG_SOURCE}
-fi
-
-export KAMEL_INSTALL_MAVEN_REPOSITORIES=$(make get-staging-repo)
-export KAMEL_INSTALL_REGISTRY=${REGISTRY_PULL_HOST}
-export KAMEL_INSTALL_REGISTRY_INSECURE=${REGISTRY_INSECURE}
-export KAMEL_INSTALL_OPERATOR_IMAGE=${CUSTOM_IMAGE}:${CUSTOM_VERSION}
-
-# Will only have an effect if olm=false
-# since, for OLM, the csv determines the policy.
-# (see kamel-build-bundle/build-bundle-image.sh)
-export KAMEL_INSTALL_OPERATOR_IMAGE_PULL_POLICY="Always"
-
-#
-# Get current context
-#
-ctx=$(kubectl config current-context)
-
-#
-# Need to be admin so switch to the admin context
-#
-kubectl config use-context "${KUBE_ADMIN_CTX}"
-
-#
-# Ensure built binary CRDs are always installed by turning off olm
-#
-kamel install --global --olm=false
-
-#
-# Change back to original context
-#
-kubectl config use-context "${ctx}"
[camel-k] 02/17: Fix #2177: Use operator id by default
Posted by as...@apache.org.
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 ee137fedc1a247b82719e5be5cf36229e792ee93
Author: Christoph Deppisch <cd...@redhat.com>
AuthorDate: Wed Jun 8 10:42:00 2022 +0200
Fix #2177: Use operator id by default
- By default use an operator-id (default='camel-k')
- Introduce operator-id setting on kamel CLI when installing Camel K
- Introduce operator-id setting on kamel CLI when running integrations
- Make sure to use an operator-id when installing Camel K and running integrations
- Set camel.apache.org/operator.id annotation on resources managed by operator with given id
- Add operator id as environment variable to integration pods
- Use default operator id in OLM deployment
- Add more comfortable way to set operator id annotation on resources
---
config/manager/operator-deployment.yaml | 2 ++
e2e/support/test_support.go | 4 ++--
pkg/apis/camel/v1/integration_types_support.go | 9 +++++++++
pkg/apis/camel/v1/integrationkit_types_support.go | 9 +++++++++
pkg/apis/camel/v1/integrationplatform_types_support.go | 9 +++++++++
pkg/cmd/install.go | 11 ++++++++++-
pkg/cmd/run.go | 16 +++++++++++++---
pkg/cmd/run_test.go | 4 ++++
pkg/install/operator.go | 7 ++++---
pkg/resources/resources.go | 4 ++--
pkg/trait/container.go | 2 +-
pkg/trait/environment.go | 2 ++
pkg/trait/quarkus.go | 2 +-
13 files changed, 68 insertions(+), 13 deletions(-)
diff --git a/config/manager/operator-deployment.yaml b/config/manager/operator-deployment.yaml
index 15311da44..36b75343b 100644
--- a/config/manager/operator-deployment.yaml
+++ b/config/manager/operator-deployment.yaml
@@ -61,6 +61,8 @@ spec:
fieldPath: metadata.namespace
- name: OPERATOR_NAME
value: "camel-k"
+ - name: OPERATOR_ID
+ value: "camel-k"
- name: POD_NAME
valueFrom:
fieldRef:
diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index 967580303..b7ab45f15 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -545,7 +545,7 @@ func AssignIntegrationToOperator(ns, name, operator string) error {
if it.Annotations == nil {
it.Annotations = make(map[string]string)
}
- it.Annotations[v1.OperatorIDAnnotation] = operator
+ it.SetOperatorID(operator)
return TestClient().Update(TestContext, it)
}
@@ -1300,7 +1300,7 @@ func AssignPlatformToOperator(ns, operator string) error {
if pl.Annotations == nil {
pl.Annotations = make(map[string]string)
}
- pl.Annotations[v1.OperatorIDAnnotation] = operator
+ pl.SetOperatorID(operator)
return TestClient().Update(TestContext, pl)
}
diff --git a/pkg/apis/camel/v1/integration_types_support.go b/pkg/apis/camel/v1/integration_types_support.go
index 360c1df48..9d137de41 100644
--- a/pkg/apis/camel/v1/integration_types_support.go
+++ b/pkg/apis/camel/v1/integration_types_support.go
@@ -255,6 +255,15 @@ func (in *SourceSpec) InferLanguage() Language {
return ""
}
+// SetOperatorID sets the given operator id as an annotation
+func (in *Integration) SetOperatorID(operatorID string) {
+ if in.Annotations == nil {
+ in.Annotations = make(map[string]string)
+ }
+
+ in.Annotations[OperatorIDAnnotation] = operatorID
+}
+
func (in *Integration) SetIntegrationPlatform(platform *IntegrationPlatform) {
cs := corev1.ConditionTrue
diff --git a/pkg/apis/camel/v1/integrationkit_types_support.go b/pkg/apis/camel/v1/integrationkit_types_support.go
index 408a88416..5862805f9 100644
--- a/pkg/apis/camel/v1/integrationkit_types_support.go
+++ b/pkg/apis/camel/v1/integrationkit_types_support.go
@@ -54,6 +54,15 @@ func (in *IntegrationKitSpec) Configurations() []ConfigurationSpec {
return in.Configuration
}
+// SetOperatorID sets the given operator id as an annotation
+func (in *IntegrationKit) SetOperatorID(operatorID string) {
+ if in.Annotations == nil {
+ in.Annotations = make(map[string]string)
+ }
+
+ in.Annotations[OperatorIDAnnotation] = operatorID
+}
+
func (in *IntegrationKit) Configurations() []ConfigurationSpec {
if in == nil {
return []ConfigurationSpec{}
diff --git a/pkg/apis/camel/v1/integrationplatform_types_support.go b/pkg/apis/camel/v1/integrationplatform_types_support.go
index b644f462e..faa287750 100644
--- a/pkg/apis/camel/v1/integrationplatform_types_support.go
+++ b/pkg/apis/camel/v1/integrationplatform_types_support.go
@@ -68,6 +68,15 @@ func (in *IntegrationPlatformSpec) Configurations() []ConfigurationSpec {
return in.Configuration
}
+// SetOperatorID sets the given operator id as an annotation
+func (in *IntegrationPlatform) SetOperatorID(operatorID string) {
+ if in.Annotations == nil {
+ in.Annotations = make(map[string]string)
+ }
+
+ in.Annotations[OperatorIDAnnotation] = operatorID
+}
+
// Configurations --
func (in *IntegrationPlatform) Configurations() []ConfigurationSpec {
if in == nil {
diff --git a/pkg/cmd/install.go b/pkg/cmd/install.go
index 89d36621a..0287d69f5 100644
--- a/pkg/cmd/install.go
+++ b/pkg/cmd/install.go
@@ -101,6 +101,7 @@ func newCmdInstall(rootCmdOptions *RootCmdOptions) (*cobra.Command, *installCmdO
cmd.Flags().StringArrayP("property", "p", nil, "Add a camel property")
cmd.Flags().String("runtime-version", "", "Set the camel-k runtime version")
cmd.Flags().String("base-image", "", "Set the base Image used to run integrations")
+ cmd.Flags().String("operator-id", "camel-k", "Set the operator id that is used to select the resources this operator should manage")
cmd.Flags().String("operator-image", "", "Set the operator Image used for the operator deployment")
cmd.Flags().String("operator-image-pull-policy", "", "Set the operator ImagePullPolicy used for the operator deployment")
cmd.Flags().String("build-strategy", "", "Set the build strategy")
@@ -177,6 +178,7 @@ type installCmdOptions struct {
OutputFormat string `mapstructure:"output"`
RuntimeVersion string `mapstructure:"runtime-version"`
BaseImage string `mapstructure:"base-image"`
+ OperatorId string `mapstructure:"operator-id"`
OperatorImage string `mapstructure:"operator-image"`
OperatorImagePullPolicy string `mapstructure:"operator-image-pull-policy"`
BuildStrategy string `mapstructure:"build-strategy"`
@@ -216,6 +218,9 @@ func (o *installCmdOptions) install(cobraCmd *cobra.Command, _ []string) error {
// Let's use a client provider during cluster installation, to eliminate the problem of CRD object caching
clientProvider := client.Provider{Get: o.NewCmdClient}
+ // --operator-id={id} is a syntax sugar for '--operator-env-vars KAMEL_OPERATOR_ID={id}'
+ o.EnvVars = append(o.EnvVars, fmt.Sprintf("KAMEL_OPERATOR_ID=%s", strings.TrimSpace(o.OperatorId)))
+
// --skip-default-kamelets-setup is a syntax sugar for '--operator-env-vars KAMEL_INSTALL_DEFAULT_KAMELETS=false'
if o.SkipDefaultKameletsSetup {
o.EnvVars = append(o.EnvVars, "KAMEL_INSTALL_DEFAULT_KAMELETS=false")
@@ -342,7 +347,7 @@ func (o *installCmdOptions) install(cobraCmd *cobra.Command, _ []string) error {
if err != nil {
return err
}
- platform, err := install.PlatformOrCollect(o.Context, c, o.ClusterType, namespace, o.SkipRegistrySetup, o.registry, collection, operatorID)
+ platform, err := install.NewPlatform(o.Context, c, o.ClusterType, o.SkipRegistrySetup, o.registry, operatorID)
if err != nil {
return err
}
@@ -600,6 +605,10 @@ func (o *installCmdOptions) decode(cmd *cobra.Command, _ []string) error {
func (o *installCmdOptions) validate(_ *cobra.Command, _ []string) error {
var result error
+ if o.OperatorId == "" {
+ result = multierr.Append(result, fmt.Errorf("cannot use empty operator id"))
+ }
+
if len(o.MavenRepositories) > 0 && o.MavenSettings != "" {
err := fmt.Errorf("incompatible options combinations: you cannot set both mavenRepository and mavenSettings")
result = multierr.Append(result, err)
diff --git a/pkg/cmd/run.go b/pkg/cmd/run.go
index a37ac19cd..fd1e5c53f 100644
--- a/pkg/cmd/run.go
+++ b/pkg/cmd/run.go
@@ -106,6 +106,7 @@ func newCmdRun(rootCmdOptions *RootCmdOptions) (*cobra.Command, *runCmdOptions)
cmd.Flags().Bool("sync", false, "Synchronize the local source file with the cluster, republishing at each change")
cmd.Flags().Bool("dev", false, "Enable Dev mode (equivalent to \"-w --logs --sync\")")
cmd.Flags().Bool("use-flows", true, "Write yaml sources as Flow objects in the integration custom resource")
+ cmd.Flags().String("operator-id", "camel-k", "Operator id selected to manage this integration.")
cmd.Flags().String("profile", "", "Trait profile used for deployment")
cmd.Flags().StringArrayP("trait", "t", nil, "Configure a trait. E.g. \"-t service.enabled=false\"")
cmd.Flags().StringP("output", "o", "", "Output format. One of: json|yaml")
@@ -138,6 +139,7 @@ type runCmdOptions struct {
IntegrationKit string `mapstructure:"kit" yaml:",omitempty"`
IntegrationName string `mapstructure:"name" yaml:",omitempty"`
Profile string `mapstructure:"profile" yaml:",omitempty"`
+ OperatorId string `mapstructure:"operator-id" yaml:",omitempty"`
OutputFormat string `mapstructure:"output" yaml:",omitempty"`
PodTemplate string `mapstructure:"pod-template" yaml:",omitempty"`
Connects []string `mapstructure:"connects" yaml:",omitempty"`
@@ -240,6 +242,10 @@ func (o *runCmdOptions) validateArgs(cmd *cobra.Command, args []string) error {
}
func (o *runCmdOptions) validate() error {
+ if o.OperatorId == "" {
+ return fmt.Errorf("cannot use empty operator id")
+ }
+
for _, volume := range o.Volumes {
volumeConfig := strings.Split(volume, ":")
if len(volumeConfig) != 2 || len(strings.TrimSpace(volumeConfig[0])) == 0 || len(strings.TrimSpace(volumeConfig[1])) == 0 {
@@ -540,12 +546,16 @@ func (o *runCmdOptions) createOrUpdateIntegration(cmd *cobra.Command, c client.C
}
}
+ if integration.Annotations == nil {
+ integration.Annotations = make(map[string]string)
+ }
+
+ // --operator-id={id} is a syntax sugar for '--annotation camel.apache.org/operator.id={id}'
+ integration.SetOperatorID(strings.TrimSpace(o.OperatorId))
+
for _, annotation := range o.Annotations {
parts := strings.SplitN(annotation, "=", 2)
if len(parts) == 2 {
- if integration.Annotations == nil {
- integration.Annotations = make(map[string]string)
- }
integration.Annotations[parts[0]] = parts[1]
}
}
diff --git a/pkg/cmd/run_test.go b/pkg/cmd/run_test.go
index 4e1fc28a2..fff96f88d 100644
--- a/pkg/cmd/run_test.go
+++ b/pkg/cmd/run_test.go
@@ -566,6 +566,8 @@ func TestOutputYaml(t *testing.T) {
assert.Equal(t, fmt.Sprintf(`apiVersion: camel.apache.org/v1
kind: Integration
metadata:
+ annotations:
+ camel.apache.org/operator.id: camel-k
creationTimestamp: null
name: %s
spec:
@@ -598,6 +600,8 @@ func TestTrait(t *testing.T) {
assert.Equal(t, fmt.Sprintf(`apiVersion: camel.apache.org/v1
kind: Integration
metadata:
+ annotations:
+ camel.apache.org/operator.id: camel-k
creationTimestamp: null
name: %s
spec:
diff --git a/pkg/install/operator.go b/pkg/install/operator.go
index 70b1ae26c..7ce9ad75f 100644
--- a/pkg/install/operator.go
+++ b/pkg/install/operator.go
@@ -508,9 +508,9 @@ func installLeaseBindings(ctx context.Context, c client.Client, namespace string
)
}
-// PlatformOrCollect --
+// NewPlatform --
// nolint: lll
-func PlatformOrCollect(ctx context.Context, c client.Client, clusterType string, namespace string, skipRegistrySetup bool, registry v1.RegistrySpec, collection *kubernetes.Collection, operatorID string) (*v1.IntegrationPlatform, error) {
+func NewPlatform(ctx context.Context, c client.Client, clusterType string, skipRegistrySetup bool, registry v1.RegistrySpec, operatorID string) (*v1.IntegrationPlatform, error) {
isOpenShift, err := isOpenShift(c, clusterType)
if err != nil {
return nil, err
@@ -536,7 +536,8 @@ func PlatformOrCollect(ctx context.Context, c client.Client, clusterType string,
if pl.Annotations == nil {
pl.Annotations = make(map[string]string)
}
- pl.Annotations[v1.OperatorIDAnnotation] = operatorID
+ pl.SetOperatorID(operatorID)
+ pl.Name = operatorID
}
if !skipRegistrySetup {
diff --git a/pkg/resources/resources.go b/pkg/resources/resources.go
index af230eb89..2b685329a 100644
--- a/pkg/resources/resources.go
+++ b/pkg/resources/resources.go
@@ -170,9 +170,9 @@ var assets = func() http.FileSystem {
"/manager/operator-deployment.yaml": &vfsgen۰CompressedFileInfo{
name: "operator-deployment.yaml",
modTime: time.Time{},
- uncompressedSize: 2689,
+ uncompressedSize: 2752,
- compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xc4\x56\xcf\x6f\xe2\x46\x14\xbe\xfb\xaf\xf8\x84\x2f\xbb\x52\x30\xb0\xa7\x95\x7b\x72\x13\xd2\xa0\xa6\x06\x61\xb6\xd1\x9e\xaa\x61\xfc\xb0\x47\x8c\x67\xdc\x99\x31\x2c\xfd\xeb\xab\x31\x98\x00\x49\x68\x23\x45\x5a\x9f\x82\xdf\x9b\xef\x7d\x3f\x9e\xed\x84\xe8\x7f\xdc\x15\x84\x78\x14\x9c\x94\xa5\x1c\x4e\xc3\x95\x84\xa4\x66\xbc\x24\x64\x7a\xe5\xb6\xcc\x10\xee\x75\xa3\x72\xe6\x84\x56\xf8\x94\x64\xf7\x9f\xd1\xa8\x9c\x0c\xb4\x22\x [...]
+ compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xc4\x56\x4d\x8f\xe2\x46\x10\xbd\xfb\x57\x3c\xe1\xcb\xae\x34\x7c\xed\x69\xe5\x9c\x9c\x81\xc9\x58\x99\x18\x84\xd9\x8c\xf6\x14\x35\xed\xc2\x6e\xd1\xee\x76\xba\xdb\xb0\xe4\xd7\x47\x6d\x30\x03\xcc\x47\x32\xd1\x48\xf1\x09\xbb\xaa\x5e\xbd\x7a\xaf\xda\x26\x44\xff\xe3\xae\x20\xc4\x83\xe0\xa4\x2c\xe5\x70\x1a\xae\x24\xc4\x35\xe3\x25\x21\xd3\x6b\xb7\x63\x86\x70\xa7\x1b\x95\x33\x27\xb4\xc2\xa7\x38\xbb\xfb\x8c\x46\xe5\x64\xa0\x15\x [...]
},
"/manager/operator-service-account.yaml": &vfsgen۰CompressedFileInfo{
name: "operator-service-account.yaml",
diff --git a/pkg/trait/container.go b/pkg/trait/container.go
index dc510701a..522120218 100644
--- a/pkg/trait/container.go
+++ b/pkg/trait/container.go
@@ -136,7 +136,7 @@ func (t *containerTrait) configureImageIntegrationKit(e *Environment) error {
}
operatorID := defaults.OperatorID()
if operatorID != "" {
- kit.Annotations[v1.OperatorIDAnnotation] = operatorID
+ kit.SetOperatorID(operatorID)
}
t.L.Infof("image %s", kit.Spec.Image)
diff --git a/pkg/trait/environment.go b/pkg/trait/environment.go
index a9ed40a70..7155a7552 100644
--- a/pkg/trait/environment.go
+++ b/pkg/trait/environment.go
@@ -37,6 +37,7 @@ type environmentTrait struct {
const (
envVarNamespace = "NAMESPACE"
envVarPodName = "POD_NAME"
+ envVarOperatorId = "CAMEL_K_OPERATOR_ID"
envVarCamelKVersion = "CAMEL_K_VERSION"
envVarCamelKIntegration = "CAMEL_K_INTEGRATION"
envVarCamelKRuntimeVersion = "CAMEL_K_RUNTIME_VERSION"
@@ -70,6 +71,7 @@ func (t *environmentTrait) Configure(e *Environment) (bool, error) {
func (t *environmentTrait) Apply(e *Environment) error {
envvar.SetVal(&e.EnvVars, envVarCamelKVersion, defaults.Version)
+ envvar.SetVal(&e.EnvVars, envVarOperatorId, defaults.OperatorID())
if e.Integration != nil {
envvar.SetVal(&e.EnvVars, envVarCamelKIntegration, e.Integration.Name)
}
diff --git a/pkg/trait/quarkus.go b/pkg/trait/quarkus.go
index 0951fd3ad..1ad680634 100644
--- a/pkg/trait/quarkus.go
+++ b/pkg/trait/quarkus.go
@@ -202,7 +202,7 @@ func (t *quarkusTrait) newIntegrationKit(e *Environment, packageType traitv1.Qua
}
operatorID := defaults.OperatorID()
if operatorID != "" {
- kit.Annotations[v1.OperatorIDAnnotation] = operatorID
+ kit.SetOperatorID(operatorID)
}
kit.Spec = v1.IntegrationKitSpec{
[camel-k] 14/17: fix(#2177): Reduce duplicate code
Posted by as...@apache.org.
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 1c242673247b2cd173003202fcb74fec5c889848
Author: Christoph Deppisch <cd...@redhat.com>
AuthorDate: Fri Jun 24 20:28:37 2022 +0200
fix(#2177): Reduce duplicate code
---
addons/threescale/3scale.go | 12 +++++------
e2e/support/test_support.go | 20 ++++++-------------
pkg/apis/camel/v1/common_types_support.go | 11 ++++++++++-
pkg/apis/camel/v1/integration_types_support.go | 6 +-----
pkg/apis/camel/v1/integrationkit_types_support.go | 6 +-----
.../camel/v1/integrationplatform_types_support.go | 6 +-----
.../v1alpha1/kamelet_binding_types_support.go | 6 +-----
pkg/cmd/bind.go | 13 +++---------
pkg/cmd/run.go | 12 +++--------
pkg/cmd/util.go | 23 +++++++++++++++++++---
pkg/install/operator.go | 3 ---
pkg/trait/container.go | 5 +----
pkg/trait/platform.go | 3 ---
pkg/trait/quarkus.go | 5 +----
pkg/util/kubernetes/replace.go | 15 +++++---------
15 files changed, 58 insertions(+), 88 deletions(-)
diff --git a/addons/threescale/3scale.go b/addons/threescale/3scale.go
index 85e8c08a0..e7f246deb 100644
--- a/addons/threescale/3scale.go
+++ b/addons/threescale/3scale.go
@@ -22,6 +22,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
traitv1 "github.com/apache/camel-k/pkg/apis/camel/v1/trait"
"github.com/apache/camel-k/pkg/trait"
)
@@ -126,19 +127,16 @@ func (t *threeScaleTrait) addLabelsAndAnnotations(obj *metav1.ObjectMeta) {
}
obj.Labels[ThreeScaleDiscoveryLabel] = ThreeScaleDiscoveryLabelEnabled
- if obj.Annotations == nil {
- obj.Annotations = make(map[string]string)
- }
if t.Scheme != "" {
- obj.Annotations[ThreeScaleSchemeAnnotation] = t.Scheme
+ v1.SetAnnotation(obj, ThreeScaleSchemeAnnotation, t.Scheme)
}
if t.Path != "" {
- obj.Annotations[ThreeScalePathAnnotation] = t.Path
+ v1.SetAnnotation(obj, ThreeScalePathAnnotation, t.Path)
}
if t.Port != 0 {
- obj.Annotations[ThreeScalePortAnnotation] = strconv.Itoa(t.Port)
+ v1.SetAnnotation(obj, ThreeScalePortAnnotation, strconv.Itoa(t.Port))
}
if t.DescriptionPath != nil && *t.DescriptionPath != "" {
- obj.Annotations[ThreeScaleDescriptionPathAnnotation] = *t.DescriptionPath
+ v1.SetAnnotation(obj, ThreeScaleDescriptionPathAnnotation, *t.DescriptionPath)
}
}
diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index ec968fcb7..2f8cbc150 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -598,9 +598,7 @@ func AssignIntegrationToOperator(ns, name, operator string) error {
if it == nil {
return fmt.Errorf("cannot assign integration %q to operator: integration not found", name)
}
- if it.Annotations == nil {
- it.Annotations = make(map[string]string)
- }
+
it.SetOperatorID(operator)
return TestClient().Update(TestContext, it)
}
@@ -991,10 +989,8 @@ func AssignKameletBindingToOperator(ns, name, operator string) error {
if klb == nil {
return fmt.Errorf("cannot assign kamelet binding %q to operator: kamelet binding not found", name)
}
- if klb.Annotations == nil {
- klb.Annotations = make(map[string]string)
- }
- klb.Annotations[v1.OperatorIDAnnotation] = operator
+
+ klb.SetOperatorID(operator)
return TestClient().Update(TestContext, klb)
}
@@ -1363,9 +1359,7 @@ func AssignPlatformToOperator(ns, operator string) error {
if pl == nil {
return errors.New("cannot assign platform to operator: no platform found")
}
- if pl.Annotations == nil {
- pl.Annotations = make(map[string]string)
- }
+
pl.SetOperatorID(operator)
return TestClient().Update(TestContext, pl)
}
@@ -1375,10 +1369,8 @@ func ConfigureSecondaryPlatformWith(ns string, customizer func(pl *v1.Integratio
if pl == nil {
return errors.New("cannot find primary platform")
}
- if pl.Annotations == nil {
- pl.Annotations = make(map[string]string)
- }
- pl.Annotations[v1.SecondaryPlatformAnnotation] = "true"
+
+ v1.SetAnnotation(&pl.ObjectMeta, v1.SecondaryPlatformAnnotation, "true")
pl.ObjectMeta.ResourceVersion = ""
pl.Name = ""
pl.Status = v1.IntegrationPlatformStatus{}
diff --git a/pkg/apis/camel/v1/common_types_support.go b/pkg/apis/camel/v1/common_types_support.go
index bb93121b8..cf66c8b7f 100644
--- a/pkg/apis/camel/v1/common_types_support.go
+++ b/pkg/apis/camel/v1/common_types_support.go
@@ -69,7 +69,7 @@ func (m *RawMessage) UnmarshalJSON(data []byte) error {
return nil
}
-// GetOperatorIDAnnotation to safely get the operator id annotation value
+// GetOperatorIDAnnotation to safely get the operator id annotation value.
func GetOperatorIDAnnotation(obj metav1.Object) string {
if obj == nil || obj.GetAnnotations() == nil {
return ""
@@ -82,5 +82,14 @@ func GetOperatorIDAnnotation(obj metav1.Object) string {
return ""
}
+// SetAnnotation safely sets the annotation on the given runtime object.
+func SetAnnotation(obj *metav1.ObjectMeta, name string, value string) {
+ if obj.Annotations == nil {
+ obj.Annotations = make(map[string]string)
+ }
+
+ obj.Annotations[name] = value
+}
+
var _ json.Marshaler = (*RawMessage)(nil)
var _ json.Unmarshaler = (*RawMessage)(nil)
diff --git a/pkg/apis/camel/v1/integration_types_support.go b/pkg/apis/camel/v1/integration_types_support.go
index 9d137de41..5b6fd9130 100644
--- a/pkg/apis/camel/v1/integration_types_support.go
+++ b/pkg/apis/camel/v1/integration_types_support.go
@@ -257,11 +257,7 @@ func (in *SourceSpec) InferLanguage() Language {
// SetOperatorID sets the given operator id as an annotation
func (in *Integration) SetOperatorID(operatorID string) {
- if in.Annotations == nil {
- in.Annotations = make(map[string]string)
- }
-
- in.Annotations[OperatorIDAnnotation] = operatorID
+ SetAnnotation(&in.ObjectMeta, OperatorIDAnnotation, operatorID)
}
func (in *Integration) SetIntegrationPlatform(platform *IntegrationPlatform) {
diff --git a/pkg/apis/camel/v1/integrationkit_types_support.go b/pkg/apis/camel/v1/integrationkit_types_support.go
index 5862805f9..87d7667be 100644
--- a/pkg/apis/camel/v1/integrationkit_types_support.go
+++ b/pkg/apis/camel/v1/integrationkit_types_support.go
@@ -56,11 +56,7 @@ func (in *IntegrationKitSpec) Configurations() []ConfigurationSpec {
// SetOperatorID sets the given operator id as an annotation
func (in *IntegrationKit) SetOperatorID(operatorID string) {
- if in.Annotations == nil {
- in.Annotations = make(map[string]string)
- }
-
- in.Annotations[OperatorIDAnnotation] = operatorID
+ SetAnnotation(&in.ObjectMeta, OperatorIDAnnotation, operatorID)
}
func (in *IntegrationKit) Configurations() []ConfigurationSpec {
diff --git a/pkg/apis/camel/v1/integrationplatform_types_support.go b/pkg/apis/camel/v1/integrationplatform_types_support.go
index faa287750..769aea622 100644
--- a/pkg/apis/camel/v1/integrationplatform_types_support.go
+++ b/pkg/apis/camel/v1/integrationplatform_types_support.go
@@ -70,11 +70,7 @@ func (in *IntegrationPlatformSpec) Configurations() []ConfigurationSpec {
// SetOperatorID sets the given operator id as an annotation
func (in *IntegrationPlatform) SetOperatorID(operatorID string) {
- if in.Annotations == nil {
- in.Annotations = make(map[string]string)
- }
-
- in.Annotations[OperatorIDAnnotation] = operatorID
+ SetAnnotation(&in.ObjectMeta, OperatorIDAnnotation, operatorID)
}
// Configurations --
diff --git a/pkg/apis/camel/v1alpha1/kamelet_binding_types_support.go b/pkg/apis/camel/v1alpha1/kamelet_binding_types_support.go
index 90c36c821..0e11963aa 100644
--- a/pkg/apis/camel/v1alpha1/kamelet_binding_types_support.go
+++ b/pkg/apis/camel/v1alpha1/kamelet_binding_types_support.go
@@ -68,11 +68,7 @@ func (c KameletBindingCondition) GetMessage() string {
// SetOperatorID sets the given operator id as an annotation
func (in *KameletBinding) SetOperatorID(operatorID string) {
- if in.Annotations == nil {
- in.Annotations = make(map[string]string)
- }
-
- in.Annotations[v1.OperatorIDAnnotation] = operatorID
+ v1.SetAnnotation(&in.ObjectMeta, v1.OperatorIDAnnotation, operatorID)
}
// GetCondition returns the condition with the provided type.
diff --git a/pkg/cmd/bind.go b/pkg/cmd/bind.go
index 0632c8d87..1effdf1e8 100644
--- a/pkg/cmd/bind.go
+++ b/pkg/cmd/bind.go
@@ -25,7 +25,6 @@ import (
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
- platformutil "github.com/apache/camel-k/pkg/platform"
"github.com/apache/camel-k/pkg/trait"
"github.com/apache/camel-k/pkg/util/kubernetes"
"github.com/apache/camel-k/pkg/util/reference"
@@ -238,17 +237,11 @@ func (o *bindCmdOptions) run(cmd *cobra.Command, args []string) error {
}
if o.OperatorID != "" {
- if pl, err := platformutil.LookupForPlatformName(o.Context, client, o.OperatorID); err != nil {
- if k8serrors.IsForbidden(err) {
- o.PrintfVerboseOutf(cmd, "Unable to verify existence of operator id [%s] due to lack of user privileges\n", o.OperatorID)
- } else {
- return err
- }
- } else if pl == nil {
+ if err := verifyOperatorID(o.Context, client, o.OperatorID, cmd.OutOrStdout()); err != nil {
if o.Force {
- o.PrintfVerboseOutf(cmd, "Unable to find operator with given id [%s] - Kamelet binding may not be reconciled and get stuck in waiting state\n", o.OperatorID)
+ o.PrintfVerboseErrf(cmd, "%s, use --force option or make sure to use a proper operator id", err.Error())
} else {
- return fmt.Errorf("unable to find integration platform for given operator id '%s', use --force option or make sure to use a proper operator id", o.OperatorID)
+ return err
}
}
}
diff --git a/pkg/cmd/run.go b/pkg/cmd/run.go
index 5d46a9fb0..5298680f7 100644
--- a/pkg/cmd/run.go
+++ b/pkg/cmd/run.go
@@ -553,17 +553,11 @@ func (o *runCmdOptions) createOrUpdateIntegration(cmd *cobra.Command, c client.C
}
if o.OperatorID != "" {
- if pl, err := platformutil.LookupForPlatformName(o.Context, c, o.OperatorID); err != nil {
- if k8serrors.IsForbidden(err) {
- o.PrintfVerboseOutf(cmd, "Unable to verify existence of operator id [%s] due to lack of user privileges\n", o.OperatorID)
- } else {
- return nil, err
- }
- } else if pl == nil {
+ if err := verifyOperatorID(o.Context, c, o.OperatorID, cmd.OutOrStdout()); err != nil {
if o.Force {
- o.PrintfVerboseOutf(cmd, "Unable to find operator with given id [%s] - integration may not be reconciled and get stuck in waiting state\n", o.OperatorID)
+ o.PrintfVerboseErrf(cmd, "%s, use --force option or make sure to use a proper operator id", err.Error())
} else {
- return nil, fmt.Errorf("unable to find integration platform for given operator id '%s', use --force option or make sure to use a proper operator id", o.OperatorID)
+ return nil, err
}
}
}
diff --git a/pkg/cmd/util.go b/pkg/cmd/util.go
index 09768c881..1dd67136a 100644
--- a/pkg/cmd/util.go
+++ b/pkg/cmd/util.go
@@ -22,23 +22,25 @@ import (
"encoding/csv"
"encoding/json"
"fmt"
+ "io"
"log"
"os"
"reflect"
"strings"
- "github.com/apache/camel-k/pkg/util/gzip"
- "github.com/pkg/errors"
-
"github.com/mitchellh/mapstructure"
+ "github.com/pkg/errors"
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
"github.com/apache/camel-k/pkg/client"
+ platformutil "github.com/apache/camel-k/pkg/platform"
+ "github.com/apache/camel-k/pkg/util/gzip"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/spf13/viper"
p "github.com/gertd/go-pluralize"
+ k8serrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
@@ -283,3 +285,18 @@ func hasSupportedScheme(uri string) bool {
return false
}
+
+func verifyOperatorID(ctx context.Context, client client.Client, operatorID string, out io.Writer) error {
+ if pl, err := platformutil.LookupForPlatformName(ctx, client, operatorID); err != nil {
+ if k8serrors.IsForbidden(err) {
+ _, printErr := fmt.Fprintf(out, "Unable to verify existence of operator id [%s] due to lack of user privileges\n", operatorID)
+ return printErr
+ }
+
+ return err
+ } else if pl == nil {
+ return fmt.Errorf("unable to find operator with given id [%s] - resource may not be reconciled and get stuck in waiting state", operatorID)
+ }
+
+ return nil
+}
diff --git a/pkg/install/operator.go b/pkg/install/operator.go
index 7ce9ad75f..0b351b180 100644
--- a/pkg/install/operator.go
+++ b/pkg/install/operator.go
@@ -533,9 +533,6 @@ func NewPlatform(ctx context.Context, c client.Client, clusterType string, skipR
if operatorID != "" {
// We must tell the operator to reconcile this IntegrationPlatform
- if pl.Annotations == nil {
- pl.Annotations = make(map[string]string)
- }
pl.SetOperatorID(operatorID)
pl.Name = operatorID
}
diff --git a/pkg/trait/container.go b/pkg/trait/container.go
index 33ab614dc..1ae267dd3 100644
--- a/pkg/trait/container.go
+++ b/pkg/trait/container.go
@@ -129,11 +129,8 @@ func (t *containerTrait) configureImageIntegrationKit(e *Environment) error {
kubernetes.CamelCreatorLabelVersion: e.Integration.ResourceVersion,
}
- if kit.Annotations == nil {
- kit.Annotations = make(map[string]string)
- }
if v, ok := e.Integration.Annotations[v1.PlatformSelectorAnnotation]; ok {
- kit.Annotations[v1.PlatformSelectorAnnotation] = v
+ v1.SetAnnotation(&kit.ObjectMeta, v1.PlatformSelectorAnnotation, v)
}
operatorID := defaults.OperatorID()
if operatorID != "" {
diff --git a/pkg/trait/platform.go b/pkg/trait/platform.go
index 5ee3759db..263214ef4 100644
--- a/pkg/trait/platform.go
+++ b/pkg/trait/platform.go
@@ -120,9 +120,6 @@ func (t *platformTrait) getOrCreatePlatform(e *Environment) (*v1.IntegrationPlat
defaultPlatform.Labels["camel.apache.org/platform.generated"] = True
// Cascade the operator id in charge to reconcile the Integration
if v1.GetOperatorIDAnnotation(e.Integration) != "" {
- if defaultPlatform.Annotations == nil {
- defaultPlatform.Annotations = make(map[string]string)
- }
defaultPlatform.SetOperatorID(v1.GetOperatorIDAnnotation(e.Integration))
}
pl = &defaultPlatform
diff --git a/pkg/trait/quarkus.go b/pkg/trait/quarkus.go
index 1ad680634..a35235921 100644
--- a/pkg/trait/quarkus.go
+++ b/pkg/trait/quarkus.go
@@ -194,11 +194,8 @@ func (t *quarkusTrait) newIntegrationKit(e *Environment, packageType traitv1.Qua
kubernetes.CamelCreatorLabelVersion: integration.ResourceVersion,
}
- if kit.Annotations == nil {
- kit.Annotations = make(map[string]string)
- }
if v, ok := integration.Annotations[v1.PlatformSelectorAnnotation]; ok {
- kit.Annotations[v1.PlatformSelectorAnnotation] = v
+ v1.SetAnnotation(&kit.ObjectMeta, v1.PlatformSelectorAnnotation, v)
}
operatorID := defaults.OperatorID()
if operatorID != "" {
diff --git a/pkg/util/kubernetes/replace.go b/pkg/util/kubernetes/replace.go
index 58533b906..9554c07f4 100644
--- a/pkg/util/kubernetes/replace.go
+++ b/pkg/util/kubernetes/replace.go
@@ -33,6 +33,7 @@ import (
routev1 "github.com/openshift/api/route/v1"
+ v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
"github.com/apache/camel-k/pkg/client"
)
@@ -84,14 +85,11 @@ func mapRequiredRouteData(from runtime.Object, to runtime.Object) {
func mapRequiredKnativeServiceV1Beta1Data(from runtime.Object, to runtime.Object) {
if fromC, ok := from.(*serving.Service); ok {
if toC, ok := to.(*serving.Service); ok {
- if toC.ObjectMeta.Annotations == nil {
- toC.ObjectMeta.Annotations = make(map[string]string)
- }
if v, present := fromC.ObjectMeta.Annotations["serving.knative.dev/creator"]; present {
- toC.ObjectMeta.Annotations["serving.knative.dev/creator"] = v
+ v1.SetAnnotation(&toC.ObjectMeta, "serving.knative.dev/creator", v)
}
if v, present := fromC.ObjectMeta.Annotations["serving.knative.dev/lastModifier"]; present {
- toC.ObjectMeta.Annotations["serving.knative.dev/lastModifier"] = v
+ v1.SetAnnotation(&toC.ObjectMeta, "serving.knative.dev/lastModifier", v)
}
}
}
@@ -100,14 +98,11 @@ func mapRequiredKnativeServiceV1Beta1Data(from runtime.Object, to runtime.Object
func mapRequiredKnativeServiceV1Data(from runtime.Object, to runtime.Object) {
if fromC, ok := from.(*serving.Service); ok {
if toC, ok := to.(*serving.Service); ok {
- if toC.ObjectMeta.Annotations == nil {
- toC.ObjectMeta.Annotations = make(map[string]string)
- }
if v, present := fromC.ObjectMeta.Annotations["serving.knative.dev/creator"]; present {
- toC.ObjectMeta.Annotations["serving.knative.dev/creator"] = v
+ v1.SetAnnotation(&toC.ObjectMeta, "serving.knative.dev/creator", v)
}
if v, present := fromC.ObjectMeta.Annotations["serving.knative.dev/lastModifier"]; present {
- toC.ObjectMeta.Annotations["serving.knative.dev/lastModifier"] = v
+ v1.SetAnnotation(&toC.ObjectMeta, "serving.knative.dev/lastModifier", v)
}
}
}
[camel-k] 09/17: Fix #2177: Create proper integration platform as part of the operator
Posted by as...@apache.org.
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 a3be4d23bb0d356d6d9795fb0815428dc7bbf09f
Author: Christoph Deppisch <cd...@redhat.com>
AuthorDate: Fri Jun 3 10:17:53 2022 +0200
Fix #2177: Create proper integration platform as part of the operator
- Make sure that each operator instance adds its integration platform if not already exists
- Automatically adds an integration platform in operator start-up
- Also adds integration platform viewer role so authenticated users can see the platform instance
- Required for kamel CLI to verify existing operator ids on the cluster when doing an operator install or running integrations
---
pkg/cmd/operator/operator.go | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/pkg/cmd/operator/operator.go b/pkg/cmd/operator/operator.go
index e87e41ebe..2ae7436e2 100644
--- a/pkg/cmd/operator/operator.go
+++ b/pkg/cmd/operator/operator.go
@@ -29,6 +29,7 @@ import (
"strings"
"time"
+ "github.com/pkg/errors"
"go.uber.org/automaxprocs/maxprocs"
appsv1 "k8s.io/api/apps/v1"
@@ -36,6 +37,7 @@ import (
coordination "k8s.io/api/coordination/v1"
corev1 "k8s.io/api/core/v1"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/selection"
@@ -237,11 +239,41 @@ func Run(healthPort, monitoringPort int32, leaderElection bool, leaderElectionID
installCtx, installCancel := context.WithTimeout(context.Background(), 1*time.Minute)
defer installCancel()
install.OperatorStartupOptionalTools(installCtx, c, watchNamespace, operatorNamespace, log)
+ exitOnError(findOrCreateIntegrationPlatform(installCtx, c, operatorNamespace), "failed to create integration platform")
log.Info("Starting the manager")
exitOnError(mgr.Start(signals.SetupSignalHandler()), "manager exited non-zero")
}
+// findOrCreateIntegrationPlatform create default integration platform in operator namespace if not already exists
+func findOrCreateIntegrationPlatform(ctx context.Context, c client.Client, operatorNamespace string) error {
+ platformName := defaults.OperatorID()
+ if platformName == "" {
+ platformName = platform.DefaultPlatformName
+ }
+
+ if pl, err := kubernetes.GetIntegrationPlatform(ctx, c, platformName, operatorNamespace); pl == nil || k8serrors.IsNotFound(err) {
+ defaultPlatform := v1.NewIntegrationPlatform(operatorNamespace, platformName)
+ if defaultPlatform.Labels == nil {
+ defaultPlatform.Labels = make(map[string]string)
+ }
+ defaultPlatform.Labels["camel.apache.org/platform.generated"] = "true"
+
+ if _, err := c.CamelV1().IntegrationPlatforms(operatorNamespace).Create(ctx, &defaultPlatform, metav1.CreateOptions{}); err != nil {
+ return err
+ }
+
+ // Make sure that IntegrationPlatform installed in operator namespace can be seen by others
+ if err := install.IntegrationPlatformViewerRole(ctx, c, operatorNamespace); err != nil && !k8serrors.IsAlreadyExists(err) {
+ return errors.Wrap(err, "Error while installing global IntegrationPlatform viewer role")
+ }
+ } else {
+ return err
+ }
+
+ return nil
+}
+
// getWatchNamespace returns the Namespace the operator should be watching for changes.
func getWatchNamespace() (string, error) {
ns, found := os.LookupEnv(platform.OperatorWatchNamespaceEnvVariable)
[camel-k] 16/17: fix(#2177): Fix preflight test script and e2e upgrade tests
Posted by as...@apache.org.
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 fb172cc4a3d3e52f482c9a136666f4cdc4bd9777
Author: Christoph Deppisch <cd...@redhat.com>
AuthorDate: Mon Jul 4 23:31:22 2022 +0200
fix(#2177): Fix preflight test script and e2e upgrade tests
---
.github/actions/kamel-preflight-test/preflight-test.sh | 11 +----------
.github/workflows/upgrade.yml | 2 +-
e2e/namespace/upgrade/cli_upgrade_test.go | 2 +-
e2e/namespace/upgrade/olm_upgrade_test.go | 2 +-
4 files changed, 4 insertions(+), 13 deletions(-)
diff --git a/.github/actions/kamel-preflight-test/preflight-test.sh b/.github/actions/kamel-preflight-test/preflight-test.sh
index ead05e1d7..de9a6c911 100755
--- a/.github/actions/kamel-preflight-test/preflight-test.sh
+++ b/.github/actions/kamel-preflight-test/preflight-test.sh
@@ -200,7 +200,7 @@ export KAMEL_INSTALL_OPERATOR_IMAGE_PULL_POLICY="Always"
#
# Install the operator to local namespace
#
-kamel install -n ${NAMESPACE} --olm=${has_olm} --global=false --operator-id=camel-k-preflight
+kamel install -n ${NAMESPACE} --olm=${has_olm} --operator-id=camel-k-preflight
if [ $? != 0 ]; then
echo "Error: kamel install returned an error."
delns "${NAMESPACE}"
@@ -284,15 +284,6 @@ if [ $? != 0 ]; then
exit 1
fi
-#
-# Remove the operator from local namespace
-#
-kamel uninstall -n ${NAMESPACE}
-if [ $? != 0 ]; then
- echo "Error: kamel uninstall returned an error."
- exit 1
-fi
-
sleep 3
echo "Preflight Test: Success"
diff --git a/.github/workflows/upgrade.yml b/.github/workflows/upgrade.yml
index ce1dffaa9..09eec212a 100644
--- a/.github/workflows/upgrade.yml
+++ b/.github/workflows/upgrade.yml
@@ -50,7 +50,7 @@ on:
skip-problematic:
description: 'Whether tests marked as problematic should be skipped - false by default (sets CAMEL_K_TEST_SKIP_PROBLEMATIC)'
required: false
- default: false
+ default: "false"
test-filters:
description: |
Filter the tests in this test suite by assigning the test pattern to TEST_UPGRADE_RUN,
diff --git a/e2e/namespace/upgrade/cli_upgrade_test.go b/e2e/namespace/upgrade/cli_upgrade_test.go
index 4c849cee4..7e9b35d23 100644
--- a/e2e/namespace/upgrade/cli_upgrade_test.go
+++ b/e2e/namespace/upgrade/cli_upgrade_test.go
@@ -64,7 +64,7 @@ func TestOperatorUpgrade(t *testing.T) {
// Run the Integration
name := "yaml"
- Expect(KamelRun(ns, "files/yaml.yaml").Execute()).To(Succeed())
+ Expect(Kamel("run", "-n", ns, "files/yaml.yaml").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutLong).Should(Equal(corev1.ConditionTrue))
diff --git a/e2e/namespace/upgrade/olm_upgrade_test.go b/e2e/namespace/upgrade/olm_upgrade_test.go
index cdcc5ef55..b6037a4f5 100644
--- a/e2e/namespace/upgrade/olm_upgrade_test.go
+++ b/e2e/namespace/upgrade/olm_upgrade_test.go
@@ -107,7 +107,7 @@ func TestOLMAutomaticUpgrade(t *testing.T) {
Eventually(PlatformVersion(ns)).Should(ContainSubstring(prevIPVersionPrefix))
name := "yaml"
- Expect(KamelRun(ns, "files/yaml.yaml").Execute()).To(Succeed())
+ Expect(Kamel("run", "-n", ns, "files/yaml.yaml").Execute()).To(Succeed())
// Check the Integration runs correctly
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutLong).Should(Equal(corev1.ConditionTrue))
[camel-k] 03/17: Fix #2177: Align namespace operator lease with operator id
Posted by as...@apache.org.
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 c2302fa9b25a7a22e247037161786bc4da76ef3d
Author: Christoph Deppisch <cd...@redhat.com>
AuthorDate: Fri Jun 3 09:56:46 2022 +0200
Fix #2177: Align namespace operator lease with operator id
- Use operator id when creating the operator lease so only operator instances with the same id elect a leader
---
pkg/cmd/operator.go | 18 +++++++++++++++---
pkg/platform/operator.go | 10 +++++++++-
2 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/pkg/cmd/operator.go b/pkg/cmd/operator.go
index b1b8c59dd..b2570a356 100644
--- a/pkg/cmd/operator.go
+++ b/pkg/cmd/operator.go
@@ -18,10 +18,12 @@ limitations under the License.
package cmd
import (
+ "fmt"
+ "github.com/apache/camel-k/pkg/platform"
+ "github.com/apache/camel-k/pkg/util/defaults"
"github.com/spf13/cobra"
"github.com/apache/camel-k/pkg/cmd/operator"
- "github.com/apache/camel-k/pkg/platform"
)
const operatorCommand = "operator"
@@ -41,7 +43,7 @@ func newCmdOperator() (*cobra.Command, *operatorCmdOptions) {
cmd.Flags().Int32("health-port", 8081, "The port of the health endpoint")
cmd.Flags().Int32("monitoring-port", 8080, "The port of the metrics endpoint")
cmd.Flags().Bool("leader-election", true, "Use leader election")
- cmd.Flags().String("leader-election-id", platform.OperatorLockName, "Use the given ID as the leader election Lease name")
+ cmd.Flags().String("leader-election-id", "", "Use the given ID as the leader election Lease name")
return &cmd, &options
}
@@ -54,5 +56,15 @@ type operatorCmdOptions struct {
}
func (o *operatorCmdOptions) run(_ *cobra.Command, _ []string) {
- operator.Run(o.HealthPort, o.MonitoringPort, o.LeaderElection, o.LeaderElectionID)
+
+ leaderElectionId := o.LeaderElectionID
+ if leaderElectionId == "" {
+ if defaults.OperatorID() != "" {
+ leaderElectionId = fmt.Sprintf("%s-lock", defaults.OperatorID())
+ } else {
+ leaderElectionId = platform.OperatorLockName
+ }
+ }
+
+ operator.Run(o.HealthPort, o.MonitoringPort, o.LeaderElection, leaderElectionId)
}
diff --git a/pkg/platform/operator.go b/pkg/platform/operator.go
index c9fe67c77..602a99105 100644
--- a/pkg/platform/operator.go
+++ b/pkg/platform/operator.go
@@ -19,6 +19,7 @@ package platform
import (
"context"
+ "fmt"
"os"
"strings"
@@ -80,8 +81,15 @@ func IsNamespaceLocked(ctx context.Context, c ctrl.Reader, namespace string) (bo
return false, nil
}
+ var operatorLockName string
+ if defaults.OperatorID() != "" {
+ operatorLockName = fmt.Sprintf("%s-lock", defaults.OperatorID())
+ } else {
+ operatorLockName = OperatorLockName
+ }
+
lease := coordination.Lease{}
- if err := c.Get(ctx, ctrl.ObjectKey{Namespace: namespace, Name: OperatorLockName}, &lease); err != nil && k8serrors.IsNotFound(err) {
+ if err := c.Get(ctx, ctrl.ObjectKey{Namespace: namespace, Name: operatorLockName}, &lease); err != nil && k8serrors.IsNotFound(err) {
return false, nil
} else if err != nil {
return true, err
[camel-k] 11/17: Fix #2177: Fix golangci-lint errors
Posted by as...@apache.org.
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 734dc8354921d145e5eb9a02500e3f2e35b757a6
Author: Christoph Deppisch <cd...@redhat.com>
AuthorDate: Thu Jun 9 08:37:52 2022 +0200
Fix #2177: Fix golangci-lint errors
---
pkg/cmd/bind.go | 16 ++++++++--------
pkg/cmd/install.go | 14 ++++++++------
pkg/cmd/operator.go | 10 +++++-----
pkg/cmd/operator/operator.go | 8 +++++---
pkg/cmd/run.go | 16 ++++++++--------
pkg/cmd/version.go | 6 +++---
pkg/controller/kameletbinding/monitor.go | 4 ++--
pkg/platform/platform.go | 7 ++++---
pkg/trait/environment.go | 4 ++--
9 files changed, 45 insertions(+), 40 deletions(-)
diff --git a/pkg/cmd/bind.go b/pkg/cmd/bind.go
index b86b08e88..0632c8d87 100644
--- a/pkg/cmd/bind.go
+++ b/pkg/cmd/bind.go
@@ -85,7 +85,7 @@ type bindCmdOptions struct {
SkipChecks bool `mapstructure:"skip-checks" yaml:",omitempty"`
Steps []string `mapstructure:"steps" yaml:",omitempty"`
Traits []string `mapstructure:"traits" yaml:",omitempty"`
- OperatorId string `mapstructure:"operator-id" yaml:",omitempty"`
+ OperatorID string `mapstructure:"operator-id" yaml:",omitempty"`
Annotations []string `mapstructure:"annotations" yaml:",omitempty"`
Force bool `mapstructure:"force" yaml:",omitempty"`
}
@@ -116,7 +116,7 @@ func (o *bindCmdOptions) validate(cmd *cobra.Command, args []string) error {
return errors.New("source or sink arguments are missing")
}
- if o.OperatorId == "" {
+ if o.OperatorID == "" {
return fmt.Errorf("cannot use empty operator id")
}
@@ -237,24 +237,24 @@ func (o *bindCmdOptions) run(cmd *cobra.Command, args []string) error {
binding.Annotations = make(map[string]string)
}
- if o.OperatorId != "" {
- if pl, err := platformutil.LookupForPlatformName(o.Context, client, o.OperatorId); err != nil {
+ if o.OperatorID != "" {
+ if pl, err := platformutil.LookupForPlatformName(o.Context, client, o.OperatorID); err != nil {
if k8serrors.IsForbidden(err) {
- o.PrintfVerboseOutf(cmd, "Unable to verify existence of operator id [%s] due to lack of user privileges\n", o.OperatorId)
+ o.PrintfVerboseOutf(cmd, "Unable to verify existence of operator id [%s] due to lack of user privileges\n", o.OperatorID)
} else {
return err
}
} else if pl == nil {
if o.Force {
- o.PrintfVerboseOutf(cmd, "Unable to find operator with given id [%s] - Kamelet binding may not be reconciled and get stuck in waiting state\n", o.OperatorId)
+ o.PrintfVerboseOutf(cmd, "Unable to find operator with given id [%s] - Kamelet binding may not be reconciled and get stuck in waiting state\n", o.OperatorID)
} else {
- return errors.New(fmt.Sprintf("unable to find integration platform for given operator id '%s', use --force option or make sure to use a proper operator id", o.OperatorId))
+ return fmt.Errorf("unable to find integration platform for given operator id '%s', use --force option or make sure to use a proper operator id", o.OperatorID)
}
}
}
// --operator-id={id} is a syntax sugar for '--annotation camel.apache.org/operator.id={id}'
- binding.SetOperatorID(strings.TrimSpace(o.OperatorId))
+ binding.SetOperatorID(strings.TrimSpace(o.OperatorID))
for _, annotation := range o.Annotations {
parts := strings.SplitN(annotation, "=", 2)
diff --git a/pkg/cmd/install.go b/pkg/cmd/install.go
index 1efba233e..2176f22db 100644
--- a/pkg/cmd/install.go
+++ b/pkg/cmd/install.go
@@ -180,7 +180,7 @@ type installCmdOptions struct {
OutputFormat string `mapstructure:"output"`
RuntimeVersion string `mapstructure:"runtime-version"`
BaseImage string `mapstructure:"base-image"`
- OperatorId string `mapstructure:"operator-id"`
+ OperatorID string `mapstructure:"operator-id"`
OperatorImage string `mapstructure:"operator-image"`
OperatorImagePullPolicy string `mapstructure:"operator-image-pull-policy"`
BuildStrategy string `mapstructure:"build-strategy"`
@@ -221,7 +221,7 @@ func (o *installCmdOptions) install(cobraCmd *cobra.Command, _ []string) error {
clientProvider := client.Provider{Get: o.NewCmdClient}
// --operator-id={id} is a syntax sugar for '--operator-env-vars KAMEL_OPERATOR_ID={id}'
- o.EnvVars = append(o.EnvVars, fmt.Sprintf("KAMEL_OPERATOR_ID=%s", strings.TrimSpace(o.OperatorId)))
+ o.EnvVars = append(o.EnvVars, fmt.Sprintf("KAMEL_OPERATOR_ID=%s", strings.TrimSpace(o.OperatorID)))
// --skip-default-kamelets-setup is a syntax sugar for '--operator-env-vars KAMEL_INSTALL_DEFAULT_KAMELETS=false'
if o.SkipDefaultKameletsSetup {
@@ -303,16 +303,18 @@ func (o *installCmdOptions) install(cobraCmd *cobra.Command, _ []string) error {
namespace := o.Namespace
- platformName := platformutil.DefaultPlatformName
+ var platformName string
if operatorID != "" {
platformName = operatorID
+ } else {
+ platformName = platformutil.DefaultPlatformName
}
if !o.SkipOperatorSetup && !installViaOLM {
if ok, err := isInstallAllowed(o.Context, c, platformName, o.Force, cobraCmd.OutOrStdout()); err != nil {
return err
} else if !ok {
- return errors.New(fmt.Sprintf("installation not allowed because operator with id '%s' already exists, use the --force option to skip this check", platformName))
+ return fmt.Errorf("installation not allowed because operator with id '%s' already exists, use the --force option to skip this check", platformName)
}
cfg := install.OperatorConfiguration{
@@ -528,7 +530,7 @@ func isInstallAllowed(ctx context.Context, c client.Client, operatorID string, f
pl, err := platformutil.LookupForPlatformName(ctx, c, operatorID)
if pl != nil && force {
- fmt.Fprintln(out, fmt.Sprintf("Overwriting existing operator with id '%s'", operatorID))
+ fmt.Fprintf(out, "Overwriting existing operator with id '%s'\n", operatorID)
return true, nil
}
@@ -636,7 +638,7 @@ func (o *installCmdOptions) decode(cmd *cobra.Command, _ []string) error {
func (o *installCmdOptions) validate(_ *cobra.Command, _ []string) error {
var result error
- if o.OperatorId == "" {
+ if o.OperatorID == "" {
result = multierr.Append(result, fmt.Errorf("cannot use empty operator id"))
}
diff --git a/pkg/cmd/operator.go b/pkg/cmd/operator.go
index b2570a356..9bb66a51f 100644
--- a/pkg/cmd/operator.go
+++ b/pkg/cmd/operator.go
@@ -57,14 +57,14 @@ type operatorCmdOptions struct {
func (o *operatorCmdOptions) run(_ *cobra.Command, _ []string) {
- leaderElectionId := o.LeaderElectionID
- if leaderElectionId == "" {
+ leaderElectionID := o.LeaderElectionID
+ if leaderElectionID == "" {
if defaults.OperatorID() != "" {
- leaderElectionId = fmt.Sprintf("%s-lock", defaults.OperatorID())
+ leaderElectionID = fmt.Sprintf("%s-lock", defaults.OperatorID())
} else {
- leaderElectionId = platform.OperatorLockName
+ leaderElectionID = platform.OperatorLockName
}
}
- operator.Run(o.HealthPort, o.MonitoringPort, o.LeaderElection, leaderElectionId)
+ operator.Run(o.HealthPort, o.MonitoringPort, o.LeaderElection, leaderElectionID)
}
diff --git a/pkg/cmd/operator/operator.go b/pkg/cmd/operator/operator.go
index 2ae7436e2..4d108d6a3 100644
--- a/pkg/cmd/operator/operator.go
+++ b/pkg/cmd/operator/operator.go
@@ -245,10 +245,12 @@ func Run(healthPort, monitoringPort int32, leaderElection bool, leaderElectionID
exitOnError(mgr.Start(signals.SetupSignalHandler()), "manager exited non-zero")
}
-// findOrCreateIntegrationPlatform create default integration platform in operator namespace if not already exists
+// findOrCreateIntegrationPlatform create default integration platform in operator namespace if not already exists.
func findOrCreateIntegrationPlatform(ctx context.Context, c client.Client, operatorNamespace string) error {
- platformName := defaults.OperatorID()
- if platformName == "" {
+ var platformName string
+ if defaults.OperatorID() != "" {
+ platformName = defaults.OperatorID()
+ } else {
platformName = platform.DefaultPlatformName
}
diff --git a/pkg/cmd/run.go b/pkg/cmd/run.go
index a3ad6b6e1..5d46a9fb0 100644
--- a/pkg/cmd/run.go
+++ b/pkg/cmd/run.go
@@ -140,7 +140,7 @@ type runCmdOptions struct {
IntegrationKit string `mapstructure:"kit" yaml:",omitempty"`
IntegrationName string `mapstructure:"name" yaml:",omitempty"`
Profile string `mapstructure:"profile" yaml:",omitempty"`
- OperatorId string `mapstructure:"operator-id" yaml:",omitempty"`
+ OperatorID string `mapstructure:"operator-id" yaml:",omitempty"`
OutputFormat string `mapstructure:"output" yaml:",omitempty"`
PodTemplate string `mapstructure:"pod-template" yaml:",omitempty"`
Connects []string `mapstructure:"connects" yaml:",omitempty"`
@@ -244,7 +244,7 @@ func (o *runCmdOptions) validateArgs(cmd *cobra.Command, args []string) error {
}
func (o *runCmdOptions) validate() error {
- if o.OperatorId == "" {
+ if o.OperatorID == "" {
return fmt.Errorf("cannot use empty operator id")
}
@@ -552,24 +552,24 @@ func (o *runCmdOptions) createOrUpdateIntegration(cmd *cobra.Command, c client.C
integration.Annotations = make(map[string]string)
}
- if o.OperatorId != "" {
- if pl, err := platformutil.LookupForPlatformName(o.Context, c, o.OperatorId); err != nil {
+ if o.OperatorID != "" {
+ if pl, err := platformutil.LookupForPlatformName(o.Context, c, o.OperatorID); err != nil {
if k8serrors.IsForbidden(err) {
- o.PrintfVerboseOutf(cmd, "Unable to verify existence of operator id [%s] due to lack of user privileges\n", o.OperatorId)
+ o.PrintfVerboseOutf(cmd, "Unable to verify existence of operator id [%s] due to lack of user privileges\n", o.OperatorID)
} else {
return nil, err
}
} else if pl == nil {
if o.Force {
- o.PrintfVerboseOutf(cmd, "Unable to find operator with given id [%s] - integration may not be reconciled and get stuck in waiting state\n", o.OperatorId)
+ o.PrintfVerboseOutf(cmd, "Unable to find operator with given id [%s] - integration may not be reconciled and get stuck in waiting state\n", o.OperatorID)
} else {
- return nil, errors.New(fmt.Sprintf("unable to find integration platform for given operator id '%s', use --force option or make sure to use a proper operator id", o.OperatorId))
+ return nil, fmt.Errorf("unable to find integration platform for given operator id '%s', use --force option or make sure to use a proper operator id", o.OperatorID)
}
}
}
// --operator-id={id} is a syntax sugar for '--annotation camel.apache.org/operator.id={id}'
- integration.SetOperatorID(strings.TrimSpace(o.OperatorId))
+ integration.SetOperatorID(strings.TrimSpace(o.OperatorID))
for _, annotation := range o.Annotations {
parts := strings.SplitN(annotation, "=", 2)
diff --git a/pkg/cmd/version.go b/pkg/cmd/version.go
index 1a6055ffe..6cec424d6 100644
--- a/pkg/cmd/version.go
+++ b/pkg/cmd/version.go
@@ -133,10 +133,10 @@ func operatorInfo(ctx context.Context, c client.Client, namespace string) (map[s
platform, err := platformutil.GetOrFindLocal(ctx, c, namespace)
if err != nil && k8serrors.IsNotFound(err) {
// find default operator platform in any namespace
- if defaultPlatform, _ := platformutil.LookupForPlatformName(ctx, c, platformutil.DefaultPlatformName); defaultPlatform == nil {
- return nil, err
- } else {
+ if defaultPlatform, _ := platformutil.LookupForPlatformName(ctx, c, platformutil.DefaultPlatformName); defaultPlatform != nil {
platform = defaultPlatform
+ } else {
+ return nil, err
}
} else if err != nil {
return nil, err
diff --git a/pkg/controller/kameletbinding/monitor.go b/pkg/controller/kameletbinding/monitor.go
index d6465573c..841a313fc 100644
--- a/pkg/controller/kameletbinding/monitor.go
+++ b/pkg/controller/kameletbinding/monitor.go
@@ -73,7 +73,7 @@ func (action *monitorAction) Handle(ctx context.Context, kameletbinding *v1alpha
return nil, errors.Wrapf(err, "could not load integration for KameletBinding %q", kameletbinding.Name)
}
- operatorIdChanged := v1.GetOperatorIDAnnotation(kameletbinding) != "" &&
+ operatorIDChanged := v1.GetOperatorIDAnnotation(kameletbinding) != "" &&
(v1.GetOperatorIDAnnotation(kameletbinding) != v1.GetOperatorIDAnnotation(&it))
// Check if the integration needs to be changed
@@ -82,7 +82,7 @@ func (action *monitorAction) Handle(ctx context.Context, kameletbinding *v1alpha
return nil, err
}
- if !equality.Semantic.DeepDerivative(expected.Spec, it.Spec) || operatorIdChanged {
+ if !equality.Semantic.DeepDerivative(expected.Spec, it.Spec) || operatorIDChanged {
action.L.Info("Monitor: KameletBinding needs a rebuild")
// KameletBinding has changed and needs rebuild
diff --git a/pkg/platform/platform.go b/pkg/platform/platform.go
index 42c88cd82..84119b696 100644
--- a/pkg/platform/platform.go
+++ b/pkg/platform/platform.go
@@ -32,7 +32,7 @@ const (
DefaultPlatformName = "camel-k"
)
-// LookupForPlatformName finds integration platform with given operator id as name in any namespace
+// LookupForPlatformName finds integration platform with given operator id as name in any namespace.
func LookupForPlatformName(ctx context.Context, c k8sclient.Reader, name string) (*v1.IntegrationPlatform, error) {
platformList := v1.NewIntegrationPlatformList()
@@ -86,7 +86,7 @@ func getOrFindForResource(ctx context.Context, c k8sclient.Reader, o k8sclient.O
platformName = ik.Status.Platform
}
- return getOrFind(ctx, c, ik.Namespace, ik.Status.Platform, active, local)
+ return getOrFind(ctx, c, ik.Namespace, platformName, active, local)
}
return find(ctx, c, o.GetNamespace(), active, local)
}
@@ -178,7 +178,8 @@ func ListPrimaryPlatforms(ctx context.Context, c k8sclient.Reader, namespace str
}
filtered := v1.NewIntegrationPlatformList()
- for _, pl := range lst.Items {
+ for i := range lst.Items {
+ pl := lst.Items[i]
if !IsSecondary(&pl) {
filtered.Items = append(filtered.Items, pl)
}
diff --git a/pkg/trait/environment.go b/pkg/trait/environment.go
index 7155a7552..b9c1ac315 100644
--- a/pkg/trait/environment.go
+++ b/pkg/trait/environment.go
@@ -37,7 +37,7 @@ type environmentTrait struct {
const (
envVarNamespace = "NAMESPACE"
envVarPodName = "POD_NAME"
- envVarOperatorId = "CAMEL_K_OPERATOR_ID"
+ envVarOperatorID = "CAMEL_K_OPERATOR_ID"
envVarCamelKVersion = "CAMEL_K_VERSION"
envVarCamelKIntegration = "CAMEL_K_INTEGRATION"
envVarCamelKRuntimeVersion = "CAMEL_K_RUNTIME_VERSION"
@@ -71,7 +71,7 @@ func (t *environmentTrait) Configure(e *Environment) (bool, error) {
func (t *environmentTrait) Apply(e *Environment) error {
envvar.SetVal(&e.EnvVars, envVarCamelKVersion, defaults.Version)
- envvar.SetVal(&e.EnvVars, envVarOperatorId, defaults.OperatorID())
+ envvar.SetVal(&e.EnvVars, envVarOperatorID, defaults.OperatorID())
if e.Integration != nil {
envvar.SetVal(&e.EnvVars, envVarCamelKIntegration, e.Integration.Name)
}
[camel-k] 07/17: Fix #2177: Use operator id in KameletBindings
Posted by as...@apache.org.
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 c33e0cc189c5b516f5da524b9a5f88032775fbd1
Author: Christoph Deppisch <cd...@redhat.com>
AuthorDate: Wed Jun 8 20:11:44 2022 +0200
Fix #2177: Use operator id in KameletBindings
- Introduce operator-id option to kamel CLI bind command
- Make sure to use proper operator id when creating the binding
- Rebuild Kamelet binding when operator id annotation changes
---
.../v1alpha1/kamelet_binding_types_support.go | 9 ++++
pkg/cmd/bind.go | 48 ++++++++++++++++++++++
pkg/cmd/bind_test.go | 19 ++++++++-
pkg/controller/kameletbinding/monitor.go | 7 +++-
4 files changed, 80 insertions(+), 3 deletions(-)
diff --git a/pkg/apis/camel/v1alpha1/kamelet_binding_types_support.go b/pkg/apis/camel/v1alpha1/kamelet_binding_types_support.go
index d47024609..90c36c821 100644
--- a/pkg/apis/camel/v1alpha1/kamelet_binding_types_support.go
+++ b/pkg/apis/camel/v1alpha1/kamelet_binding_types_support.go
@@ -66,6 +66,15 @@ func (c KameletBindingCondition) GetMessage() string {
return c.Message
}
+// SetOperatorID sets the given operator id as an annotation
+func (in *KameletBinding) SetOperatorID(operatorID string) {
+ if in.Annotations == nil {
+ in.Annotations = make(map[string]string)
+ }
+
+ in.Annotations[v1.OperatorIDAnnotation] = operatorID
+}
+
// GetCondition returns the condition with the provided type.
func (in *KameletBindingStatus) GetCondition(condType KameletBindingConditionType) *KameletBindingCondition {
for i := range in.Conditions {
diff --git a/pkg/cmd/bind.go b/pkg/cmd/bind.go
index 2a1c4ad26..b86b08e88 100644
--- a/pkg/cmd/bind.go
+++ b/pkg/cmd/bind.go
@@ -25,6 +25,7 @@ import (
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
+ platformutil "github.com/apache/camel-k/pkg/platform"
"github.com/apache/camel-k/pkg/trait"
"github.com/apache/camel-k/pkg/util/kubernetes"
"github.com/apache/camel-k/pkg/util/reference"
@@ -60,6 +61,9 @@ func newCmdBind(rootCmdOptions *RootCmdOptions) (*cobra.Command, *bindCmdOptions
cmd.Flags().Bool("skip-checks", false, "Do not verify the binding for compliance with Kamelets and other Kubernetes resources")
cmd.Flags().StringArray("step", nil, `Add binding steps as Kubernetes resources. Endpoints are expected in the format "[[apigroup/]version:]kind:[namespace/]name", plain Camel URIs or Kamelet name.`)
cmd.Flags().StringArrayP("trait", "t", nil, `Add a trait to the corresponding Integration.`)
+ cmd.Flags().String("operator-id", "camel-k", "Operator id selected to manage this Kamelet binding.")
+ cmd.Flags().StringArray("annotation", nil, "Add an annotation to the Kamelet binding. E.g. \"--annotation my.company=hello\"")
+ cmd.Flags().Bool("force", false, "Force creation of Kamelet binding regardless of potential misconfiguration.")
return &cmd, &options
}
@@ -81,6 +85,9 @@ type bindCmdOptions struct {
SkipChecks bool `mapstructure:"skip-checks" yaml:",omitempty"`
Steps []string `mapstructure:"steps" yaml:",omitempty"`
Traits []string `mapstructure:"traits" yaml:",omitempty"`
+ OperatorId string `mapstructure:"operator-id" yaml:",omitempty"`
+ Annotations []string `mapstructure:"annotations" yaml:",omitempty"`
+ Force bool `mapstructure:"force" yaml:",omitempty"`
}
func (o *bindCmdOptions) preRunE(cmd *cobra.Command, args []string) error {
@@ -109,6 +116,17 @@ func (o *bindCmdOptions) validate(cmd *cobra.Command, args []string) error {
return errors.New("source or sink arguments are missing")
}
+ if o.OperatorId == "" {
+ return fmt.Errorf("cannot use empty operator id")
+ }
+
+ for _, annotation := range o.Annotations {
+ parts := strings.SplitN(annotation, "=", 2)
+ if len(parts) != 2 {
+ return fmt.Errorf(`invalid annotation specification %s. Expected "<annotationkey>=<annotationvalue>"`, annotation)
+ }
+ }
+
for _, p := range o.Properties {
if _, _, _, err := o.parseProperty(p); err != nil {
return err
@@ -215,6 +233,36 @@ func (o *bindCmdOptions) run(cmd *cobra.Command, args []string) error {
}
}
+ if binding.Annotations == nil {
+ binding.Annotations = make(map[string]string)
+ }
+
+ if o.OperatorId != "" {
+ if pl, err := platformutil.LookupForPlatformName(o.Context, client, o.OperatorId); err != nil {
+ if k8serrors.IsForbidden(err) {
+ o.PrintfVerboseOutf(cmd, "Unable to verify existence of operator id [%s] due to lack of user privileges\n", o.OperatorId)
+ } else {
+ return err
+ }
+ } else if pl == nil {
+ if o.Force {
+ o.PrintfVerboseOutf(cmd, "Unable to find operator with given id [%s] - Kamelet binding may not be reconciled and get stuck in waiting state\n", o.OperatorId)
+ } else {
+ return errors.New(fmt.Sprintf("unable to find integration platform for given operator id '%s', use --force option or make sure to use a proper operator id", o.OperatorId))
+ }
+ }
+ }
+
+ // --operator-id={id} is a syntax sugar for '--annotation camel.apache.org/operator.id={id}'
+ binding.SetOperatorID(strings.TrimSpace(o.OperatorId))
+
+ for _, annotation := range o.Annotations {
+ parts := strings.SplitN(annotation, "=", 2)
+ if len(parts) == 2 {
+ binding.Annotations[parts[0]] = parts[1]
+ }
+ }
+
if o.OutputFormat != "" {
return showOutput(cmd, &binding, o.OutputFormat, client.GetScheme())
}
diff --git a/pkg/cmd/bind_test.go b/pkg/cmd/bind_test.go
index aa5778a5c..e4583b7bd 100644
--- a/pkg/cmd/bind_test.go
+++ b/pkg/cmd/bind_test.go
@@ -20,6 +20,8 @@ package cmd
import (
"testing"
+ v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
+ "github.com/apache/camel-k/pkg/platform"
"github.com/apache/camel-k/pkg/util/test"
"github.com/spf13/cobra"
"github.com/stretchr/testify/assert"
@@ -31,7 +33,10 @@ const cmdBind = "bind"
func initializeBindCmdOptions(t *testing.T) (*bindCmdOptions, *cobra.Command, RootCmdOptions) {
t.Helper()
- options, rootCmd := kamelTestPreAddCommandInit()
+ defaultIntegrationPlatform := v1.NewIntegrationPlatform("default", platform.DefaultPlatformName)
+ fakeClient, _ := test.NewFakeClient(&defaultIntegrationPlatform)
+
+ options, rootCmd := kamelTestPreAddCommandInitWithClient(fakeClient)
bindCmdOptions := addTestBindCmd(*options, rootCmd)
kamelTestPostAddCommandInit(t, rootCmd)
@@ -52,7 +57,7 @@ func TestBindOutputJSON(t *testing.T) {
assert.Equal(t, "json", buildCmdOptions.OutputFormat)
assert.Nil(t, err)
- assert.Equal(t, `{"kind":"KameletBinding","apiVersion":"camel.apache.org/v1alpha1","metadata":{"name":"my-to-my","creationTimestamp":null},"spec":{"source":{"uri":"my:src"},"sink":{"uri":"my:dst"}},"status":{}}`, output)
+ assert.Equal(t, `{"kind":"KameletBinding","apiVersion":"camel.apache.org/v1alpha1","metadata":{"name":"my-to-my","creationTimestamp":null,"annotations":{"camel.apache.org/operator.id":"camel-k"}},"spec":{"source":{"uri":"my:src"},"sink":{"uri":"my:dst"}},"status":{}}`, output)
}
func TestBindOutputYAML(t *testing.T) {
@@ -64,6 +69,8 @@ func TestBindOutputYAML(t *testing.T) {
assert.Equal(t, `apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
+ annotations:
+ camel.apache.org/operator.id: camel-k
creationTimestamp: null
name: my-to-my
spec:
@@ -93,6 +100,8 @@ func TestBindErrorHandlerDLCKamelet(t *testing.T) {
assert.Equal(t, `apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
+ annotations:
+ camel.apache.org/operator.id: camel-k
creationTimestamp: null
name: my-to-my
spec:
@@ -123,6 +132,8 @@ func TestBindErrorHandlerNone(t *testing.T) {
assert.Equal(t, `apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
+ annotations:
+ camel.apache.org/operator.id: camel-k
creationTimestamp: null
name: my-to-my
spec:
@@ -146,6 +157,8 @@ func TestBindErrorHandlerLog(t *testing.T) {
assert.Equal(t, `apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
+ annotations:
+ camel.apache.org/operator.id: camel-k
creationTimestamp: null
name: my-to-my
spec:
@@ -168,6 +181,8 @@ func TestBindTraits(t *testing.T) {
assert.Equal(t, `apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
+ annotations:
+ camel.apache.org/operator.id: camel-k
creationTimestamp: null
name: my-to-my
spec:
diff --git a/pkg/controller/kameletbinding/monitor.go b/pkg/controller/kameletbinding/monitor.go
index 5c9b599aa..d6465573c 100644
--- a/pkg/controller/kameletbinding/monitor.go
+++ b/pkg/controller/kameletbinding/monitor.go
@@ -73,13 +73,18 @@ func (action *monitorAction) Handle(ctx context.Context, kameletbinding *v1alpha
return nil, errors.Wrapf(err, "could not load integration for KameletBinding %q", kameletbinding.Name)
}
+ operatorIdChanged := v1.GetOperatorIDAnnotation(kameletbinding) != "" &&
+ (v1.GetOperatorIDAnnotation(kameletbinding) != v1.GetOperatorIDAnnotation(&it))
+
// Check if the integration needs to be changed
expected, err := CreateIntegrationFor(ctx, action.client, kameletbinding)
if err != nil {
return nil, err
}
- if !equality.Semantic.DeepDerivative(expected.Spec, it.Spec) {
+ if !equality.Semantic.DeepDerivative(expected.Spec, it.Spec) || operatorIdChanged {
+ action.L.Info("Monitor: KameletBinding needs a rebuild")
+
// KameletBinding has changed and needs rebuild
target := kameletbinding.DeepCopy()
// Rebuild the integration
[camel-k] 13/17: Fix #2177: Update docs
Posted by as...@apache.org.
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 93245fd35c7a118d35ee9fc9369956c2838bddf6
Author: Christoph Deppisch <cd...@redhat.com>
AuthorDate: Tue Jun 14 12:15:30 2022 +0200
Fix #2177: Update docs
---
docs/modules/ROOT/pages/architecture/operator.adoc | 21 +++++++++++++--
.../ROOT/pages/installation/advanced/multi.adoc | 31 +++++++++++++++-------
2 files changed, 41 insertions(+), 11 deletions(-)
diff --git a/docs/modules/ROOT/pages/architecture/operator.adoc b/docs/modules/ROOT/pages/architecture/operator.adoc
index 6a980a789..252487f21 100644
--- a/docs/modules/ROOT/pages/architecture/operator.adoc
+++ b/docs/modules/ROOT/pages/architecture/operator.adoc
@@ -21,7 +21,7 @@ The Camel K Operator defines a number of new Kubernetes API through the https://
All the api conform to the Kubernetes https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md[api conventions].
-To manage the interaction with them, a simple control loop was not enough and we ended up with a sort of “Hierarchical Operator Pattern” where the reconcile phase may trigger other controllers and supervises them.
+To manage the interaction with them, a simple control loop was not enough. So we ended up with a sort of “Hierarchical Operator Pattern” where the reconcile phase may trigger other controllers and supervises them.
image::architecture/camel-k-operator-control-loop.png[control-loop]
@@ -31,7 +31,7 @@ With the exception of the `CamelCatalog`, each CR has a dedicated state machine
image::architecture/camel-k-state-machine-basic.png[State Machine]
-Each state of the CR is handled by a dedicated handler, named `Action`, defined as follow:
+Each state of the CR is handled by a dedicated handler, named `Action`, defined as follows:
[source,go]
----
@@ -47,3 +47,20 @@ type Action interface {
====
Since the go language does not yet support generics, there is an `Action` definition per CR, The full list of definitions can be found in the https://github.com/apache/camel-k/tree/main/pkg/controller[controller package]
====
+
+== Operator resource mapping
+
+By default the Camel K operator (global mode) will manage all Camel K resources on the cluster doing the reconciliation loops for the resources in order to apply the mentioned state machine.
+
+For clusters with multiple Camel K tenants this approach is not going to work as user groups may want to separate the workloads with respective
+authentication and authorization schemes. For multi tenancy the Camel K operator uses an operator id that can be applied to resources in the form of
+an annotation. The annotation selects the operator that should handle the resource.
+
+This approach allows multiple Camel K installations and operators on the same cluster with each operator handling an explicit set of Camel K resources identified
+by the operator id.
+
+By default the Camel K operator has the id `camel-k` and users with only one single installation on the cluster will not even notice the existence of this identifier. When an administrator wants to add more Camel K operator installations to the cluster the
+operator id needs to be unique and resources should be annotated with the respective annotation `camel.apache.org/operator.id={operator-id}`. With this approach we make sure that only one single operator installation manages
+a resource at a time.
+
+Read more about this topic in xref:installation/advanced/multi.adoc[Multiple Operators and Selective Upgrades]
diff --git a/docs/modules/ROOT/pages/installation/advanced/multi.adoc b/docs/modules/ROOT/pages/installation/advanced/multi.adoc
index c95da15ba..fdad7bdba 100644
--- a/docs/modules/ROOT/pages/installation/advanced/multi.adoc
+++ b/docs/modules/ROOT/pages/installation/advanced/multi.adoc
@@ -1,19 +1,22 @@
[[advanced-installation-multiple-operators]]
= Multiple Operators and Selective Upgrades
-It's possible to setup multiple Camel K operators in a cluster to watch the same namespaces. It's not
+It is possible to set up multiple Camel K operators on a cluster to watch resources on namespaces. It's not
possible to configure Camel K this way using OLM (Operator Hub), since OLM prevents two operators from watching the same namespaces,
but it's technically possible to achieve this setup manually.
-A typical example is when you install two global operators in different namespaces (e.g. `kamel install --global --olm=false -n camel-ns-1` and `kamel install --global --olm=false -n camel-ns-2`).
-In this situation, both operators will watch the same resources in the cluster, so that if a user creates an integration in any namespace,
-both operators will contend the integration and the reconciliation will most probably result in an error (actual behavior is undefined).
+A typical example is when you need to install multiple global operators in different namespaces in order to have multiple tenants on the cluster working with Camel K.
+In this multi operator situation Camel K needs to avoid that the same resources on the cluster are managed by more than one operator at the same time.
+Operators must not contend the integration and the reconciliation because this will most probably result in an error (actual behavior is undefined).
-To avoid contention, it's possible to specify for each operator an ID and then assign any custom resource (CR) to a specific operator using an annotation.
-The assigned operator will be responsible for the reconciliation of the annotated CR.
+To avoid contention, Camel K uses an operator id for each operator. The operator id must be unique on the cluster and any custom resource (CR) is assigned to a specific operator using an annotation.
+The assigned operator will be responsible for the reconciliation of the annotated CR and explicitly manages the resource no matter where it lives.
In detail, the Camel K operator supports the environment variable `KAMEL_OPERATOR_ID`. The value is an identifier that can be equal to any string (e.g. `KAMEL_OPERATOR_ID=operator-1`).
-Once the operator is assigned an ID, it will *only reconcile* Camel custom resources that are assigned to that ID (unannotated resources will be ignored as well).
+Once the operator is assigned with an identifier, it will *only reconcile* Camel K custom resources that are assigned to that ID (unannotated resources will be ignored as well).
+
+By default, the Camel K operator is using the id `camel-k`. When installing many operators the instances must use a different operator id.
+(e.g. `kamel install --global --olm=false -n camel-ns-1 --operator-id=operator-2`).
To assign a resource to a specific operator, the user can annotate it with `camel.apache.org/operator.id`. For example:
@@ -23,10 +26,14 @@ kind: Integration
apiVersion: camel.apache.org/v1
metadata:
annotations:
- camel.apache.org/operator.id: operator-1
+ camel.apache.org/operator.id: operator-2
# ...
----
+By default, Camel K custom resources use the default operator id `camel-k` as a value in this annotation.
+And more precisely the default operator with id `camel-k` and only this specific operator is allowed to also reconcile resources that are missing the
+operator id annotation.
+
The annotation can be put on any resource belonging to the "camel.apache.org" group.
NOTE: When a resource creates additional resources in order to proceed with the reconciliation (for example
@@ -34,7 +41,13 @@ an Integration may create an IntegrationKit, which in turn creates a Build resou
all resources created in the process, so they'll be all reconciled by the same operator.
By using the `camel.apache.org/operator.id` annotation, it's possible to move integrations between two or more operators running different
-versions of the Camel K platform, i.e. *selectively upgrading or downgrading* them.
+versions of the Camel K platform, i.e. *selectively upgrading or downgrading* them. Just change the annotation on that particula resource to point to a new
+operator id:
+
+[source,shell script]
+----
+kubectl annotate integration timer-to-log camel.apache.org/operator.id=operator-2 --overwrite
+----
[[advanced-installation-multiple-platforms]]
== Configuring Multiple Integration Platforms
[camel-k] 06/17: Fix #2177: Ensure valid operator id when running integrations
Posted by as...@apache.org.
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 417b7b873f4aea59488cddfcc9ddf2f548248194
Author: Christoph Deppisch <cd...@redhat.com>
AuthorDate: Thu Jun 2 16:53:53 2022 +0200
Fix #2177: Ensure valid operator id when running integrations
- Make sure to use a known operator id when running an integration
- Check performs a cluster wide search for integration platforms and verifies that the platform name exists
- Users may use --force option to skip the check
---
pkg/cmd/root_test.go | 11 ++++++++---
pkg/cmd/run.go | 20 +++++++++++++++++++-
pkg/cmd/run_test.go | 6 +++++-
3 files changed, 32 insertions(+), 5 deletions(-)
diff --git a/pkg/cmd/root_test.go b/pkg/cmd/root_test.go
index 8fe884d0d..d2b4eb7d5 100644
--- a/pkg/cmd/root_test.go
+++ b/pkg/cmd/root_test.go
@@ -23,6 +23,7 @@ import (
"os"
"testing"
+ "github.com/apache/camel-k/pkg/client"
"github.com/apache/camel-k/pkg/util/test"
"github.com/spf13/cobra"
"github.com/spf13/viper"
@@ -37,17 +38,21 @@ func kamelTestPostAddCommandInit(t *testing.T, rootCmd *cobra.Command) {
}
}
-func kamelTestPreAddCommandInit() (*RootCmdOptions, *cobra.Command) {
- fakeClient, _ := test.NewFakeClient()
+func kamelTestPreAddCommandInitWithClient(client client.Client) (*RootCmdOptions, *cobra.Command) {
options := RootCmdOptions{
Context: context.Background(),
- _client: fakeClient,
+ _client: client,
}
rootCmd := kamelPreAddCommandInit(&options)
rootCmd.Run = test.EmptyRun
return &options, rootCmd
}
+func kamelTestPreAddCommandInit() (*RootCmdOptions, *cobra.Command) {
+ fakeClient, _ := test.NewFakeClient()
+ return kamelTestPreAddCommandInitWithClient(fakeClient)
+}
+
func TestLoadFromEnvVar(t *testing.T) {
defer teardown(t)
// shows how to include a "," character inside an env value see VAR1 value
diff --git a/pkg/cmd/run.go b/pkg/cmd/run.go
index fd1e5c53f..a3ad6b6e1 100644
--- a/pkg/cmd/run.go
+++ b/pkg/cmd/run.go
@@ -118,6 +118,7 @@ func newCmdRun(rootCmdOptions *RootCmdOptions) (*cobra.Command, *runCmdOptions)
cmd.Flags().StringArray("label", nil, "Add a label to the integration. E.g. \"--label my.company=hello\"")
cmd.Flags().StringArray("source", nil, "Add source file to your integration, this is added to the list of files listed as arguments of the command")
cmd.Flags().String("pod-template", "", "The path of the YAML file containing a PodSpec template to be used for the Integration pods")
+ cmd.Flags().Bool("force", false, "Force creation of integration regardless of potential misconfiguration.")
cmd.Flags().Bool("save", false, "Save the run parameters into the default kamel configuration file (kamel-config.yaml)")
@@ -157,11 +158,12 @@ type runCmdOptions struct {
Annotations []string `mapstructure:"annotations" yaml:",omitempty"`
Sources []string `mapstructure:"sources" yaml:",omitempty"`
RegistryOptions url.Values
+ Force bool `mapstructure:"force" yaml:",omitempty"`
}
func (o *runCmdOptions) preRunE(cmd *cobra.Command, args []string) error {
if o.OutputFormat != "" {
- // let the command to work in offline mode
+ // let the command work in offline mode
cmd.Annotations[offlineCommandLabel] = "true"
}
return o.RootCmdOptions.preRun(cmd, args)
@@ -550,6 +552,22 @@ func (o *runCmdOptions) createOrUpdateIntegration(cmd *cobra.Command, c client.C
integration.Annotations = make(map[string]string)
}
+ if o.OperatorId != "" {
+ if pl, err := platformutil.LookupForPlatformName(o.Context, c, o.OperatorId); err != nil {
+ if k8serrors.IsForbidden(err) {
+ o.PrintfVerboseOutf(cmd, "Unable to verify existence of operator id [%s] due to lack of user privileges\n", o.OperatorId)
+ } else {
+ return nil, err
+ }
+ } else if pl == nil {
+ if o.Force {
+ o.PrintfVerboseOutf(cmd, "Unable to find operator with given id [%s] - integration may not be reconciled and get stuck in waiting state\n", o.OperatorId)
+ } else {
+ return nil, errors.New(fmt.Sprintf("unable to find integration platform for given operator id '%s', use --force option or make sure to use a proper operator id", o.OperatorId))
+ }
+ }
+ }
+
// --operator-id={id} is a syntax sugar for '--annotation camel.apache.org/operator.id={id}'
integration.SetOperatorID(strings.TrimSpace(o.OperatorId))
diff --git a/pkg/cmd/run_test.go b/pkg/cmd/run_test.go
index fff96f88d..d53516400 100644
--- a/pkg/cmd/run_test.go
+++ b/pkg/cmd/run_test.go
@@ -27,6 +27,7 @@ import (
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
traitv1 "github.com/apache/camel-k/pkg/apis/camel/v1/trait"
+ "github.com/apache/camel-k/pkg/platform"
"github.com/apache/camel-k/pkg/trait"
"github.com/apache/camel-k/pkg/util/test"
@@ -55,7 +56,10 @@ func initializeRunCmdOptions(t *testing.T) (*runCmdOptions, *cobra.Command, Root
func initializeRunCmdOptionsWithOutput(t *testing.T) (*runCmdOptions, *cobra.Command, RootCmdOptions) {
t.Helper()
- options, rootCmd := kamelTestPreAddCommandInit()
+ defaultIntegrationPlatform := v1.NewIntegrationPlatform("default", platform.DefaultPlatformName)
+ fakeClient, _ := test.NewFakeClient(&defaultIntegrationPlatform)
+
+ options, rootCmd := kamelTestPreAddCommandInitWithClient(fakeClient)
runCmdOptions := addTestRunCmdWithOutput(*options, rootCmd)
kamelTestPostAddCommandInit(t, rootCmd)
[camel-k] 10/17: Fix #2177: Improve operator version lookup
Posted by as...@apache.org.
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 ad6a749000da3a1bddb114c998d550f632768633
Author: Christoph Deppisch <cd...@redhat.com>
AuthorDate: Fri Jun 3 08:46:10 2022 +0200
Fix #2177: Improve operator version lookup
- Find local integration platform or try to search for default operator in any namespace instead of just looking for the "camel-k" integration platform in local namespace
- Should eliminate nasty "No Integration platform available in current namespace" warnings when using the kamel CLI
---
pkg/cmd/version.go | 24 ++++++++++++++----------
pkg/platform/platform.go | 4 ++++
2 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/pkg/cmd/version.go b/pkg/cmd/version.go
index ec0e493bd..1a6055ffe 100644
--- a/pkg/cmd/version.go
+++ b/pkg/cmd/version.go
@@ -22,14 +22,14 @@ import (
"fmt"
"strings"
+ k8serrors "k8s.io/apimachinery/pkg/api/errors"
+
"github.com/Masterminds/semver"
"github.com/fatih/camelcase"
"github.com/spf13/cobra"
- k8sclient "sigs.k8s.io/controller-runtime/pkg/client"
-
- v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
"github.com/apache/camel-k/pkg/client"
+ platformutil "github.com/apache/camel-k/pkg/platform"
"github.com/apache/camel-k/pkg/util/defaults"
)
@@ -130,16 +130,20 @@ func (o *versionCmdOptions) displayOperatorVersion(cmd *cobra.Command, c client.
func operatorInfo(ctx context.Context, c client.Client, namespace string) (map[string]string, error) {
infos := make(map[string]string)
- platform := v1.NewIntegrationPlatform(namespace, "camel-k")
- platformKey := k8sclient.ObjectKey{
- Namespace: namespace,
- Name: "camel-k",
- }
-
- if err := c.Get(ctx, platformKey, &platform); err != nil {
+ platform, err := platformutil.GetOrFindLocal(ctx, c, namespace)
+ if err != nil && k8serrors.IsNotFound(err) {
+ // find default operator platform in any namespace
+ if defaultPlatform, _ := platformutil.LookupForPlatformName(ctx, c, platformutil.DefaultPlatformName); defaultPlatform == nil {
+ return nil, err
+ } else {
+ platform = defaultPlatform
+ }
+ } else if err != nil {
return nil, err
}
+
// Useful information
+ infos["name"] = platform.Name
infos["version"] = platform.Status.Version
infos["publishStrategy"] = string(platform.Status.Build.PublishStrategy)
infos["runtimeVersion"] = platform.Status.Build.RuntimeVersion
diff --git a/pkg/platform/platform.go b/pkg/platform/platform.go
index 8b5f5c9c1..42c88cd82 100644
--- a/pkg/platform/platform.go
+++ b/pkg/platform/platform.go
@@ -65,6 +65,10 @@ func GetOrFindLocalForResource(ctx context.Context, c k8sclient.Reader, o k8scli
return getOrFindForResource(ctx, c, o, active, true)
}
+func GetOrFindLocal(ctx context.Context, c k8sclient.Reader, namespace string) (*v1.IntegrationPlatform, error) {
+ return findLocal(ctx, c, namespace, true)
+}
+
func getOrFindForResource(ctx context.Context, c k8sclient.Reader, o k8sclient.Object, active bool, local bool) (*v1.IntegrationPlatform, error) {
if selectedPlatform, ok := o.GetAnnotations()[v1.PlatformSelectorAnnotation]; ok {
return get(ctx, c, o.GetNamespace(), selectedPlatform)
[camel-k] 01/17: Fix #2177: Cosmetic changes
Posted by as...@apache.org.
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 d6da80d52d9231c191138dccaad170cfa99f45d7
Author: Christoph Deppisch <cd...@redhat.com>
AuthorDate: Fri Jun 3 08:46:37 2022 +0200
Fix #2177: Cosmetic changes
- Fix typos
- Use IsSecondary() utility method
---
e2e/global/common/secondary_platform_test.go | 2 +-
e2e/support/test_support.go | 2 +-
pkg/platform/platform.go | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/e2e/global/common/secondary_platform_test.go b/e2e/global/common/secondary_platform_test.go
index 665262737..beb714314 100644
--- a/e2e/global/common/secondary_platform_test.go
+++ b/e2e/global/common/secondary_platform_test.go
@@ -37,7 +37,7 @@ import (
func TestSecondaryPlatform(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
Expect(KamelInstall(ns).Execute()).To(Succeed())
- Expect(ConfigureSecondayPlatfromWith(ns, func(p *v1.IntegrationPlatform) {
+ Expect(ConfigureSecondaryPlatformWith(ns, func(p *v1.IntegrationPlatform) {
p.Name = "secondary"
p.Spec.Traits.Container = &traitv1.ContainerTrait{
Trait: traitv1.Trait{
diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index 08f9d7455..967580303 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -1304,7 +1304,7 @@ func AssignPlatformToOperator(ns, operator string) error {
return TestClient().Update(TestContext, pl)
}
-func ConfigureSecondayPlatfromWith(ns string, customizer func(pl *v1.IntegrationPlatform)) error {
+func ConfigureSecondaryPlatformWith(ns string, customizer func(pl *v1.IntegrationPlatform)) error {
pl := Platform(ns)()
if pl == nil {
return errors.New("cannot find primary platform")
diff --git a/pkg/platform/platform.go b/pkg/platform/platform.go
index 8c3af7ac0..affba22b6 100644
--- a/pkg/platform/platform.go
+++ b/pkg/platform/platform.go
@@ -143,7 +143,7 @@ func ListPrimaryPlatforms(ctx context.Context, c k8sclient.Reader, namespace str
filtered := v1.NewIntegrationPlatformList()
for _, pl := range lst.Items {
- if val, present := pl.Annotations[v1.SecondaryPlatformAnnotation]; !present || val != "true" {
+ if !IsSecondary(&pl) {
filtered.Items = append(filtered.Items, pl)
}
}