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-tools.git


The following commit(s) were added to refs/heads/main by this push:
     new 19694daee0c kie-issues#1337: kn-plugin-workflow should verify if the 
cluster has SonataFlow Operator installed (#2446)
19694daee0c is described below

commit 19694daee0c7eff52da003a2a091e6c9c578c15f
Author: Dmitrii Tikhomirov <[email protected]>
AuthorDate: Mon Aug 12 05:40:57 2024 -0700

    kie-issues#1337: kn-plugin-workflow should verify if the cluster has 
SonataFlow Operator installed (#2446)
---
 packages/kn-plugin-workflow/pkg/command/deploy.go     |  7 +++++++
 packages/kn-plugin-workflow/pkg/common/kubectl.go     | 15 ++++++++++++---
 packages/kn-plugin-workflow/pkg/metadata/constants.go |  3 +++
 3 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/packages/kn-plugin-workflow/pkg/command/deploy.go 
b/packages/kn-plugin-workflow/pkg/command/deploy.go
index ba201e5aff2..d97443ee9f9 100644
--- a/packages/kn-plugin-workflow/pkg/command/deploy.go
+++ b/packages/kn-plugin-workflow/pkg/command/deploy.go
@@ -188,6 +188,13 @@ func runDeployCmdConfig(cmd *cobra.Command) (cfg 
DeployUndeployCmdConfig, err er
                return cfg, fmt.Errorf("❌ ERROR: failed to get default 
dashboards files folder: %w", err)
        }
 
+       // check if sonataflow operator CRDs are installed
+       for _, crd := range metadata.SonataflowCRDs {
+               if !common.CheckKubectlCrdExists(crd) {
+                       return cfg, fmt.Errorf("❌ ERROR: the required CRDs are 
not installed.. Install the SonataFlow Operator CRD first")
+               }
+       }
+
        //setup manifest path
        if err := setupConfigManifestPath(&cfg); err != nil {
                return cfg, err
diff --git a/packages/kn-plugin-workflow/pkg/common/kubectl.go 
b/packages/kn-plugin-workflow/pkg/common/kubectl.go
index 17b3f54396a..dfb349b3f72 100644
--- a/packages/kn-plugin-workflow/pkg/common/kubectl.go
+++ b/packages/kn-plugin-workflow/pkg/common/kubectl.go
@@ -6,15 +6,15 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *  http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
- * under the License. 
+ * under the License.
  */
 
 package common
@@ -68,3 +68,12 @@ func CheckKubectl() error {
        fmt.Println(" - ✅ kubectl is available")
        return nil
 }
+
+func CheckKubectlCrdExists(crd string) bool {
+       cmd := exec.Command("kubectl", "get", "crd", crd)
+       _, err := cmd.Output()
+       if err != nil {
+               return false
+       }
+       return true
+}
diff --git a/packages/kn-plugin-workflow/pkg/metadata/constants.go 
b/packages/kn-plugin-workflow/pkg/metadata/constants.go
index 601dee87cb6..b5179857bb8 100644
--- a/packages/kn-plugin-workflow/pkg/metadata/constants.go
+++ b/packages/kn-plugin-workflow/pkg/metadata/constants.go
@@ -48,6 +48,9 @@ var KogitoDependencies = []Dependency{
        {GroupId: "org.apache.kie.sonataflow", ArtifactId: 
"sonataflow-quarkus-devui", Version: "${kie.tooling.version}"},
 }
 
+// requared crds for sonataflow
+var SonataflowCRDs = []string{"sonataflowbuilds.sonataflow.org", 
"sonataflowclusterplatforms.sonataflow.org", 
"sonataflowplatforms.sonataflow.org", "sonataflows.sonataflow.org"}
+
 const (
        QuarkusMavenPlugin                          = "quarkus-maven-plugin"
        QuarkusKubernetesExtension                  = "quarkus-kubernetes"


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

Reply via email to