gnodet-bot commented on code in PR #30024:
URL: https://github.com/apache/camel/pull/30024#discussion_r4578664823


##########
dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesRun.java:
##########
@@ -904,6 +888,38 @@ void detectCluster() {
         }
     }
 
+    /**
+     * The properties of --property: a key=value, or the properties of a file 
(file:path, or a path). A key=value is a
+     * property also when its value is a path, such as camel.server.path=/api, 
which was taken for a file that does not
+     * exist and silently left out (CAMEL-26934).
+     *
+     * @throws CliException with exit code 66 for a properties file that does 
not exist
+     */
+    static String[] mergeProperties(String[] properties) throws IOException {
+        List<String> definiteProperties = new ArrayList<>();
+        for (String p : properties) {
+            int eq = p.indexOf('=');
+            String key = eq > 0 ? p.substring(0, eq) : null;
+            boolean keyValue = key != null && !key.contains("/") && 
!key.contains(File.separator);
+            if (p.startsWith("file:") || !keyValue) {
+                String filename = p.startsWith("file:") ? 
p.substring("file:".length()) : p;
+                File f = new File(filename);
+                if (!f.isFile()) {
+                    throw CliException.fileNotFound(
+                            "Properties file does not exist: " + filename + " 
(a property is given as key=value)");

Review Comment:
   💬 **Nit — error message is misleading for the `file:` case:**
   
   When the user writes `--property file:nope.properties` and the file doesn't 
exist, the message reads:
   
   > Properties file does not exist: nope.properties **(a property is given as 
key=value)**
   
   The parenthetical `(a property is given as key=value)` says the opposite of 
what happened — the user explicitly used `file:`, so they did *not* give a 
key=value. The hint only makes sense for the ambiguous bare-path case.
   
   Consider two distinct messages:
   
   ```suggestion
                       throw CliException.fileNotFound(
                               "Properties file does not exist: " + filename);
   ```
   
   …and for the bare-path case (`!keyValue && !p.startsWith("file:")`) keep the 
hint in a separate branch. Or at minimum, reword to something like `(to pass a 
property whose value contains a path, use key=value syntax)`.



-- 
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]

Reply via email to