squakez commented on code in PR #5440:
URL: https://github.com/apache/camel-k/pull/5440#discussion_r1584818308


##########
script/check_jdk_version.go:
##########
@@ -0,0 +1,33 @@
+package main

Review Comment:
   We have a cmd/util directory where we should host any tool. Please, keep the 
same structure.



##########
script/check_jdk_version.go:
##########
@@ -0,0 +1,33 @@
+package main
+
+import (
+       "fmt"
+       "os/exec"
+       "regexp"
+       "strconv"
+)
+
+func main() {
+
+       cmd := exec.Command("java", "-version")
+       output, err := cmd.CombinedOutput()
+       if err != nil {
+               panic(fmt.Sprintf("Error: %v\n", err))
+       }
+
+       versionStr := string(output)
+       versionRegex := regexp.MustCompile(`version 
"?([1-9]+)(\.([0-9]+)){2,3}"?`)
+       matches := versionRegex.FindStringSubmatch(versionStr)
+       if len(matches) < 2 {
+               panic(fmt.Sprintf("Unable to determine Java version: %s\n", 
versionStr))

Review Comment:
   IMO we should not panic. We cannot test all the possible JDK out there to 
make sure they return the expected text.



-- 
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: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to