use of com.netflix.spinnaker.halyard.config.model.v1.node.Providers in project halyard by spinnaker.
the class ClouddriverBootstrapProfileFactory method disableAllProviders.
private void disableAllProviders(Providers providers) {
NodeIterator providerNodes = providers.getChildren();
Provider provider;
while ((provider = (Provider) providerNodes.getNext()) != null) {
provider.setEnabled(false);
}
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.Providers in project halyard by spinnaker.
the class ProviderService method getProvider.
public Provider getProvider(String deploymentName, String providerName) {
NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setProvider(providerName);
List<Provider> matching = lookupService.getMatchingNodesOfType(filter, Provider.class);
switch(matching.size()) {
case 0:
throw new ConfigNotFoundException(new ConfigProblemBuilder(Severity.FATAL, "No provider with name \"" + providerName + "\" could be found").setRemediation("Create a new provider with name \"" + providerName + "\"").build());
case 1:
return matching.get(0);
default:
throw new IllegalConfigException(new ConfigProblemBuilder(Severity.FATAL, "More than one provider with name \"" + providerName + "\" found").setRemediation("Manually delete or rename duplicate providers with name \"" + providerName + "\" in your halconfig file").build());
}
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.Providers in project halyard by spinnaker.
the class ArtifactProviderService method getAllArtifactProviders.
public List<ArtifactProvider> getAllArtifactProviders(String deploymentName) {
NodeFilter filter = new NodeFilter().setDeployment(deploymentName).withAnyArtifactProvider();
List<ArtifactProvider> matching = lookupService.getMatchingNodesOfType(filter, ArtifactProvider.class);
if (matching.size() == 0) {
throw new ConfigNotFoundException(new ConfigProblemBuilder(Severity.FATAL, "No providers could be found").build());
} else {
return matching;
}
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.Providers in project halyard by spinnaker.
the class ClouddriverProfileFactory method setProfile.
@Override
protected void setProfile(Profile profile, DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) {
super.setProfile(profile, deploymentConfiguration, endpoints);
// We need to make modifications to this deployment configuration, but can't use helpful objects
// like the accountService on a clone. Therefore, we'll make the modifications in place and
// restore to the original state when the modifications are written out.
Providers originalProviders = deploymentConfiguration.getProviders().cloneNode(Providers.class);
Providers modifiedProviders = deploymentConfiguration.getProviders();
DeploymentEnvironment deploymentEnvironment = deploymentConfiguration.getDeploymentEnvironment();
if (deploymentEnvironment.getBootstrapOnly() != null && deploymentEnvironment.getBootstrapOnly()) {
String bootstrapAccountName = deploymentEnvironment.getAccountName();
removeBootstrapOnlyAccount(modifiedProviders, deploymentConfiguration.getName(), bootstrapAccountName);
}
Artifacts artifacts = deploymentConfiguration.getArtifacts();
List<String> files = backupRequiredFiles(modifiedProviders, deploymentConfiguration.getName());
files.addAll(backupRequiredFiles(artifacts, deploymentConfiguration.getName()));
if (deploymentConfiguration.getProviders() != null) {
processProviders(deploymentConfiguration.getProviders());
}
profile.appendContents(yamlToString(modifiedProviders)).appendContents(yamlToString(new ArtifactWrapper(artifacts))).appendContents(profile.getBaseContents()).setRequiredFiles(files);
deploymentConfiguration.setProviders(originalProviders);
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.Providers in project halyard by spinnaker.
the class ClouddriverProfileFactory method removeBootstrapOnlyAccount.
@SuppressWarnings("unchecked")
private void removeBootstrapOnlyAccount(Providers providers, String deploymentName, String bootstrapAccountName) {
Account bootstrapAccount = accountService.getAnyProviderAccount(deploymentName, bootstrapAccountName);
Provider bootstrapProvider = ((Provider) bootstrapAccount.getParent());
bootstrapProvider.getAccounts().remove(bootstrapAccount);
if (bootstrapProvider.getAccounts().isEmpty()) {
bootstrapProvider.setEnabled(false);
if (bootstrapAccount instanceof ContainerAccount) {
ContainerAccount containerAccount = (ContainerAccount) bootstrapAccount;
DockerRegistryAccountReverseIndex revIndex = new DockerRegistryAccountReverseIndex(providers);
containerAccount.getDockerRegistries().forEach(reg -> {
Set<Account> dependentAccounts = revIndex.get(reg.getAccountName());
if (dependentAccounts == null || dependentAccounts.isEmpty()) {
DockerRegistryAccount regAcct = (DockerRegistryAccount) accountService.getAnyProviderAccount(deploymentName, reg.getAccountName());
((DockerRegistryProvider) regAcct.getParent()).getAccounts().remove(regAcct);
}
});
if (providers.getDockerRegistry().getAccounts().isEmpty()) {
providers.getDockerRegistry().setEnabled(false);
}
}
}
}
Aggregations