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

tiagobento pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-tools.git


The following commit(s) were added to refs/heads/main by this push:
     new 861458f2b3f kie-tools#2623: [kn-plugin-workflow] Parameterize Quarkus 
version with $(build-env versions.quarkus) (#2835)
861458f2b3f is described below

commit 861458f2b3fae0179ea44fd19886c63f48fa9585
Author: Dmitrii Tikhomirov <[email protected]>
AuthorDate: Mon Jan 13 09:02:54 2025 -0800

    kie-tools#2623: [kn-plugin-workflow] Parameterize Quarkus version with 
$(build-env versions.quarkus) (#2835)
---
 packages/kn-plugin-workflow/e2e-tests/helper_test.go   |  5 +++++
 .../e2e-tests/quarkus_convert_test.go                  |  4 ++--
 .../e2e-tests/quarkus_create_test.go                   |  4 ++--
 .../pkg/command/quarkus/deploy_test.go                 | 18 +++++++++++++++++-
 .../pkg/command/quarkus/testdata/knative.yml           |  4 ++--
 5 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/packages/kn-plugin-workflow/e2e-tests/helper_test.go 
b/packages/kn-plugin-workflow/e2e-tests/helper_test.go
index ad7f283e820..880a7ae06c7 100644
--- a/packages/kn-plugin-workflow/e2e-tests/helper_test.go
+++ b/packages/kn-plugin-workflow/e2e-tests/helper_test.go
@@ -35,10 +35,15 @@ import (
 
        
"github.com/apache/incubator-kie-tools/packages/kn-plugin-workflow/pkg/command"
        
"github.com/apache/incubator-kie-tools/packages/kn-plugin-workflow/pkg/command/quarkus"
+       
"github.com/apache/incubator-kie-tools/packages/kn-plugin-workflow/pkg/metadata"
        "github.com/spf13/cobra"
        "github.com/stretchr/testify/require"
 )
 
+// Holds quarkus dependencies populated from environment variables
+var quarkusDependencies = metadata.ResolveQuarkusDependencies()
+
+
 // ExecuteCommand executes a command with the given arguments and returns an 
error if the command fails.
 func ExecuteCommand(command string, args ...string) error {
        cmd := exec.Command(command, args...)
diff --git a/packages/kn-plugin-workflow/e2e-tests/quarkus_convert_test.go 
b/packages/kn-plugin-workflow/e2e-tests/quarkus_convert_test.go
index a6a94174f2d..0c5e317ca9e 100644
--- a/packages/kn-plugin-workflow/e2e-tests/quarkus_convert_test.go
+++ b/packages/kn-plugin-workflow/e2e-tests/quarkus_convert_test.go
@@ -55,8 +55,8 @@ var cfgTestInputQuarkusConvert_Success = 
[]CfgTestInputQuarkusConvert{
        {input: quarkus.CreateQuarkusProjectConfig{
                Extensions: "quarkus-jsonp,quarkus-smallrye-openapi",
                DependenciesVersion: metadata.DependenciesVersion{
-                       QuarkusPlatformGroupId: "io.quarkus.platform",
-                       QuarkusVersion:         "3.8.6",
+                       QuarkusPlatformGroupId: 
quarkusDependencies.QuarkusPlatformGroupId,
+                       QuarkusVersion: quarkusDependencies.QuarkusVersion,
                },
        }},
 }
diff --git a/packages/kn-plugin-workflow/e2e-tests/quarkus_create_test.go 
b/packages/kn-plugin-workflow/e2e-tests/quarkus_create_test.go
index 23aabd99c8f..22069344137 100644
--- a/packages/kn-plugin-workflow/e2e-tests/quarkus_create_test.go
+++ b/packages/kn-plugin-workflow/e2e-tests/quarkus_create_test.go
@@ -50,8 +50,8 @@ var cfgTestInputQuarkusCreate_Success = 
[]CfgTestInputQuarkusCreate{
                ProjectName: "serverless-workflow-hello-world",
                Extensions:  "quarkus-jsonp,quarkus-smallrye-openapi",
                DependenciesVersion: metadata.DependenciesVersion{
-                       QuarkusPlatformGroupId: "io.quarkus.platform",
-                       QuarkusVersion:         "3.8.6",
+                       QuarkusPlatformGroupId: 
quarkusDependencies.QuarkusPlatformGroupId,
+                       QuarkusVersion:         
quarkusDependencies.QuarkusVersion,
                },
        }},
 }
diff --git a/packages/kn-plugin-workflow/pkg/command/quarkus/deploy_test.go 
b/packages/kn-plugin-workflow/pkg/command/quarkus/deploy_test.go
index c3d292af363..addfccc4af4 100644
--- a/packages/kn-plugin-workflow/pkg/command/quarkus/deploy_test.go
+++ b/packages/kn-plugin-workflow/pkg/command/quarkus/deploy_test.go
@@ -24,6 +24,7 @@ import (
        "fmt"
        
"github.com/apache/incubator-kie-tools/packages/kn-plugin-workflow/pkg/common"
        
"github.com/apache/incubator-kie-tools/packages/kn-plugin-workflow/pkg/common/k8sclient"
+       
"github.com/apache/incubator-kie-tools/packages/kn-plugin-workflow/pkg/metadata"
        "github.com/spf13/afero"
        "github.com/stretchr/testify/assert"
        "k8s.io/apimachinery/pkg/api/errors"
@@ -34,6 +35,7 @@ import (
        "os/exec"
        "path/filepath"
        "strconv"
+       "strings"
        "testing"
 )
 
@@ -47,6 +49,8 @@ type testDeploy struct {
 
 const defaultPath = "./target/kubernetes"
 
+var quarkusDependencies = metadata.ResolveQuarkusDependencies()
+
 var testRunDeploy = []testDeploy{
        {input: DeployCmdConfig{Path: defaultPath}, expected: true, knative: 
"knative.yml", kogito: "kogito-default.yml"},
        {input: DeployCmdConfig{Path: "./different/folders"}, expected: true, 
knative: "knative.yml", kogito: "kogito-default.yml"},
@@ -175,10 +179,22 @@ func prepareFolderAndFiles(t *testing.T, test testDeploy) 
{
                test.input.Path = defaultPath
        }
        common.CreateFolderStructure(t, test.input.Path)
-       common.CopyFileInFolderStructure(t, test.input.Path, test.knative, 
"knative.yml")
+       knativeFixQuarkusVersionAndWriteToTestFolder(t, test)
        common.CopyFileInFolderStructure(t, test.input.Path, test.kogito, 
"kogito.yml")
 }
 
+func knativeFixQuarkusVersionAndWriteToTestFolder(t *testing.T, test 
testDeploy) {
+       knativeBytes, err := os.ReadFile(filepath.Join("testdata", 
"knative.yml"))
+       if err != nil {
+               t.Errorf("❌ ERROR: Failed to read Knative file: %v", err)
+       }
+       knativeWithQuarkusVersion := strings.ReplaceAll(string(knativeBytes), 
"QUARKUS_VERSION", quarkusDependencies.QuarkusVersion)
+
+       if err := afero.WriteFile(common.FS, filepath.Join(test.input.Path, 
"knative.yml"), []byte(knativeWithQuarkusVersion), 0644); err != nil {
+               t.Errorf("Error writing to file: %s", 
filepath.Join(test.input.Path, "knative.yml"))
+       }
+}
+
 func checkObjectCreated(obj unstructured.Unstructured, namespace string) 
(bool, error) {
        if namespace == "" {
                currentNamespace, err := common.GetNamespace()
diff --git 
a/packages/kn-plugin-workflow/pkg/command/quarkus/testdata/knative.yml 
b/packages/kn-plugin-workflow/pkg/command/quarkus/testdata/knative.yml
index fdbab5b243d..408cd8796ac 100644
--- a/packages/kn-plugin-workflow/pkg/command/quarkus/testdata/knative.yml
+++ b/packages/kn-plugin-workflow/pkg/command/quarkus/testdata/knative.yml
@@ -3,7 +3,7 @@ apiVersion: v1
 kind: ServiceAccount
 metadata:
   annotations:
-    app.quarkus.io/quarkus-version: 3.8.6
+    app.quarkus.io/quarkus-version: QUARKUS_VERSION
     app.quarkus.io/build-timestamp: 2024-08-22 - 21:01:20 +0000
   labels:
     app.kubernetes.io/version: 1.0.0-SNAPSHOT
@@ -14,7 +14,7 @@ apiVersion: serving.knative.dev/v1
 kind: Service
 metadata:
   annotations:
-    app.quarkus.io/quarkus-version: 3.8.6
+    app.quarkus.io/quarkus-version: QUARKUS_VERSION
     app.quarkus.io/build-timestamp: 2024-08-22 - 21:01:20 +0000
   labels:
     app.kubernetes.io/version: 1.0.0-SNAPSHOT


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to