Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(core): s/version/providerVersion #1914

Merged
merged 1 commit into from
Sep 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class KubernetesConfigurationProperties {
@ToString(includeNames = true)
static class ManagedAccount {
String name
ProviderVersion version
ProviderVersion providerVersion
String environment
String accountType
String context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,21 @@ class KubernetesProviderConfig implements Runnable {

for (KubernetesNamedAccountCredentials credentials : allAccounts) {
KubernetesCachingAgentDispatcher dispatcher
switch (credentials.version) {
switch (credentials.providerVersion) {
case ProviderVersion.v1:
dispatcher = kubernetesV1CachingAgentDispatcher
break
case ProviderVersion.v2:
dispatcher = kubernetesV2CachingAgentDispatcher
break
default:
log.warn "No support for caching accounts of $credentials.version"
log.warn "No support for caching accounts of $credentials.providerVersion"
continue
}

def newlyAddedAgents = dispatcher.buildAllCachingAgents(credentials)

log.info "Adding ${newlyAddedAgents.size()} agents for account ${credentials.name} at version ${credentials.version}"
log.info "Adding ${newlyAddedAgents.size()} agents for account ${credentials.name} at version ${credentials.providerVersion}"

// If there is an agent scheduler, then this provider has been through the AgentController in the past.
// In that case, we need to do the scheduling here (because accounts have been added to a running system).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
public class KubernetesNamedAccountCredentials<C extends KubernetesCredentials> implements AccountCredentials<C> {
final private String cloudProvider = "kubernetes";
final private String name;
final private ProviderVersion version;
final private ProviderVersion providerVersion;
final private String environment;
final private String accountType;
final private String context;
Expand All @@ -60,7 +60,7 @@ public class KubernetesNamedAccountCredentials<C extends KubernetesCredentials>
private final AccountCredentialsRepository accountCredentialsRepository;

KubernetesNamedAccountCredentials(String name,
ProviderVersion version,
ProviderVersion providerVersion,
AccountCredentialsRepository accountCredentialsRepository,
String userAgent,
String environment,
Expand All @@ -79,7 +79,7 @@ public class KubernetesNamedAccountCredentials<C extends KubernetesCredentials>
Registry spectatorRegistry,
C credentials) {
this.name = name;
this.version = version;
this.providerVersion = providerVersion;
this.environment = environment;
this.accountType = accountType;
this.context = context;
Expand Down Expand Up @@ -109,8 +109,8 @@ public String getName() {
}

@Override
public ProviderVersion getVersion() {
return version;
public ProviderVersion getProviderVersion() {
return providerVersion;
}

@Override
Expand Down Expand Up @@ -152,7 +152,7 @@ public List<String> getRequiredGroupMembership() {

static class Builder<C extends KubernetesCredentials> {
String name;
ProviderVersion version;
ProviderVersion providerVersion;
String environment;
String accountType;
String context;
Expand All @@ -176,8 +176,8 @@ Builder name(String name) {
return this;
}

Builder version(ProviderVersion version) {
this.version = version;
Builder providerVersion(ProviderVersion providerVersion) {
this.providerVersion = providerVersion;
return this;
}

Expand Down Expand Up @@ -270,7 +270,7 @@ Builder accountCredentialsRepository(AccountCredentialsRepository accountCredent
}

private C buildCredentials() {
switch (version) {
switch (providerVersion) {
case v1:
return (C) new KubernetesV1Credentials(
name,
Expand All @@ -293,7 +293,7 @@ private C buildCredentials() {
.setNamer(KubernetesManifest.class, new KubernetesManifestNamer());
return (C) new KubernetesV2Credentials(name, spectatorRegistry);
default:
throw new IllegalArgumentException("Unknown provider type: " + version);
throw new IllegalArgumentException("Unknown provider type: " + providerVersion);
}
}

Expand All @@ -310,8 +310,8 @@ KubernetesNamedAccountCredentials build() {
cacheThreads = 1;
}

if (version == null) {
version = v1;
if (providerVersion == null) {
providerVersion = v1;
}

if (StringUtils.isEmpty(kubeconfigFile)) {
Expand All @@ -330,7 +330,7 @@ KubernetesNamedAccountCredentials build() {

return new KubernetesNamedAccountCredentials(
name,
version,
providerVersion,
accountCredentialsRepository,
userAgent,
environment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class KubernetesNamedAccountCredentialsInitializer implements CredentialsInitial
.accountCredentialsRepository(accountCredentialsRepository)
.userAgent(clouddriverUserAgentApplicationName)
.name(managedAccount.name)
.version(managedAccount.version)
.providerVersion(managedAccount.providerVersion)
.environment(managedAccount.environment ?: managedAccount.name)
.accountType(managedAccount.accountType ?: managedAccount.name)
.context(managedAccount.context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public interface AccountCredentials<T> {
*
* @return the account's version.
*/
default ProviderVersion getVersion() {
default ProviderVersion getProviderVersion() {
return ProviderVersion.v1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class OperationsController {
String accountName = operation.credentials ?: operation.accountName ?: operation.account
if (accountName) {
def credentials = accountCredentialsRepository.getOne(accountName)
providerVersion = credentials.getVersion()
providerVersion = credentials.getProviderVersion()
} else {
log.warn "Unable to get account name from operation: $inputs"
}
Expand Down