mirror of https://github.com/apache/jclouds.git
reinstated arg so that we are binary compatible for drop-in w/whirr
This commit is contained in:
parent
f29a733b18
commit
7b72ef5cfc
|
@ -21,9 +21,10 @@ package org.jclouds.compute.functions;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.Template;
|
import org.jclouds.compute.domain.Template;
|
||||||
import org.jclouds.compute.options.TemplateOptions;
|
import org.jclouds.compute.options.RunScriptOptions;
|
||||||
import org.jclouds.domain.LoginCredentials;
|
import org.jclouds.domain.LoginCredentials;
|
||||||
import org.jclouds.domain.LoginCredentials.Builder;
|
import org.jclouds.domain.LoginCredentials.Builder;
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
|
||||||
|
@ -36,8 +37,14 @@ public class DefaultCredentialsFromImageOrOverridingCredentials implements Funct
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LoginCredentials apply(Template template) {
|
public LoginCredentials apply(Template template) {
|
||||||
TemplateOptions options = template.getOptions();
|
RunScriptOptions options = template.getOptions();
|
||||||
Builder builder = LoginCredentials.builder(template.getImage().getDefaultCredentials());
|
LoginCredentials defaultCreds = template.getImage().getDefaultCredentials();
|
||||||
|
return overrideDefaultCredentialsWithOptionsIfPresent(defaultCreds, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LoginCredentials overrideDefaultCredentialsWithOptionsIfPresent(
|
||||||
|
@Nullable LoginCredentials defaultCreds, RunScriptOptions options) {
|
||||||
|
Builder builder = LoginCredentials.builder(defaultCreds);
|
||||||
if (options.getLoginUser() != null)
|
if (options.getLoginUser() != null)
|
||||||
builder.user(options.getLoginUser());
|
builder.user(options.getLoginUser());
|
||||||
if (options.getLoginPassword() != null)
|
if (options.getLoginPassword() != null)
|
||||||
|
|
|
@ -21,6 +21,7 @@ package org.jclouds.compute.options;
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import org.jclouds.compute.functions.DefaultCredentialsFromImageOrOverridingCredentials;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.domain.LoginCredentials;
|
import org.jclouds.domain.LoginCredentials;
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
@ -330,6 +331,18 @@ public class RunScriptOptions {
|
||||||
return authenticateSudo;
|
return authenticateSudo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This will be removed in jclouds 1.4.0
|
||||||
|
* @see #getLoginPassword
|
||||||
|
* @see #getLoginPrivateKey
|
||||||
|
* @see #getLoginUser
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public Credentials getOverridingCredentials() {
|
||||||
|
return DefaultCredentialsFromImageOrOverridingCredentials.overrideDefaultCredentialsWithOptionsIfPresent(null,
|
||||||
|
this);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return the login password for
|
* @return the login password for
|
||||||
|
|
Loading…
Reference in New Issue