You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kie.apache.org by ri...@apache.org on 2024/06/07 13:29:19 UTC

(incubator-kie-kogito-serverless-operator) branch main updated: Added Image() to workflowproj (#481)

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

ricardozanini pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-kogito-serverless-operator.git


The following commit(s) were added to refs/heads/main by this push:
     new 8db9006d Added Image() to workflowproj (#481)
8db9006d is described below

commit 8db9006d4ed56e782ce7a5bd80219c810cd85655
Author: Dmitrii Tikhomirov <tr...@users.noreply.github.com>
AuthorDate: Fri Jun 7 06:29:15 2024 -0700

    Added Image() to workflowproj (#481)
---
 workflowproj/workflowproj.go      | 6 ++++++
 workflowproj/workflowproj_test.go | 8 ++++++++
 2 files changed, 14 insertions(+)

diff --git a/workflowproj/workflowproj.go b/workflowproj/workflowproj.go
index 3845da81..44fe83a6 100644
--- a/workflowproj/workflowproj.go
+++ b/workflowproj/workflowproj.go
@@ -64,6 +64,8 @@ type WorkflowProjectHandler interface {
 	SaveAsKubernetesManifests(path string) error
 	// AsObjects returns a reference to the WorkflowProject holding the Kubernetes Manifests based on your files.
 	AsObjects() (*WorkflowProject, error)
+	// Image overrides the default image in the generated SonataFlow manifest
+	Image(image string) WorkflowProjectHandler
 }
 
 // WorkflowProject is a structure to hold every Kubernetes object generated by the given WorkflowProjectHandler handler.
@@ -301,6 +303,10 @@ func (w *workflowProjectHandler) addResourceConfigMapToProject(cm *corev1.Config
 	}
 	return nil
 }
+func (w *workflowProjectHandler) Image(image string) WorkflowProjectHandler {
+	w.project.Workflow.Spec.PodTemplate.Container.Image = image
+	return w
+}
 
 // IsDevProfile detects if the workflow is using the Dev profile or not
 func IsDevProfile(workflow *operatorapi.SonataFlow) bool {
diff --git a/workflowproj/workflowproj_test.go b/workflowproj/workflowproj_test.go
index 9d3cab67..6e9c876b 100644
--- a/workflowproj/workflowproj_test.go
+++ b/workflowproj/workflowproj_test.go
@@ -226,6 +226,14 @@ func Test_Handler_WorkflowService_SaveAs(t *testing.T) {
 	})
 }
 
+func TestWorkflowProjectHandler_Image(t *testing.T) {
+	handler := New("default").WithWorkflow(getWorkflowService())
+	proj, err := handler.AsObjects()
+	handler.Image("quay.io/kiegroup/kogito-service:latest")
+	assert.NoError(t, err)
+	assert.Equal(t, "quay.io/kiegroup/kogito-service:latest", proj.Workflow.Spec.PodTemplate.Container.Image)
+}
+
 func getWorkflowMinimalInvalid() io.Reader {
 	return mustGetFile("testdata/workflows/workflow-minimal-invalid.sw.json")
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org