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

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


The following commit(s) were added to refs/heads/release-2.2.x by this push:
     new a24184b8d Add optional install to tests - branch 2.2.x
a24184b8d is described below

commit a24184b8dbf5e63394b1db911a33c9d3a0866e11
Author: Lucie Krejcirova <lfabr...@redhat.com>
AuthorDate: Mon Mar 25 15:15:16 2024 +0100

    Add optional install to tests - branch 2.2.x
---
 e2e/support/test_support.go | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index 434d5ecd8..ac9a211ec 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -27,6 +27,7 @@ import (
        "bytes"
        "context"
        "encoding/json"
+       "encoding/pem"
        "errors"
        "fmt"
        "io"
@@ -321,7 +322,13 @@ func kamelInstallWithContext(ctx context.Context, 
operatorID string, namespace s
                fmt.Printf("Setting operator image pull policy to %s\n", 
opImagePullPolicy)
                installArgs = append(installArgs, 
"--operator-image-pull-policy", opImagePullPolicy)
        }
-
+       if len(os.Getenv("CAMEL_K_TEST_MAVEN_CA_PEM_PATH")) > 0 {
+               certName := "myCert"
+               secretName := "maven-ca-certs"
+               CreateSecretDecoded(namespace, 
os.Getenv("CAMEL_K_TEST_MAVEN_CA_PEM_PATH"), secretName, certName)
+               installArgs = append(installArgs, "--maven-repository", 
os.Getenv("KAMEL_INSTALL_MAVEN_REPOSITORIES"),
+                       "--maven-ca-secret", secretName+"/"+certName)
+       }
        installArgs = append(installArgs, args...)
        return KamelWithContext(ctx, installArgs...)
 }
@@ -1714,6 +1721,25 @@ func DeleteSecret(ns string, name string) error {
        }
        return TestClient().Delete(TestContext, &sec)
 }
+func CreateSecretDecoded(ns string, pathToFile string, secretName string, 
certName string) error {
+       bytes, _ := os.ReadFile(pathToFile)
+       block, _ := pem.Decode(bytes)
+
+       secret := corev1.Secret{
+               TypeMeta: metav1.TypeMeta{
+                       Kind:       "Secret",
+                       APIVersion: corev1.SchemeGroupVersion.String(),
+               },
+               ObjectMeta: metav1.ObjectMeta{
+                       Namespace: ns,
+                       Name:      secretName,
+               },
+               Data: map[string][]byte{
+                       certName: block.Bytes,
+               },
+       }
+       return TestClient().Create(TestContext, &secret)
+}
 
 func KnativeService(ns string, name string) func() *servingv1.Service {
        return func() *servingv1.Service {

Reply via email to