/**
* Configures the builder from the requirements and chosen host configuration
*/
public void configure(SshHostConfiguration sshHostConfig, FabricRequirements requirements, ProfileRequirements profileRequirements) {
SshConfiguration sshHosts = requirements.getSshConfiguration();
host = sshHostConfig.getHostName();
if (Strings.isNullOrBlank(host)) {
throw new IllegalArgumentException("Missing host property in the ssh configuration: " + sshHostConfig);
}
String preferredAddress = getPreferredAddress();
if (Strings.isNullOrBlank(preferredAddress)) {
preferredAddress = sshHostConfig.getPreferredAddress();
if (Strings.isNullOrBlank(preferredAddress)) {
preferredAddress = host;
}
preferredAddress(preferredAddress);
}
path = sshHostConfig.getPath();
if (Strings.isNullOrBlank(path)) {
if (sshHosts != null) {
path = sshHosts.getDefaultPath();
}
if (Strings.isNullOrBlank(path)) {
path = DEFAULT_PATH;
}
}
Integer portValue = sshHostConfig.getPort();
if (portValue == null) {
if (sshHosts != null) {
portValue = sshHosts.getDefaultPort();
}
}
port = portValue != null ? portValue : DEFAULT_SSH_PORT;
username = sshHostConfig.getUsername();
if (Strings.isNullOrBlank(username)) {
if (sshHosts != null) {
username = sshHosts.getDefaultUsername();
}
if (Strings.isNullOrBlank(username)) {
username = DEFAULT_USERNAME;
}
}
password = sshHostConfig.getPassword();
if (Strings.isNullOrBlank(password)) {
if (sshHosts != null) {
password = sshHosts.getDefaultPassword();
}
}
if (sshHosts != null) {
fallbackRepositories = sshHosts.getFallbackRepositories();
}
passPhrase = sshHostConfig.getPassPhrase();
if (Strings.isNullOrBlank(passPhrase)) {
if (sshHosts != null) {
passPhrase = sshHosts.getDefaultPassPhrase();
}
}
privateKeyFile = sshHostConfig.getPrivateKeyFile();
if (Strings.isNullOrBlank(privateKeyFile)) {
if (sshHosts != null) {
privateKeyFile = sshHosts.getDefaultPrivateKeyFile();
}
if (Strings.isNullOrBlank(privateKeyFile)) {
privateKeyFile = DEFAULT_PRIVATE_KEY_FILE;
}
}