jaikiran commented on a change in pull request #106: Support SSH config file in 
the ssh tasks
URL: https://github.com/apache/ant/pull/106#discussion_r338909104
 
 

 ##########
 File path: src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHBase.java
 ##########
 @@ -235,6 +259,37 @@ public void init() throws BuildException {
         this.port = SSH_PORT;
     }
 
+    /**
+     * Load the SSH configuration file.
+     * @throws BuildException on error
+     */
+    protected void loadSshConfig() throws BuildException {
+        if (sshConfig != null) {
+            if (!new File(sshConfig).exists()) {
+                throw new BuildException("The SSH configuration file specified 
doesn't exist: " + sshConfig);
+            }
+            
+            log("Loading SSH configuration file " + sshConfig, 
Project.MSG_DEBUG);
+            ConfigRepository.Config config = null;
+            try {
+                config = OpenSSHConfig.parseFile(sshConfig).getConfig(host);
+            } catch (IOException e) {
+                throw new BuildException("Failed to load the SSH configuration 
file " + sshConfig, e);
+            }
+            
+            host = config.getHostname();
+            
+            if (userInfo.getName() == null) {
 
 Review comment:
   Should this check perhaps happen before even trying to load the `sshConfig` 
file? So as to avoid the whole loading and parsing of the file?
   
   Perhaps load the file only if userInfo doesn't have the name or keyfile 
available?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@ant.apache.org
For additional commands, e-mail: dev-h...@ant.apache.org

Reply via email to