You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2022/11/04 12:22:14 UTC

[GitHub] [camel] gilvansfilho opened a new pull request, #8661: [CAMEL-18646] Provide custom configuration

gilvansfilho opened a new pull request, #8661:
URL: https://github.com/apache/camel/pull/8661

   Allows user to provide a custom git config file through a endpoint query param.
   Related to [Jira issue](https://issues.apache.org/jira/projects/CAMEL/issues/CAMEL-18646).
   
   <!-- Uncomment and fill this section if your PR is not trivial
   - [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it).  Trivial changes like typos do not require a JIRA issue.  Your pull request should address just this issue, without pulling in other changes.
   - [ ] Each commit in the pull request should have a meaningful subject line and body.
   - [ ] If you're unsure, you can format the pull request title like `[CAMEL-XXX] Fixes bug in camel-file component`, where you replace `CAMEL-XXX` with the appropriate JIRA issue.
   - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
   - [ ] Run `mvn clean install -Psourcecheck` in your module with source check enabled to make sure basic checks pass and there are no checkstyle violations. A more thorough check will be performed on your pull request automatically.
   Below are the contribution guidelines:
   https://github.com/apache/camel/blob/main/CONTRIBUTING.md
   -->
   


-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel] github-actions[bot] commented on pull request #8661: [CAMEL-18646] Provide custom configuration

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #8661:
URL: https://github.com/apache/camel/pull/8661#issuecomment-1304649926

   ### Components tested:
   
   | Total | Tested | Failed :x: | Passed :white_check_mark: | 
   | --- | --- | --- |  --- |
   | 1 | 1 | 0 | 1 |


-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel] davsclaus commented on a diff in pull request #8661: [CAMEL-18646] Provide custom configuration

Posted by GitBox <gi...@apache.org>.
davsclaus commented on code in PR #8661:
URL: https://github.com/apache/camel/pull/8661#discussion_r1015451221


##########
components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java:
##########
@@ -77,6 +77,9 @@ public class GitEndpoint extends DefaultEndpoint {
               label = "producer")
     private String operation;
 
+    @UriParam(description = "A String with path to a .gitconfig file", label = "producer,consumer,advanced")

Review Comment:
   producer and consumer is default, so only use "advanced"



-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel] orpiske commented on a diff in pull request #8661: [CAMEL-18646] Provide custom configuration

Posted by GitBox <gi...@apache.org>.
orpiske commented on code in PR #8661:
URL: https://github.com/apache/camel/pull/8661#discussion_r1013967297


##########
components/camel-git/src/main/docs/git-component.adoc:
##########
@@ -83,5 +83,17 @@ from("git:///tmp/testRepo?type=commit")
     .to(....)
 ---------------------------------------
 
+== Custom config file
+By default camel-git will load .gitconfig file from user home folder. You

Review Comment:
   Use quotes to force the formatting to recognize this as a file. For instance, to make it like this `.gitconfig`.



##########
components/camel-git/src/main/java/org/apache/camel/component/RepositoryFactory.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file 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.
+ */
+package org.apache.camel.component;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.camel.component.git.GitEndpoint;
+import org.apache.camel.util.ObjectHelper;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
+import org.eclipse.jgit.util.SystemReader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class RepositoryFactory {
+
+    private static final Logger LOG = LoggerFactory.getLogger(RepositoryFactory.class);
+    private static final SystemReader DEFAULT_INSTANCE;
+
+    static {
+        DEFAULT_INSTANCE = SystemReader.getInstance();
+    }
+
+    private RepositoryFactory() {
+    }
+
+    public static Repository of(GitEndpoint endpoint) throws IOException {
+        if (ObjectHelper.isNotEmpty(endpoint.getGitConfigFile())) {
+            return fromPathToConfigFile(endpoint, endpoint.getGitConfigFile());
+        }
+        return getRepository(endpoint, DEFAULT_INSTANCE);
+    }
+
+    private static Repository fromPathToConfigFile(GitEndpoint endpoint, String pathToConfigFile) throws IOException {
+        if (ObjectHelper.isEmpty(pathToConfigFile)) {
+            throw new IllegalArgumentException("Path to git config file must be supplied");
+        }
+        File gitConfigFile;
+        if (pathToConfigFile.startsWith("/")) { //load from system
+            gitConfigFile = new File(pathToConfigFile);
+        } else { //load from resources
+            gitConfigFile = new File(endpoint.getClass().getClassLoader().getResource(pathToConfigFile).getFile());
+        }
+        return getRepository(endpoint, new CustomConfigSystemReader(gitConfigFile));
+    }
+
+    private static Repository getRepository(GitEndpoint endpoint, SystemReader instance) throws IOException {
+        FileRepositoryBuilder builder = new FileRepositoryBuilder();
+        try {
+            SystemReader.setInstance(instance);
+            // scan environment GIT_* variables
+            return builder.setGitDir(new File(endpoint.getLocalPath(), ".git")).readEnvironment()
+                    .findGitDir() // scan up the file system tree
+                    .build();
+        } catch (IOException e) {
+            LOG.error("There was an error, cannot open {} repository", endpoint.getLocalPath());
+            throw e;

Review Comment:
   Maybe describe the error that caused the problem. Something like: `LOG.error("There was an error opening the {} repository: {}", endpoint.getLocalPath(), e.getMessage);` 
   
   Or ... just wrap the exception. 



##########
components/camel-git/src/main/java/org/apache/camel/component/RepositoryFactory.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file 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.
+ */
+package org.apache.camel.component;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.camel.component.git.GitEndpoint;
+import org.apache.camel.util.ObjectHelper;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
+import org.eclipse.jgit.util.SystemReader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class RepositoryFactory {
+
+    private static final Logger LOG = LoggerFactory.getLogger(RepositoryFactory.class);
+    private static final SystemReader DEFAULT_INSTANCE;
+
+    static {
+        DEFAULT_INSTANCE = SystemReader.getInstance();
+    }
+
+    private RepositoryFactory() {
+    }
+
+    public static Repository of(GitEndpoint endpoint) throws IOException {
+        if (ObjectHelper.isNotEmpty(endpoint.getGitConfigFile())) {
+            return fromPathToConfigFile(endpoint, endpoint.getGitConfigFile());
+        }
+        return getRepository(endpoint, DEFAULT_INSTANCE);
+    }
+
+    private static Repository fromPathToConfigFile(GitEndpoint endpoint, String pathToConfigFile) throws IOException {
+        if (ObjectHelper.isEmpty(pathToConfigFile)) {
+            throw new IllegalArgumentException("Path to git config file must be supplied");
+        }
+        File gitConfigFile;
+        if (pathToConfigFile.startsWith("/")) { //load from system

Review Comment:
   Wouldn't this break on Windows? 



-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel] gilvansfilho commented on a diff in pull request #8661: [CAMEL-18646] Provide custom configuration

Posted by GitBox <gi...@apache.org>.
gilvansfilho commented on code in PR #8661:
URL: https://github.com/apache/camel/pull/8661#discussion_r1014032557


##########
components/camel-git/src/main/java/org/apache/camel/component/RepositoryFactory.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file 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.
+ */
+package org.apache.camel.component;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.camel.component.git.GitEndpoint;
+import org.apache.camel.util.ObjectHelper;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
+import org.eclipse.jgit.util.SystemReader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class RepositoryFactory {
+
+    private static final Logger LOG = LoggerFactory.getLogger(RepositoryFactory.class);
+    private static final SystemReader DEFAULT_INSTANCE;
+
+    static {
+        DEFAULT_INSTANCE = SystemReader.getInstance();
+    }
+
+    private RepositoryFactory() {
+    }
+
+    public static Repository of(GitEndpoint endpoint) throws IOException {
+        if (ObjectHelper.isNotEmpty(endpoint.getGitConfigFile())) {
+            return fromPathToConfigFile(endpoint, endpoint.getGitConfigFile());
+        }
+        return getRepository(endpoint, DEFAULT_INSTANCE);
+    }
+
+    private static Repository fromPathToConfigFile(GitEndpoint endpoint, String pathToConfigFile) throws IOException {
+        if (ObjectHelper.isEmpty(pathToConfigFile)) {
+            throw new IllegalArgumentException("Path to git config file must be supplied");
+        }
+        File gitConfigFile;
+        if (pathToConfigFile.startsWith("/")) { //load from system

Review Comment:
   @oscerd 
   > Maybe we can also point a remote configfile through resource helper and copy locally in the git repository before using it.
   
   Do you think We do it using same config param (`gitConfigFile`) or other? like `remoteGitConfigFile`



-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel] davsclaus merged pull request #8661: [CAMEL-18646] Provide custom configuration

Posted by GitBox <gi...@apache.org>.
davsclaus merged PR #8661:
URL: https://github.com/apache/camel/pull/8661


-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel] github-actions[bot] commented on pull request #8661: [CAMEL-18646] Provide custom configuration

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #8661:
URL: https://github.com/apache/camel/pull/8661#issuecomment-1305725051

   ### Components tested:
   
   | Total | Tested | Failed :x: | Passed :white_check_mark: | 
   | --- | --- | --- |  --- |
   | 1 | 1 | 0 | 1 |


-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel] github-actions[bot] commented on pull request #8661: [CAMEL-18646] Provide custom configuration

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #8661:
URL: https://github.com/apache/camel/pull/8661#issuecomment-1303522716

   ### Components tested:
   
   | Total | Tested | Failed :x: | Passed :white_check_mark: | 
   | --- | --- | --- |  --- |
   | 1 | 1 | 0 | 1 |


-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel] gilvansfilho commented on a diff in pull request #8661: [CAMEL-18646] Provide custom configuration

Posted by GitBox <gi...@apache.org>.
gilvansfilho commented on code in PR #8661:
URL: https://github.com/apache/camel/pull/8661#discussion_r1014725153


##########
components/camel-git/src/main/java/org/apache/camel/component/RepositoryFactory.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file 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.
+ */
+package org.apache.camel.component;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.camel.component.git.GitEndpoint;
+import org.apache.camel.util.ObjectHelper;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
+import org.eclipse.jgit.util.SystemReader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class RepositoryFactory {
+
+    private static final Logger LOG = LoggerFactory.getLogger(RepositoryFactory.class);
+    private static final SystemReader DEFAULT_INSTANCE;
+
+    static {
+        DEFAULT_INSTANCE = SystemReader.getInstance();
+    }
+
+    private RepositoryFactory() {
+    }
+
+    public static Repository of(GitEndpoint endpoint) throws IOException {
+        if (ObjectHelper.isNotEmpty(endpoint.getGitConfigFile())) {
+            return fromPathToConfigFile(endpoint, endpoint.getGitConfigFile());
+        }
+        return getRepository(endpoint, DEFAULT_INSTANCE);
+    }
+
+    private static Repository fromPathToConfigFile(GitEndpoint endpoint, String pathToConfigFile) throws IOException {
+        if (ObjectHelper.isEmpty(pathToConfigFile)) {
+            throw new IllegalArgumentException("Path to git config file must be supplied");
+        }
+        File gitConfigFile;
+        if (pathToConfigFile.startsWith("/")) { //load from system
+            gitConfigFile = new File(pathToConfigFile);
+        } else { //load from resources
+            gitConfigFile = new File(endpoint.getClass().getClassLoader().getResource(pathToConfigFile).getFile());
+        }
+        return getRepository(endpoint, new CustomConfigSystemReader(gitConfigFile));
+    }
+
+    private static Repository getRepository(GitEndpoint endpoint, SystemReader instance) throws IOException {
+        FileRepositoryBuilder builder = new FileRepositoryBuilder();
+        try {
+            SystemReader.setInstance(instance);
+            // scan environment GIT_* variables
+            return builder.setGitDir(new File(endpoint.getLocalPath(), ".git")).readEnvironment()
+                    .findGitDir() // scan up the file system tree
+                    .build();
+        } catch (IOException e) {
+            LOG.error("There was an error, cannot open {} repository", endpoint.getLocalPath());
+            throw e;

Review Comment:
   Done.



##########
components/camel-git/src/main/java/org/apache/camel/component/RepositoryFactory.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file 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.
+ */
+package org.apache.camel.component;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.camel.component.git.GitEndpoint;
+import org.apache.camel.util.ObjectHelper;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
+import org.eclipse.jgit.util.SystemReader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class RepositoryFactory {
+
+    private static final Logger LOG = LoggerFactory.getLogger(RepositoryFactory.class);
+    private static final SystemReader DEFAULT_INSTANCE;
+
+    static {
+        DEFAULT_INSTANCE = SystemReader.getInstance();
+    }
+
+    private RepositoryFactory() {
+    }
+
+    public static Repository of(GitEndpoint endpoint) throws IOException {
+        if (ObjectHelper.isNotEmpty(endpoint.getGitConfigFile())) {
+            return fromPathToConfigFile(endpoint, endpoint.getGitConfigFile());
+        }
+        return getRepository(endpoint, DEFAULT_INSTANCE);
+    }
+
+    private static Repository fromPathToConfigFile(GitEndpoint endpoint, String pathToConfigFile) throws IOException {
+        if (ObjectHelper.isEmpty(pathToConfigFile)) {
+            throw new IllegalArgumentException("Path to git config file must be supplied");
+        }
+        File gitConfigFile;
+        if (pathToConfigFile.startsWith("/")) { //load from system

Review Comment:
   Done.



-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel] gilvansfilho commented on a diff in pull request #8661: [CAMEL-18646] Provide custom configuration

Posted by GitBox <gi...@apache.org>.
gilvansfilho commented on code in PR #8661:
URL: https://github.com/apache/camel/pull/8661#discussion_r1014031024


##########
components/camel-git/src/main/java/org/apache/camel/component/RepositoryFactory.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file 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.
+ */
+package org.apache.camel.component;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.camel.component.git.GitEndpoint;
+import org.apache.camel.util.ObjectHelper;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
+import org.eclipse.jgit.util.SystemReader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class RepositoryFactory {
+
+    private static final Logger LOG = LoggerFactory.getLogger(RepositoryFactory.class);
+    private static final SystemReader DEFAULT_INSTANCE;
+
+    static {
+        DEFAULT_INSTANCE = SystemReader.getInstance();
+    }
+
+    private RepositoryFactory() {
+    }
+
+    public static Repository of(GitEndpoint endpoint) throws IOException {
+        if (ObjectHelper.isNotEmpty(endpoint.getGitConfigFile())) {
+            return fromPathToConfigFile(endpoint, endpoint.getGitConfigFile());
+        }
+        return getRepository(endpoint, DEFAULT_INSTANCE);
+    }
+
+    private static Repository fromPathToConfigFile(GitEndpoint endpoint, String pathToConfigFile) throws IOException {
+        if (ObjectHelper.isEmpty(pathToConfigFile)) {
+            throw new IllegalArgumentException("Path to git config file must be supplied");
+        }
+        File gitConfigFile;
+        if (pathToConfigFile.startsWith("/")) { //load from system
+            gitConfigFile = new File(pathToConfigFile);
+        } else { //load from resources
+            gitConfigFile = new File(endpoint.getClass().getClassLoader().getResource(pathToConfigFile).getFile());
+        }
+        return getRepository(endpoint, new CustomConfigSystemReader(gitConfigFile));
+    }
+
+    private static Repository getRepository(GitEndpoint endpoint, SystemReader instance) throws IOException {
+        FileRepositoryBuilder builder = new FileRepositoryBuilder();
+        try {
+            SystemReader.setInstance(instance);
+            // scan environment GIT_* variables
+            return builder.setGitDir(new File(endpoint.getLocalPath(), ".git")).readEnvironment()
+                    .findGitDir() // scan up the file system tree
+                    .build();
+        } catch (IOException e) {
+            LOG.error("There was an error, cannot open {} repository", endpoint.getLocalPath());
+            throw e;

Review Comment:
   `LOG.error("There was an error opening the {} repository: {}", endpoint.getLocalPath(), e.getMessage);` This will create a sonar issue.
   
   So wrap on wich exception?



-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel] github-actions[bot] commented on pull request #8661: [CAMEL-18646] Provide custom configuration

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #8661:
URL: https://github.com/apache/camel/pull/8661#issuecomment-1304646280

   ### Components tested:
   
   | Total | Tested | Failed :x: | Passed :white_check_mark: | 
   | --- | --- | --- |  --- |
   | 1 | 1 | 0 | 1 |


-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel] github-actions[bot] commented on pull request #8661: [CAMEL-18646] Provide custom configuration

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #8661:
URL: https://github.com/apache/camel/pull/8661#issuecomment-1304647711

   ### Components tested:
   
   | Total | Tested | Failed :x: | Passed :white_check_mark: | 
   | --- | --- | --- |  --- |
   | 10 | 10 | 1 | 10 |


-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel] orpiske commented on a diff in pull request #8661: [CAMEL-18646] Provide custom configuration

Posted by GitBox <gi...@apache.org>.
orpiske commented on code in PR #8661:
URL: https://github.com/apache/camel/pull/8661#discussion_r1014785533


##########
components/camel-git/src/main/java/org/apache/camel/component/RepositoryFactory.java:
##########
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file 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.
+ */
+package org.apache.camel.component;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.nio.channels.Channels;
+import java.nio.channels.ReadableByteChannel;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.component.git.GitEndpoint;
+import org.apache.camel.support.ResourceHelper;
+import org.apache.camel.util.ObjectHelper;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
+import org.eclipse.jgit.util.SystemReader;
+
+public abstract class RepositoryFactory {
+
+    private static final SystemReader DEFAULT_INSTANCE;
+    private static final List<String> VALID_SCHEMES = Arrays.asList("classpath:", "file:", "http:", "https:");
+
+    static {
+        DEFAULT_INSTANCE = SystemReader.getInstance();
+    }
+
+    private RepositoryFactory() {
+    }
+
+    public static Repository of(GitEndpoint endpoint) {
+        if (ObjectHelper.isNotEmpty(endpoint.getGitConfigFile())) {
+            return resolveConfigFile(endpoint, endpoint.getGitConfigFile());
+        }
+        return getRepository(endpoint, DEFAULT_INSTANCE);
+    }
+
+    private static Repository resolveConfigFile(GitEndpoint endpoint, String uri) {
+        if (ObjectHelper.isEmpty(uri)) {
+            throw new IllegalArgumentException("URI to git config file must be supplied");
+        }
+
+        if (!ResourceHelper.hasScheme(uri) || !VALID_SCHEMES.contains(ResourceHelper.getScheme(uri))) {
+            throw new IllegalArgumentException(
+                    "URI to git config file must have scheme:path pattern where scheme could be classpath, file, http or https");
+        }
+
+        String schema = ResourceHelper.getScheme(uri);
+        String path = uri.substring(schema.length());
+
+        File gitConfigFile;
+        if (ResourceHelper.isClasspathUri(uri)) {
+            gitConfigFile = new File(endpoint.getClass().getClassLoader().getResource(path).getFile());
+        } else if (ResourceHelper.isHttpUri(uri)) {
+            try {
+                gitConfigFile = getTempFileFromHttp(uri);
+            } catch (IOException e) {
+                throw new RuntimeCamelException(String.format("Something goes wrong when loading: %s", uri), e);

Review Comment:
   Just a minor grammatical nitpick: "Something went wrong when loading". 



##########
components/camel-git/src/main/java/org/apache/camel/component/RepositoryFactory.java:
##########
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file 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.
+ */
+package org.apache.camel.component;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.nio.channels.Channels;
+import java.nio.channels.ReadableByteChannel;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.component.git.GitEndpoint;
+import org.apache.camel.support.ResourceHelper;
+import org.apache.camel.util.ObjectHelper;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
+import org.eclipse.jgit.util.SystemReader;
+
+public abstract class RepositoryFactory {
+
+    private static final SystemReader DEFAULT_INSTANCE;
+    private static final List<String> VALID_SCHEMES = Arrays.asList("classpath:", "file:", "http:", "https:");
+
+    static {
+        DEFAULT_INSTANCE = SystemReader.getInstance();
+    }
+
+    private RepositoryFactory() {
+    }
+
+    public static Repository of(GitEndpoint endpoint) {
+        if (ObjectHelper.isNotEmpty(endpoint.getGitConfigFile())) {
+            return resolveConfigFile(endpoint, endpoint.getGitConfigFile());
+        }
+        return getRepository(endpoint, DEFAULT_INSTANCE);
+    }
+
+    private static Repository resolveConfigFile(GitEndpoint endpoint, String uri) {
+        if (ObjectHelper.isEmpty(uri)) {
+            throw new IllegalArgumentException("URI to git config file must be supplied");
+        }
+
+        if (!ResourceHelper.hasScheme(uri) || !VALID_SCHEMES.contains(ResourceHelper.getScheme(uri))) {
+            throw new IllegalArgumentException(
+                    "URI to git config file must have scheme:path pattern where scheme could be classpath, file, http or https");
+        }
+
+        String schema = ResourceHelper.getScheme(uri);
+        String path = uri.substring(schema.length());
+
+        File gitConfigFile;
+        if (ResourceHelper.isClasspathUri(uri)) {
+            gitConfigFile = new File(endpoint.getClass().getClassLoader().getResource(path).getFile());
+        } else if (ResourceHelper.isHttpUri(uri)) {
+            try {
+                gitConfigFile = getTempFileFromHttp(uri);
+            } catch (IOException e) {
+                throw new RuntimeCamelException(String.format("Something goes wrong when loading: %s", uri), e);
+            }
+        } else { //load from system
+            gitConfigFile = new File(path);
+            if (!gitConfigFile.exists() || gitConfigFile.isDirectory()) {
+                throw new IllegalArgumentException(String.format("Invalid file: %s", path));

Review Comment:
   And based on the comment above, I'd reword the exception message to: `"The configuration file at %s is unreadable (either missing, lacking proper access permission os is not a regular file")`



##########
components/camel-git/src/main/java/org/apache/camel/component/RepositoryFactory.java:
##########
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file 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.
+ */
+package org.apache.camel.component;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.nio.channels.Channels;
+import java.nio.channels.ReadableByteChannel;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.component.git.GitEndpoint;
+import org.apache.camel.support.ResourceHelper;
+import org.apache.camel.util.ObjectHelper;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
+import org.eclipse.jgit.util.SystemReader;
+
+public abstract class RepositoryFactory {
+
+    private static final SystemReader DEFAULT_INSTANCE;
+    private static final List<String> VALID_SCHEMES = Arrays.asList("classpath:", "file:", "http:", "https:");
+
+    static {
+        DEFAULT_INSTANCE = SystemReader.getInstance();
+    }
+
+    private RepositoryFactory() {
+    }
+
+    public static Repository of(GitEndpoint endpoint) {
+        if (ObjectHelper.isNotEmpty(endpoint.getGitConfigFile())) {
+            return resolveConfigFile(endpoint, endpoint.getGitConfigFile());
+        }
+        return getRepository(endpoint, DEFAULT_INSTANCE);
+    }
+
+    private static Repository resolveConfigFile(GitEndpoint endpoint, String uri) {
+        if (ObjectHelper.isEmpty(uri)) {
+            throw new IllegalArgumentException("URI to git config file must be supplied");
+        }
+
+        if (!ResourceHelper.hasScheme(uri) || !VALID_SCHEMES.contains(ResourceHelper.getScheme(uri))) {
+            throw new IllegalArgumentException(
+                    "URI to git config file must have scheme:path pattern where scheme could be classpath, file, http or https");
+        }
+
+        String schema = ResourceHelper.getScheme(uri);
+        String path = uri.substring(schema.length());
+
+        File gitConfigFile;
+        if (ResourceHelper.isClasspathUri(uri)) {
+            gitConfigFile = new File(endpoint.getClass().getClassLoader().getResource(path).getFile());
+        } else if (ResourceHelper.isHttpUri(uri)) {
+            try {
+                gitConfigFile = getTempFileFromHttp(uri);
+            } catch (IOException e) {
+                throw new RuntimeCamelException(String.format("Something goes wrong when loading: %s", uri), e);
+            }
+        } else { //load from system
+            gitConfigFile = new File(path);
+            if (!gitConfigFile.exists() || gitConfigFile.isDirectory()) {

Review Comment:
   This fails to take into account access permissions for file. I'd recommend using [Files.isReadable](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/file/Files.html#isReadable(java.nio.file.Path)) to ensure that the file is a regular file that exists and is also readable.



##########
components/camel-git/src/main/java/org/apache/camel/component/RepositoryFactory.java:
##########
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file 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.
+ */
+package org.apache.camel.component;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.nio.channels.Channels;
+import java.nio.channels.ReadableByteChannel;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.component.git.GitEndpoint;
+import org.apache.camel.support.ResourceHelper;
+import org.apache.camel.util.ObjectHelper;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
+import org.eclipse.jgit.util.SystemReader;
+
+public abstract class RepositoryFactory {
+
+    private static final SystemReader DEFAULT_INSTANCE;
+    private static final List<String> VALID_SCHEMES = Arrays.asList("classpath:", "file:", "http:", "https:");
+
+    static {
+        DEFAULT_INSTANCE = SystemReader.getInstance();
+    }
+
+    private RepositoryFactory() {
+    }
+
+    public static Repository of(GitEndpoint endpoint) {
+        if (ObjectHelper.isNotEmpty(endpoint.getGitConfigFile())) {
+            return resolveConfigFile(endpoint, endpoint.getGitConfigFile());
+        }
+        return getRepository(endpoint, DEFAULT_INSTANCE);
+    }
+
+    private static Repository resolveConfigFile(GitEndpoint endpoint, String uri) {
+        if (ObjectHelper.isEmpty(uri)) {
+            throw new IllegalArgumentException("URI to git config file must be supplied");
+        }
+
+        if (!ResourceHelper.hasScheme(uri) || !VALID_SCHEMES.contains(ResourceHelper.getScheme(uri))) {
+            throw new IllegalArgumentException(
+                    "URI to git config file must have scheme:path pattern where scheme could be classpath, file, http or https");
+        }
+
+        String schema = ResourceHelper.getScheme(uri);
+        String path = uri.substring(schema.length());
+
+        File gitConfigFile;
+        if (ResourceHelper.isClasspathUri(uri)) {
+            gitConfigFile = new File(endpoint.getClass().getClassLoader().getResource(path).getFile());
+        } else if (ResourceHelper.isHttpUri(uri)) {
+            try {
+                gitConfigFile = getTempFileFromHttp(uri);
+            } catch (IOException e) {
+                throw new RuntimeCamelException(String.format("Something goes wrong when loading: %s", uri), e);
+            }
+        } else { //load from system
+            gitConfigFile = new File(path);
+            if (!gitConfigFile.exists() || gitConfigFile.isDirectory()) {
+                throw new IllegalArgumentException(String.format("Invalid file: %s", path));
+            }
+        }
+
+        return getRepository(endpoint, new CustomConfigSystemReader(gitConfigFile));
+    }
+
+    private static Repository getRepository(GitEndpoint endpoint, SystemReader instance) {
+        FileRepositoryBuilder builder = new FileRepositoryBuilder();
+        try {
+            SystemReader.setInstance(instance);
+            // scan environment GIT_* variables
+            return builder.setGitDir(new File(endpoint.getLocalPath(), ".git")).readEnvironment()
+                    .findGitDir() // scan up the file system tree
+                    .build();
+        } catch (IOException e) {
+            throw new RuntimeCamelException(
+                    String.format("There was an error, cannot open %s repository", endpoint.getLocalPath()), e);

Review Comment:
   Nitpicking a bit: "There was an error opening the repository at %s."



-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel] oscerd commented on a diff in pull request #8661: [CAMEL-18646] Provide custom configuration

Posted by GitBox <gi...@apache.org>.
oscerd commented on code in PR #8661:
URL: https://github.com/apache/camel/pull/8661#discussion_r1014033634


##########
components/camel-git/src/main/java/org/apache/camel/component/RepositoryFactory.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file 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.
+ */
+package org.apache.camel.component;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.camel.component.git.GitEndpoint;
+import org.apache.camel.util.ObjectHelper;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
+import org.eclipse.jgit.util.SystemReader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class RepositoryFactory {
+
+    private static final Logger LOG = LoggerFactory.getLogger(RepositoryFactory.class);
+    private static final SystemReader DEFAULT_INSTANCE;
+
+    static {
+        DEFAULT_INSTANCE = SystemReader.getInstance();
+    }
+
+    private RepositoryFactory() {
+    }
+
+    public static Repository of(GitEndpoint endpoint) throws IOException {
+        if (ObjectHelper.isNotEmpty(endpoint.getGitConfigFile())) {
+            return fromPathToConfigFile(endpoint, endpoint.getGitConfigFile());
+        }
+        return getRepository(endpoint, DEFAULT_INSTANCE);
+    }
+
+    private static Repository fromPathToConfigFile(GitEndpoint endpoint, String pathToConfigFile) throws IOException {
+        if (ObjectHelper.isEmpty(pathToConfigFile)) {
+            throw new IllegalArgumentException("Path to git config file must be supplied");
+        }
+        File gitConfigFile;
+        if (pathToConfigFile.startsWith("/")) { //load from system

Review Comment:
   Probably with remoteGitConfigFile. With resource helper you could able to grab file content directly from classpath, filesystem, http etc.



-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel] orpiske commented on a diff in pull request #8661: [CAMEL-18646] Provide custom configuration

Posted by GitBox <gi...@apache.org>.
orpiske commented on code in PR #8661:
URL: https://github.com/apache/camel/pull/8661#discussion_r1014086840


##########
components/camel-git/src/main/java/org/apache/camel/component/RepositoryFactory.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file 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.
+ */
+package org.apache.camel.component;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.camel.component.git.GitEndpoint;
+import org.apache.camel.util.ObjectHelper;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
+import org.eclipse.jgit.util.SystemReader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class RepositoryFactory {
+
+    private static final Logger LOG = LoggerFactory.getLogger(RepositoryFactory.class);
+    private static final SystemReader DEFAULT_INSTANCE;
+
+    static {
+        DEFAULT_INSTANCE = SystemReader.getInstance();
+    }
+
+    private RepositoryFactory() {
+    }
+
+    public static Repository of(GitEndpoint endpoint) throws IOException {
+        if (ObjectHelper.isNotEmpty(endpoint.getGitConfigFile())) {
+            return fromPathToConfigFile(endpoint, endpoint.getGitConfigFile());
+        }
+        return getRepository(endpoint, DEFAULT_INSTANCE);
+    }
+
+    private static Repository fromPathToConfigFile(GitEndpoint endpoint, String pathToConfigFile) throws IOException {
+        if (ObjectHelper.isEmpty(pathToConfigFile)) {
+            throw new IllegalArgumentException("Path to git config file must be supplied");
+        }
+        File gitConfigFile;
+        if (pathToConfigFile.startsWith("/")) { //load from system
+            gitConfigFile = new File(pathToConfigFile);
+        } else { //load from resources
+            gitConfigFile = new File(endpoint.getClass().getClassLoader().getResource(pathToConfigFile).getFile());
+        }
+        return getRepository(endpoint, new CustomConfigSystemReader(gitConfigFile));
+    }
+
+    private static Repository getRepository(GitEndpoint endpoint, SystemReader instance) throws IOException {
+        FileRepositoryBuilder builder = new FileRepositoryBuilder();
+        try {
+            SystemReader.setInstance(instance);
+            // scan environment GIT_* variables
+            return builder.setGitDir(new File(endpoint.getLocalPath(), ".git")).readEnvironment()
+                    .findGitDir() // scan up the file system tree
+                    .build();
+        } catch (IOException e) {
+            LOG.error("There was an error, cannot open {} repository", endpoint.getLocalPath());
+            throw e;

Review Comment:
   I think `RuntimeCamelException` should do the trick.



-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel] github-actions[bot] commented on pull request #8661: [CAMEL-18646] Provide custom configuration

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #8661:
URL: https://github.com/apache/camel/pull/8661#issuecomment-1304873318

   ### Components tested:
   
   | Total | Tested | Failed :x: | Passed :white_check_mark: | 
   | --- | --- | --- |  --- |
   | 1 | 1 | 0 | 1 |


-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel] gilvansfilho commented on a diff in pull request #8661: [CAMEL-18646] Provide custom configuration

Posted by GitBox <gi...@apache.org>.
gilvansfilho commented on code in PR #8661:
URL: https://github.com/apache/camel/pull/8661#discussion_r1014024339


##########
components/camel-git/src/main/java/org/apache/camel/component/RepositoryFactory.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file 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.
+ */
+package org.apache.camel.component;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.camel.component.git.GitEndpoint;
+import org.apache.camel.util.ObjectHelper;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
+import org.eclipse.jgit.util.SystemReader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class RepositoryFactory {
+
+    private static final Logger LOG = LoggerFactory.getLogger(RepositoryFactory.class);
+    private static final SystemReader DEFAULT_INSTANCE;
+
+    static {
+        DEFAULT_INSTANCE = SystemReader.getInstance();
+    }
+
+    private RepositoryFactory() {
+    }
+
+    public static Repository of(GitEndpoint endpoint) throws IOException {
+        if (ObjectHelper.isNotEmpty(endpoint.getGitConfigFile())) {
+            return fromPathToConfigFile(endpoint, endpoint.getGitConfigFile());
+        }
+        return getRepository(endpoint, DEFAULT_INSTANCE);
+    }
+
+    private static Repository fromPathToConfigFile(GitEndpoint endpoint, String pathToConfigFile) throws IOException {
+        if (ObjectHelper.isEmpty(pathToConfigFile)) {
+            throw new IllegalArgumentException("Path to git config file must be supplied");
+        }
+        File gitConfigFile;
+        if (pathToConfigFile.startsWith("/")) { //load from system

Review Comment:
   Sure, this will. I will change.



-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel] github-actions[bot] commented on pull request #8661: [CAMEL-18646] Provide custom configuration

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #8661:
URL: https://github.com/apache/camel/pull/8661#issuecomment-1303409673

   :star2: Thank you for your contribution to the Apache Camel project! :star2: 
   
   :warning: Please note that the changes on this PR may be **tested automatically**. 
   
   If necessary Apache Camel Committers may access logs and test results in the job summaries!


-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel] github-actions[bot] commented on pull request #8661: [CAMEL-18646] Provide custom configuration

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #8661:
URL: https://github.com/apache/camel/pull/8661#issuecomment-1303539971

   ### Components tested:
   
   | Total | Tested | Failed :x: | Passed :white_check_mark: | 
   | --- | --- | --- |  --- |
   | 1 | 1 | 0 | 1 |


-- 
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-unsubscribe@camel.apache.org

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


[GitHub] [camel] gilvansfilho commented on a diff in pull request #8661: [CAMEL-18646] Provide custom configuration

Posted by GitBox <gi...@apache.org>.
gilvansfilho commented on code in PR #8661:
URL: https://github.com/apache/camel/pull/8661#discussion_r1014725125


##########
components/camel-git/src/main/docs/git-component.adoc:
##########
@@ -83,5 +83,17 @@ from("git:///tmp/testRepo?type=commit")
     .to(....)
 ---------------------------------------
 
+== Custom config file
+By default camel-git will load .gitconfig file from user home folder. You

Review Comment:
   Done.



-- 
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-unsubscribe@camel.apache.org

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