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

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

commit e04fbbb2e40d06269d7e9dd18b88933eadb068f2
Author: Pasquale Congiusti <pasquale.congiu...@gmail.com>
AuthorDate: Thu May 4 12:48:47 2023 +0200

    chore: fix test after deprecation
---
 e2e/common/misc/kamelet_test.go         |  4 +--
 e2e/common/misc/pipe_test.go            | 45 ++++++++-------------------------
 e2e/common/misc/pipe_with_image_test.go | 25 +++++-------------
 e2e/common/traits/health_test.go        | 22 ++++------------
 pkg/cmd/run.go                          |  3 +--
 pkg/cmd/run_support.go                  |  9 +++----
 6 files changed, 29 insertions(+), 79 deletions(-)

diff --git a/e2e/common/misc/kamelet_test.go b/e2e/common/misc/kamelet_test.go
index e54efd19c..97dd0b8f9 100644
--- a/e2e/common/misc/kamelet_test.go
+++ b/e2e/common/misc/kamelet_test.go
@@ -36,7 +36,7 @@ func TestKameletClasspathLoading(t *testing.T) {
 
        // Store a configmap on the cluster
        var cmData = make(map[string]string)
-       cmData["my-kamelet"] = `
+       cmData["my-timer-source.kamelet.yaml"] = `
 # ---------------------------------------------------------------------------
 # Licensed to the Apache Software Foundation (ASF) under one or more
 # contributor license agreements.  See the NOTICE file distributed with
@@ -112,7 +112,7 @@ spec:
        // Basic
        t.Run("test basic case", func(t *testing.T) {
                Expect(KamelRunWithID(operatorID, ns, 
"files/TimerKameletIntegration.java", "-t", "kamelets.enabled=false",
-                       "--resource", 
"configmap:my-kamelet-cm@/kamelets/my-timer-source.kamelet.yaml",
+                       "--resource", "configmap:my-kamelet-cm@/kamelets",
                        "-p camel.component.kamelet.location=file:/kamelets",
                        "-d", "camel:yaml-dsl",
                        // kamelet dependencies
diff --git a/e2e/common/misc/pipe_test.go b/e2e/common/misc/pipe_test.go
index b0eb5f573..213008169 100644
--- a/e2e/common/misc/pipe_test.go
+++ b/e2e/common/misc/pipe_test.go
@@ -41,23 +41,12 @@ func TestPipe(t *testing.T) {
        t.Run("test error handler", func(t *testing.T) {
                Expect(createErrorProducerKamelet(ns, 
"my-own-error-producer-source")()).To(Succeed())
                Expect(CreateLogKamelet(ns, "my-own-log-sink")()).To(Succeed())
-               from := corev1.ObjectReference{
-                       Kind:       "Kamelet",
-                       Name:       "my-own-error-producer-source",
-                       APIVersion: v1.SchemeGroupVersion.String(),
-               }
-
-               to := corev1.ObjectReference{
-                       Kind:       "Kamelet",
-                       Name:       "my-own-log-sink",
-                       APIVersion: v1.SchemeGroupVersion.String(),
-               }
 
                t.Run("throw error test", func(t *testing.T) {
-                       Expect(KamelBind(ns,
-                               from.Name,
-                               to.Name,
-                               "--error-handler", "sink:"+to.Name,
+                       Expect(KamelBindWithID(operatorID, ns,
+                               "my-own-error-producer-source",
+                               "my-own-log-sink",
+                               "--error-handler", "sink:my-own-log-sink",
                                "-p", "source.message=throw Error",
                                "-p", "sink.loggerName=integrationLogger",
                                "-p", 
"error-handler.loggerName=kameletErrorHandler",
@@ -71,10 +60,10 @@ func TestPipe(t *testing.T) {
                })
 
                t.Run("don't throw error test", func(t *testing.T) {
-                       Expect(KamelBind(ns,
-                               from.Name,
-                               to.Name,
-                               "--error-handler", "sink:"+to.Name,
+                       Expect(KamelBindWithID(operatorID, ns,
+                               "my-own-error-producer-source",
+                               "my-own-log-sink",
+                               "--error-handler", "sink:my-own-log-sink",
                                "-p", "source.message=true",
                                "-p", "sink.loggerName=integrationLogger",
                                "-p", 
"error-handler.loggerName=kameletErrorHandler",
@@ -93,21 +82,9 @@ func TestPipe(t *testing.T) {
                Expect(CreateTimerKamelet(ns, 
"my-own-timer-source")()).To(Succeed())
                // Log sink kamelet exists from previous test
 
-               from := corev1.ObjectReference{
-                       Kind:       "Kamelet",
-                       Name:       "my-own-timer-source",
-                       APIVersion: v1.SchemeGroupVersion.String(),
-               }
-
-               to := corev1.ObjectReference{
-                       Kind:       "Kamelet",
-                       Name:       "my-own-log-sink",
-                       APIVersion: v1.SchemeGroupVersion.String(),
-               }
-
-               Expect(KamelBind(ns,
-                       from.Name,
-                       to.Name,
+               Expect(KamelBindWithID(operatorID, ns,
+                       "my-own-timer-source",
+                       "my-own-log-sink",
                        "-p", "source.message=hello from test",
                        "-p", "sink.loggerName=integrationLogger",
                        "--annotation", 
"trait.camel.apache.org/camel.properties=[\"camel.prop1=a\",\"camel.prop2=b\"]",
diff --git a/e2e/common/misc/pipe_with_image_test.go 
b/e2e/common/misc/pipe_with_image_test.go
index 77ddf9348..d34e67d39 100644
--- a/e2e/common/misc/pipe_with_image_test.go
+++ b/e2e/common/misc/pipe_with_image_test.go
@@ -31,32 +31,19 @@ import (
        corev1 "k8s.io/api/core/v1"
 
        . "github.com/apache/camel-k/v2/e2e/support"
-       v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
 )
 
 func TestPipeWithImage(t *testing.T) {
        RegisterTestingT(t)
 
-       from := corev1.ObjectReference{
-               Kind:       "Kamelet",
-               Name:       "my-own-timer-source",
-               APIVersion: v1.SchemeGroupVersion.String(),
-       }
-
-       to := corev1.ObjectReference{
-               Kind:       "Kamelet",
-               Name:       "my-own-log-sink",
-               APIVersion: v1.SchemeGroupVersion.String(),
-       }
-
        bindingID := "with-image-binding"
 
        t.Run("run with initial image", func(t *testing.T) {
                expectedImage := "docker.io/jmalloc/echo-server:0.3.2"
 
-               Expect(KamelBind(ns,
-                       from.Name,
-                       to.Name,
+               Expect(KamelBindWithID(operatorID, ns,
+                       "my-own-timer-source",
+                       "my-own-log-sink",
                        "--annotation", 
"trait.camel.apache.org/container.image="+expectedImage,
                        "--annotation", 
"trait.camel.apache.org/jvm.enabled=false",
                        "--annotation", 
"trait.camel.apache.org/kamelets.enabled=false",
@@ -82,9 +69,9 @@ func TestPipeWithImage(t *testing.T) {
        t.Run("run with new image", func(t *testing.T) {
                expectedImage := "docker.io/jmalloc/echo-server:0.3.3"
 
-               Expect(KamelBind(ns,
-                       from.Name,
-                       to.Name,
+               Expect(KamelBindWithID(operatorID, ns,
+                       "my-own-timer-source",
+                       "my-own-log-sink",
                        "--annotation", 
"trait.camel.apache.org/container.image="+expectedImage,
                        "--annotation", 
"trait.camel.apache.org/jvm.enabled=false",
                        "--annotation", 
"trait.camel.apache.org/kamelets.enabled=false",
diff --git a/e2e/common/traits/health_test.go b/e2e/common/traits/health_test.go
index 2da0d25cf..ef994a7a9 100644
--- a/e2e/common/traits/health_test.go
+++ b/e2e/common/traits/health_test.go
@@ -138,24 +138,12 @@ func TestHealthTrait(t *testing.T) {
        t.Run("Readiness condition with stopped binding", func(t *testing.T) {
                name := "stopped-binding"
 
-               Expect(CreateTimerKamelet(ns, 
"my-own-timer-source")).To(Succeed())
-               Expect(CreateLogKamelet(ns, "my-own-log-sink")).To(Succeed())
+               Expect(CreateTimerKamelet(ns, 
"my-health-timer-source")()).To(Succeed())
+               Expect(CreateLogKamelet(ns, 
"my-health-log-sink")()).To(Succeed())
 
-               from := corev1.ObjectReference{
-                       Kind:       "Kamelet",
-                       Name:       "my-stopped-binding-timer-source",
-                       APIVersion: camelv1.SchemeGroupVersion.String(),
-               }
-
-               to := corev1.ObjectReference{
-                       Kind:       "Kamelet",
-                       Name:       "my-stopped-binding-log-sink",
-                       APIVersion: camelv1.SchemeGroupVersion.String(),
-               }
-
-               Expect(KamelBind(ns,
-                       from.Name,
-                       to.Name,
+               Expect(KamelBindWithID(operatorID, ns,
+                       "my-health-timer-source",
+                       "my-health-log-sink",
                        "-p", "source.message=Magicstring!",
                        "-p", "sink.loggerName=binding",
                        "--annotation", 
"trait.camel.apache.org/health.enabled=true",
diff --git a/pkg/cmd/run.go b/pkg/cmd/run.go
index 87f7edc9c..c2da4f6ad 100644
--- a/pkg/cmd/run.go
+++ b/pkg/cmd/run.go
@@ -742,8 +742,7 @@ func (o *runCmdOptions) parseAndConvertToTrait(cmd 
*cobra.Command,
                if err != nil {
                        return err
                }
-               // We try to autogenerate a configmap
-               if _, err := parseConfigAndGenCm(o.Context, cmd, c, config, 
integration); err != nil {
+               if err := parseConfig(o.Context, cmd, c, config, integration); 
err != nil {
                        return err
                }
                o.Traits = append(o.Traits, convertToTrait(convert(config), 
traitParam))
diff --git a/pkg/cmd/run_support.go b/pkg/cmd/run_support.go
index b3fde6146..68ba2d81f 100644
--- a/pkg/cmd/run_support.go
+++ b/pkg/cmd/run_support.go
@@ -39,7 +39,6 @@ import (
        "github.com/magiconair/properties"
        "github.com/pkg/errors"
        "github.com/spf13/cobra"
-       corev1 "k8s.io/api/core/v1"
 )
 
 func addDependency(cmd *cobra.Command, it *v1.Integration, dependency string, 
catalog *camel.RuntimeCatalog) {
@@ -48,14 +47,14 @@ func addDependency(cmd *cobra.Command, it *v1.Integration, 
dependency string, ca
        it.Spec.AddDependency(normalized)
 }
 
-func parseConfigAndGenCm(ctx context.Context, cmd *cobra.Command, c 
client.Client, config *resource.Config, integration *v1.Integration) 
(*corev1.ConfigMap, error) {
+func parseConfig(ctx context.Context, cmd *cobra.Command, c client.Client, 
config *resource.Config, integration *v1.Integration) error {
        switch config.StorageType() {
        case resource.StorageTypeConfigmap:
                cm := kubernetes.LookupConfigmap(ctx, c, integration.Namespace, 
config.Name())
                if cm == nil {
                        fmt.Fprintln(cmd.ErrOrStderr(), "Warn:", config.Name(), 
"Configmap not found in", integration.Namespace, "namespace, make sure to 
provide it before the Integration can run")
                } else if config.ContentType() != resource.ContentTypeData && 
cm.BinaryData != nil {
-                       return nil, fmt.Errorf("you cannot provide a binary 
config, use a text file instead")
+                       return fmt.Errorf("you cannot provide a binary config, 
use a text file instead")
                }
        case resource.StorageTypeSecret:
                secret := kubernetes.LookupSecret(ctx, c, 
integration.Namespace, config.Name())
@@ -64,10 +63,10 @@ func parseConfigAndGenCm(ctx context.Context, cmd 
*cobra.Command, c client.Clien
                }
        default:
                // Should never reach this
-               return nil, fmt.Errorf("invalid option type %s", 
config.StorageType())
+               return fmt.Errorf("invalid option type %s", 
config.StorageType())
        }
 
-       return nil, nil
+       return nil
 }
 
 func filterFileLocation(maybeFileLocations []string) []string {

Reply via email to