ricardozanini commented on code in PR #2465:
URL:
https://github.com/apache/incubator-kie-tools/pull/2465#discussion_r1742520755
##########
packages/kn-plugin-workflow/pkg/common/k8sclient/goapi.go:
##########
@@ -0,0 +1,242 @@
+package k8sclient
+
+import (
+ "context"
+ "fmt"
+ "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
+ "log"
+ "os"
+ "path/filepath"
+ "strings"
+
+ "k8s.io/apimachinery/pkg/api/meta"
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
+ "k8s.io/apimachinery/pkg/util/yaml"
+
+ "k8s.io/apimachinery/pkg/api/errors"
+ "k8s.io/client-go/dynamic"
+ "k8s.io/client-go/rest"
+ "k8s.io/client-go/tools/clientcmd"
+ "k8s.io/client-go/tools/clientcmd/api"
+)
+
+type GoAPI struct{}
Review Comment:
It is a very nice adapter implementation. 👍
##########
packages/kn-plugin-workflow/pkg/command/quarkus/deploy.go:
##########
@@ -71,6 +74,11 @@ func NewDeployCommand() *cobra.Command {
return cmd
}
+var crds = map[string][]string{
+ "SonataFlow Operator": metadata.SonataflowCRDs,
+ "Knative Serving and Knative Eventing": metadata.KnativeCoreServingCRDs,
Review Comment:
These are not mandatory—only the SonataFlow one. The Operator can manage the
cluster without Knative and deploy the objects accordingly.
##########
packages/kn-plugin-workflow/pkg/command/deploy.go:
##########
@@ -202,3 +203,18 @@ func runDeployCmdConfig(cmd *cobra.Command) (cfg
DeployUndeployCmdConfig, err er
return cfg, nil
}
+
+func CheckCRDs(crds []string, typeName string) error {
+ for _, crd := range crds {
+ err := common.CheckCrdExists(crd)
+ if err != nil {
+ var statusErr *apierrors.StatusError
+ if errors.As(err, &statusErr) &&
statusErr.ErrStatus.Reason == metav1.StatusReasonNotFound {
+ return fmt.Errorf("❌ ERROR: the required CRDs
are not installed.. Install the %s CRD first", typeName)
Review Comment:
```suggestion
return fmt.Errorf("❌ ERROR: the required CRDs
are not installed.. Install the %s CRD first. Usually this is done by
installing the SonataFlow Operator", typeName)
```
##########
packages/kn-plugin-workflow/pkg/command/quarkus/deploy.go:
##########
@@ -94,36 +105,19 @@ func runDeploy(cmd *cobra.Command, args []string) error {
func deployKnativeServiceAndEventingBindings(cfg DeployCmdConfig) (bool,
error) {
isKnativeEventingBindingsCreated := false
- createService := common.ExecCommand("kubectl", "apply", "-f",
fmt.Sprintf("%s/knative.yml", cfg.Path), fmt.Sprintf("--namespace=%s",
cfg.Namespace))
- if err := common.RunCommand(
- createService,
- "deploy",
- ); err != nil {
- fmt.Println("❌ ERROR: Deploy failed, Knative service was not
created.")
+
+ err := common.ExecuteApply(filepath.Join(cfg.Path, "knative.yml"),
cfg.Namespace)
Review Comment:
If we go to this branch, it means that the user is generating the artifacts
from Quarkus (which we will review later), which makes Knative mandatory in
this specific unique case.
##########
packages/kn-plugin-workflow/pkg/command/quarkus/testdata/kogito-complex3-custom-namespace.yml:
##########
@@ -0,0 +1,66 @@
+apiVersion: batch/v1
+kind: Job
+metadata:
+ name: example-job
+ namespace: mycustom
+spec:
+ template:
+ spec:
+ containers:
+ - name: example-job-container
+ image: busybox
+ command: ["echo", "Hello, Kubernetes!"]
+ restartPolicy: Never
+ backoffLimit: 4
+---
+apiVersion: batch/v1
+kind: CronJob
+metadata:
+ name: example-cronjob
+ namespace: mycustom
+spec:
+ schedule: "*/5 * * * *" # Запуск каждые 5 минут
Review Comment:
Nice Russian comment :D
##########
packages/kn-plugin-workflow/pkg/command/quarkus/deploy.go:
##########
@@ -71,6 +74,11 @@ func NewDeployCommand() *cobra.Command {
return cmd
}
+var crds = map[string][]string{
+ "SonataFlow Operator": metadata.SonataflowCRDs,
+ "Knative Serving and Knative Eventing": metadata.KnativeCoreServingCRDs,
Review Comment:
We can warn the users about it: "If Knative is not installed, you may not be
able to deploy serverless services or orchestrate events."
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]