Skip to content

Commit

Permalink
KOGITO-9405: Move from Kogito operator to SonataFlow Operator (#1782) (
Browse files Browse the repository at this point in the history
…#1789)

Co-authored-by: Eder Ignatowicz <ignatowicz@gmail.com>
Co-authored-by: Zbyněk Drápela <61500440+zdrapela@users.noreply.github.com>
  • Loading branch information
3 people authored Jun 21, 2023
1 parent d7d4448 commit 723e19b
Show file tree
Hide file tree
Showing 23 changed files with 95 additions and 94 deletions.
2 changes: 1 addition & 1 deletion packages/kn-plugin-workflow/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# kn-plugin-workflow

`kn-plugin-workflow` is a plugin of the Knative Client, to enable users to quickly set up a local Kogito Serverless Workflow project from the command line.
`kn-plugin-workflow` is a plugin of the Knative Client, to enable users to quickly set up a local SonataFlow project from the command line.

[Read the documentation](https://kiegroup.github.io/kogito-docs/serverlessworkflow/main/tooling/kn-plugin-workflow-overview.html)

Expand Down
6 changes: 3 additions & 3 deletions packages/kn-plugin-workflow/env/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ module.exports = composeEnv([require("@kie-tools/root-env/env")], {
KN_PLUGIN_WORKFLOW__version: {
name: "KN_PLUGIN_WORKFLOW__version",
default: packageJson.version,
description: "Knative Workflow plugin version",
description: "Knative SonataFlow plugin version",
},
KN_PLUGIN_WORKFLOW__quarkusPlatformGroupId: {
name: "KN_PLUGIN_WORKFLOW__quarkusPlatformGroupId",
default: "io.quarkus.platform",
description: "Quarkus group to be used when creating the Kogito Serverless Workflow project",
description: "Quarkus group to be used when creating the SonataFlow project",
},
KN_PLUGIN_WORKFLOW__quarkusVersion: {
name: "KN_PLUGIN_WORKFLOW__quarkusVersion",
default: "2.16.7.Final",
description: "Quarkus version to be used when creating the Kogito Serverless Workflow project",
description: "Quarkus version to be used when creating the SonataFlow project",
},
}),
get env() {
Expand Down
4 changes: 2 additions & 2 deletions packages/kn-plugin-workflow/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.19
require (
github.com/docker/docker v23.0.6+incompatible
github.com/jstemmer/go-junit-report/v2 v2.0.0
github.com/kiegroup/kogito-serverless-operator/workflowproj v0.0.0-20230613140808-9a658cef8f79
github.com/kiegroup/kogito-serverless-operator/workflowproj v0.0.0-20230619124910-96f05158ba87
github.com/ory/viper v1.7.5
github.com/spf13/afero v1.9.3
github.com/spf13/cobra v1.6.1
Expand Down Expand Up @@ -47,7 +47,7 @@ require (
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kiegroup/kogito-serverless-operator/api v0.0.0-20230613074518-8c40a054ef3c // indirect
github.com/kiegroup/kogito-serverless-operator/api v0.0.0-20230619124910-96f05158ba87 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
Expand Down
8 changes: 4 additions & 4 deletions packages/kn-plugin-workflow/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,10 @@ github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/X
github.com/jstemmer/go-junit-report/v2 v2.0.0 h1:bMZNO9B16VFn07tKyi4YJFIbZtVmJaa5Xakv9dcwK58=
github.com/jstemmer/go-junit-report/v2 v2.0.0/go.mod h1:mgHVr7VUo5Tn8OLVr1cKnLuEy0M92wdRntM99h7RkgQ=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/kiegroup/kogito-serverless-operator/api v0.0.0-20230613074518-8c40a054ef3c h1:NnuKFXj+IBNS6Mo1u7FIZwt+Q6q5lCiLlwgwAvNn+us=
github.com/kiegroup/kogito-serverless-operator/api v0.0.0-20230613074518-8c40a054ef3c/go.mod h1:W6mlmZuoa+yDwSRXiUEpNif0LBwzRAbpk0Xa4nxCOO0=
github.com/kiegroup/kogito-serverless-operator/workflowproj v0.0.0-20230613140808-9a658cef8f79 h1:KVHmFFVKsbfvYWUwZYB0ON+Lstg9tuqvC+Y1Q8ziKlg=
github.com/kiegroup/kogito-serverless-operator/workflowproj v0.0.0-20230613140808-9a658cef8f79/go.mod h1:0I0BmfULxZjRN7Lj1VsQtZ47k8g3ZRtEkJq5ODPr3HA=
github.com/kiegroup/kogito-serverless-operator/api v0.0.0-20230619124910-96f05158ba87 h1:RgW8XqqkibzzD4EXnqiFvKVxJ4BQFbF89GQLtDB1iWc=
github.com/kiegroup/kogito-serverless-operator/api v0.0.0-20230619124910-96f05158ba87/go.mod h1:5nAGodPBf6ebCjFtF7JKl40Ji0ptG0JwJNT/P0OupfE=
github.com/kiegroup/kogito-serverless-operator/workflowproj v0.0.0-20230619124910-96f05158ba87 h1:yV7MBYTaCDylcsxeF+LMdFQh6BFsuaDXwkteSEIZdtk=
github.com/kiegroup/kogito-serverless-operator/workflowproj v0.0.0-20230619124910-96f05158ba87/go.mod h1:0I0BmfULxZjRN7Lj1VsQtZ47k8g3ZRtEkJq5ODPr3HA=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
Expand Down
3 changes: 2 additions & 1 deletion packages/kn-plugin-workflow/go.work.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
github.com/emicklei/go-restful v2.15.0+incompatible h1:8KpYO/Xl/ZudZs5RNOEhWMBY4hmzlZhhRd9cu+jrZP4=
github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U=
github.com/jstemmer/go-junit-report v0.9.1 h1:6QPYqodiu3GuPL+7mfx+NwDdp2eTkp9IfEUpgAwUN0o=
github.com/kiegroup/kogito-serverless-operator/api v0.0.0-20230619124910-96f05158ba87 h1:RgW8XqqkibzzD4EXnqiFvKVxJ4BQFbF89GQLtDB1iWc=
github.com/kiegroup/kogito-serverless-operator/api v0.0.0-20230619124910-96f05158ba87/go.mod h1:5nAGodPBf6ebCjFtF7JKl40Ji0ptG0JwJNT/P0OupfE=
10 changes: 5 additions & 5 deletions packages/kn-plugin-workflow/pkg/command/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ type CreateCmdConfig struct {
func NewCreateCommand() *cobra.Command {
var cmd = &cobra.Command{
Use: "create",
Short: "Creates a new Workflow project",
Short: "Creates a new SonataFlow project",
Long: `
Creates a Workflow file in the specified directory (new-project is the default).
This plain Serverless Workflow project targets use cases requiring a single Serverless
This SonataFlow project targets use cases requiring a single Serverless
Workflow file definition.
Additionally, you can define the configurable parameters of your application in the
"application.properties" file (inside the root directory).
You can also store your spec files (i.e., Open API files)inside the "specs" folder.
You can also store your spec files (i.e., Open API files) inside the "specs" folder.
`,
Example: `
# Create a project in the local directory
Expand Down Expand Up @@ -70,7 +70,7 @@ func NewCreateCommand() *cobra.Command {
}

func runCreate(cfg CreateCmdConfig) error {
fmt.Println("🛠️ Creating Serverless Workflow project")
fmt.Println("🛠️ Creating SonataFlow project")

if err := os.Mkdir(cfg.ProjectName, os.ModePerm); err != nil {
return fmt.Errorf("❌ ERROR: Error creating project directory: %w", err)
Expand All @@ -81,7 +81,7 @@ func runCreate(cfg CreateCmdConfig) error {
return fmt.Errorf("❌ ERROR: Error creating workflow file: %w", err)
}

fmt.Println("🎉 Kogito Serverless Workflow project successfully created")
fmt.Println("🎉 SonataFlow project successfully created")

return nil

Expand Down
14 changes: 7 additions & 7 deletions packages/kn-plugin-workflow/pkg/command/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ import (
func NewDeployCommand() *cobra.Command {
var cmd = &cobra.Command{
Use: "deploy",
Short: "Deploy a Kogito Serverless Workflow file on Kubernetes via Kogito Serverless Workflow Operator",
Short: "Deploy a SonataFlow project on Kubernetes via SonataFlow Operator",
Long: `
Deploy a Kogito Serverless Workflow file in Kubernetes via the Kogito Serverless Workflow Operator.
Deploy a SonataFlow project in Kubernetes via the SonataFlow Operator.
`,
Example: `
# Deploy the workflow from the current directory's project.
# as a Knative service. You must provide target namespace.
# Deploy the workflow project from the current directory's project.
# You must provide target namespace.
{{.Name}} deploy --namespace <your_namespace>
# Persist the generated Kubernetes manifests on a given path and deploy the
# workflow from the current directory's project.
Expand Down Expand Up @@ -77,7 +77,7 @@ func runDeployUndeploy(cmd *cobra.Command, args []string) error {
return fmt.Errorf("❌ ERROR: initializing deploy config: %w", err)
}

fmt.Println("🛠️️ Deploy a Kogito Serverless Workflow file on Kubernetes via the Kogito Serverless Workflow Operator...")
fmt.Println("🛠️️ Deploy a SonataFlow project on Kubernetes via the SonataFlow Operator...")

if err := checkEnvironment(&cfg); err != nil {
return fmt.Errorf("❌ ERROR: checking deploy environment: %w", err)
Expand All @@ -91,13 +91,13 @@ func runDeployUndeploy(cmd *cobra.Command, args []string) error {
return fmt.Errorf("❌ ERROR: applying deploy: %w", err)
}

fmt.Printf("\n🎉 Kogito Serverless Workflow project successfully deployed.")
fmt.Printf("\n🎉 SonataFlow project successfully deployed.\n")

return nil
}

func deploy(cfg *DeployUndeployCmdConfig) error {
fmt.Printf("🛠 Deploying your Kogito Serverless project in namespace %s\n", cfg.NameSpace)
fmt.Printf("🛠 Deploying your SonataFlow project in namespace %s\n", cfg.NameSpace)

manifestExtension := []string{".yaml"}

Expand Down
20 changes: 10 additions & 10 deletions packages/kn-plugin-workflow/pkg/command/deploy_undeploy_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
type DeployUndeployCmdConfig struct {
NameSpace string
KubectlContext string
SWFFile string
SonataFlowFile string
ManifestPath string
TempDir string
ApplicationPropertiesPath string
Expand Down Expand Up @@ -58,7 +58,7 @@ func checkEnvironment(cfg *DeployUndeployCmdConfig) error {
}
}

fmt.Println("🔎 Checking if the Kogito Serverless Workflow Operator is correctly installed...")
fmt.Println("🔎 Checking if the SonataFlow Operator is correctly installed...")
if err := common.CheckOperatorInstalled(); err != nil {
return err
}
Expand All @@ -67,14 +67,14 @@ func checkEnvironment(cfg *DeployUndeployCmdConfig) error {
}

func generateManifests(cfg *DeployUndeployCmdConfig) error {
fmt.Println("\n🛠️ Generating your manifests...")
fmt.Println("🔍 Looking for your Serverless Workflow File...")
if file, err := findServerlessWorkflowFile(); err != nil {
fmt.Println("\n🛠️ Generating your manifests...")
fmt.Println("🔍 Looking for your SonataFlow files...")
if file, err := findSonataFlowFile(); err != nil {
return err
} else {
cfg.SWFFile = file
cfg.SonataFlowFile = file
}
fmt.Printf(" - ✅ Serverless workflow file found: %s\n", cfg.SWFFile)
fmt.Printf(" - ✅ SonataFlow file found: %s\n", cfg.SonataFlowFile)

fmt.Println("🔍 Looking for your configuration support files...")

Expand Down Expand Up @@ -102,7 +102,7 @@ func generateManifests(cfg *DeployUndeployCmdConfig) error {

fmt.Println("🚚️ Generating your Kubernetes manifest files..")

swfFile, err := common.MustGetFile(cfg.SWFFile)
swfFile, err := common.MustGetFile(cfg.SonataFlowFile)
if err != nil {
return err
}
Expand Down Expand Up @@ -148,7 +148,7 @@ func findApplicationPropertiesPath(directoryPath string) string {
return filePath
}

func findServerlessWorkflowFile() (string, error) {
func findSonataFlowFile() (string, error) {
extensions := []string{metadata.YAMLExtension, metadata.YAMLExtensionShort, metadata.JSONExtension}

dir, err := os.Getwd()
Expand All @@ -168,7 +168,7 @@ func findServerlessWorkflowFile() (string, error) {
case 1:
return matchingFiles[0], nil
default:
return "", fmt.Errorf("❌ ERROR: multiple serverless workflow definition files found")
return "", fmt.Errorf("❌ ERROR: multiple SonataFlow definition files found")
}
}

Expand Down
8 changes: 4 additions & 4 deletions packages/kn-plugin-workflow/pkg/command/quarkus/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ type BuildCmdConfig struct {
func NewBuildCommand() *cobra.Command {
var cmd = &cobra.Command{
Use: "build",
Short: "Build a Kogito Serverless Workflow project and generate a container image",
Short: "Build a Quarkus SonataFlow project and generate a container image",
Long: `
Builds a Kogito Serverless Workflow project in the current directory
Builds a Quarkus SonataFlow project in the current directory
resulting in a container image.
By default the resultant container image will have the project name. It can be
overridden with the --image or with others image options, see help for more information.
Expand Down Expand Up @@ -110,7 +110,7 @@ func NewBuildCommand() *cobra.Command {
}

func runBuild(cmd *cobra.Command) (out string, err error) {
fmt.Println("🔨 Building your Quarkus Kogito Serverless Workflow project...")
fmt.Println("🔨 Building your Quarkus SonataFlow project...")

cfg, err := runBuildCmdConfig(cmd)
if err != nil {
Expand Down Expand Up @@ -144,7 +144,7 @@ func runBuild(cmd *cobra.Command) (out string, err error) {
return
}

fmt.Println("✅ Quarkus Kogito Serverless Workflow project successfully built")
fmt.Println("✅ Quarkus SonataFlow project successfully built")

return
}
Expand Down
20 changes: 10 additions & 10 deletions packages/kn-plugin-workflow/pkg/command/quarkus/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import (
func NewConvertCommand() *cobra.Command {
var cmd = &cobra.Command{
Use: "convert",
Short: "Convert a single-file Kogito Serverless Workflow project to a Quarkus project",
Short: "Convert a SonataFlow project to a Quarkus SonataFlow project",
Long: `
Convert a Single Kogito Serverless Workflow project to a Quarkus Project.
Convert a SonataFlow project to a Quarkus SonataFlow Project.
`,
Example: `
# Run the local directory
Expand All @@ -59,12 +59,12 @@ func NewConvertCommand() *cobra.Command {
}

func runConvert() error {
if common.IsSWFProject() {
if common.IsSonataFlowProject() {
return convert()
} else if common.IsQuarkusSWFProject() {
} else if common.IsQuarkusSonataFlowProject() {
return fmt.Errorf("looks like you are already inside a Quarkus project, so no need to convert it")
} else {
return fmt.Errorf("cannot find Kogito Serverless Workflow project")
return fmt.Errorf("cannot find SonataFlow project")
}
}

Expand Down Expand Up @@ -119,13 +119,13 @@ func convert() error {

func runConvertProject(cfg CreateQuarkusProjectConfig) (err error) {

fmt.Println("🔨 Creating a Quarkus Kogito Serverless Workflow project...")
fmt.Println("🔨 Creating a Quarkus SonataFlow project...")
if err = CreateQuarkusProject(cfg); err != nil {
fmt.Println("❌ Error creating Quarkus project", err)
return err
}

fmt.Println("🔨 Moving Kogito Serverless Workflow files to Quarkus project...")
fmt.Println("🔨 Moving SonataFlow files to Quarkus SonataFlow project...")
rootFolder, err := os.Getwd()
if err != nil {
return err
Expand All @@ -138,15 +138,15 @@ func runConvertProject(cfg CreateQuarkusProjectConfig) (err error) {
generatedQuarkusProjectPath := rootFolder + "/" + cfg.ProjectName

if err := copyDir(generatedQuarkusProjectPath, rootFolder); err != nil {
fmt.Println("❌ Error migrating Quarkus project files", err)
fmt.Println("❌ Error migrating Quarkus SonataFlow project files", err)
return err
}
if err := os.RemoveAll(generatedQuarkusProjectPath); err != nil {
fmt.Println("❌ Error migrating Quarkus project", err)
fmt.Println("❌ Error migrating Quarkus SonataFlow project", err)
return err
}

fmt.Println("✅ Quarkus Kogito Serverless Workflow project successfully created")
fmt.Println("✅ Quarkus SonataFlow project successfully created")

return nil
}
Expand Down
12 changes: 6 additions & 6 deletions packages/kn-plugin-workflow/pkg/command/quarkus/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ import (
func NewCreateCommand() *cobra.Command {
var cmd = &cobra.Command{
Use: "create",
Short: "Create a Kogito Serverless Workflow project",
Short: "Create a Quarkus SonataFlow project",
Long: `
Creates a Kogito Serverless Workflow project in the current directory.
Creates a Quarkus SonataFlow project in the current directory.
It sets up a Quarkus project with minimal extensions to build a workflow
project.
The generated project has a "hello world" workflow.sw.json located on the
Expand Down Expand Up @@ -84,16 +84,16 @@ func runCreate() error {
return err
}

fmt.Println("🛠️ Creating a Quarkus Kogito Serverless Workflow project...")
fmt.Println("🛠️ Creating a Quarkus SonataFlow project...")
if err = CreateQuarkusProject(cfg); err != nil {
fmt.Println("❌ ERROR: creating Quarkus project", err)
fmt.Println("❌ ERROR: creating Quarkus SonataFlow project", err)
return err
}

workflowFilePath := fmt.Sprintf("./%s/src/main/resources/%s", cfg.ProjectName, metadata.WorkflowSwJson)
common.CreateWorkflow(workflowFilePath)

fmt.Println("🎉 Quarkus Kogito Serverless Workflow project successfully created")
fmt.Println("🎉 Quarkus SonataFlow project successfully created")
return nil
}

Expand All @@ -115,7 +115,7 @@ func runCreateProject(cfg CreateQuarkusProjectConfig) (err error) {
fmt.Sprintf("-DprojectArtifactId=%s", cfg.ProjectName),
fmt.Sprintf("-Dextensions=%s", cfg.Extensions))

fmt.Println("Creating a Quarkus Kogito Serverless Workflow project...")
fmt.Println("Creating a Quarkus SonataFlow project...")

if err := common.RunCommand(
create,
Expand Down
8 changes: 4 additions & 4 deletions packages/kn-plugin-workflow/pkg/command/quarkus/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ type DeployCmdConfig struct {
func NewDeployCommand() *cobra.Command {
var cmd = &cobra.Command{
Use: "deploy",
Short: "Deploy a Kogito Serverless Workflow project",
Short: "Deploy a Quarkus SonataFlow project",
Long: `
Deploys a Kogito Serverless Workflow project in the current directory.
Deploys a Quarkus SonataFlow project in the current directory.
By default, this command uses the ./target/kubernetes folder to find
the deployment files generated in the build process. The build step
is required before using the deploy command.
Expand Down Expand Up @@ -64,7 +64,7 @@ func NewDeployCommand() *cobra.Command {
}

func runDeploy(cmd *cobra.Command, args []string) error {
fmt.Println("🛠️ Deploying your Quarkus Kogito Serverless Workflow project...")
fmt.Println("🛠️ Deploying your Quarkus SonataFlow project...")

cfg, err := runDeployCmdConfig(cmd)
if err != nil {
Expand All @@ -79,7 +79,7 @@ func runDeploy(cmd *cobra.Command, args []string) error {
return err
}

fmt.Println("🎉 Quarkus Kogito Serverless Workflow project successfully deployed")
fmt.Println("🎉 Quarkus SonataFlow project successfully deployed")

return nil
}
Expand Down
4 changes: 2 additions & 2 deletions packages/kn-plugin-workflow/pkg/command/quarkus/quarkus.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
func NewQuarkusCommand() *cobra.Command {
var cmd = &cobra.Command{
Use: "quarkus",
Short: "Manage Kogito Serverless Workflow built in Quarkus projects",
Long: `Manage Kogito Serverless Workflow built in Quarkus projects`,
Short: "Manage SonataFlow projects built in Quarkus",
Long: `Manage SonataFlow projects built in Quarkus`,
SuggestFor: []string{"quaks", "qarkus"},
}

Expand Down
Loading

0 comments on commit 723e19b

Please sign in to comment.