tree: 8340fb534ba01c1a110c614e399221507b7b1436 [path history] [tgz]
  1. testdata/
  2. camelschema.go
  3. go.mod
  4. go.sum
  5. io.go
  6. Makefile
  7. operator.go
  8. README.md
  9. resources.go
  10. resources_test.go
  11. workflowproj.go
  12. workflowproj_test.go
workflowproj/README.md

Workflow Project Handler

Handler to programmatically convert a local SonataFlow project into Kubernetes manifests to deploy with the operator.

How to

Add this module to your project's dependencies:

go get github.com/kiegroup/kogito-serverless-workflow/workflowproj

Then you should have access to the main entry point of this package, which is the workflow project handler builder.

The API is simple enough to describe in a few lines:

package main

import (
	"os"

	"github.com/apache/incubator-kie-kogito-serverless-operator/workflowproj"
)

func Main() {
	// we are ignoring errors just for demo purposes, but don't do this!
	workflowFile, _ := os.Open("myworkflow.sw.json")
	propertiesFile, _ := os.Open("application.properties")
	specFile, _ := os.Open("myopenapi.yaml")
	defer workflowFile.Close()
	defer propertiesFile.Close()
	defer specFile.Close()
	
	// create the handler
	handler := workflowproj.New("mynamespace").
		WithWorkflow(workflowFile).
		WithAppProperties(propertiesFile).
		AddResource("myopenapi.yaml", specFile)

	// You can easily generate the Kubernetes manifests to later use client-go to deploy them in the cluster...
	objs, _ := handler.AsObjects()
	// client.Create(...), other stuff
	
	// ... or you can save the files locally to use them later or to integrate in a GitOps process
	_ = handler.SaveAsKubernetesManifests("/my/dir/")
}

The SonataFlow custom resource generated is annotated with the devmode profile . Every other resource added to the project is a ConfigMap handling these resources for you.

Given that you already have the SonataFlow Operator installed , to deploy the generated project you can simply run:

kubectl apply -f /my/dir/* -n "mynamespace"