use of com.netflix.spinnaker.halyard.core.error.v1.HalException in project halyard by spinnaker.
the class DeployService method getDeployer.
private Deployer getDeployer(DeploymentConfiguration deploymentConfiguration) {
DeploymentEnvironment deploymentEnvironment = deploymentConfiguration.getDeploymentEnvironment();
DeploymentEnvironment.DeploymentType type = deploymentEnvironment.getType();
String accountName = deploymentEnvironment.getAccountName();
switch(type) {
case BakeDebian:
return bakeDeployer;
case LocalGit:
return localGitDeployer;
case LocalDebian:
return localDeployer;
case Distributed:
if (StringUtils.isEmpty(accountName)) {
throw new HalException(Problem.Severity.FATAL, "An account name must be " + "specified as the desired place to run your distributed deployment.");
}
Account account = accountService.getAnyProviderAccount(deploymentConfiguration.getName(), accountName);
Provider.ProviderType providerType = ((Provider) account.getParent()).providerType();
if (providerType == Provider.ProviderType.KUBERNETES && account.getProviderVersion() == V2) {
return kubectlDeployer;
} else {
return distributedDeployer;
}
default:
throw new IllegalArgumentException("Unrecognized deployment type " + type);
}
}
use of com.netflix.spinnaker.halyard.core.error.v1.HalException in project halyard by spinnaker.
the class VaultService method publishSecret.
public void publishSecret(DeploymentConfiguration deploymentConfiguration, String name, Path path) {
String contents;
try {
contents = IOUtils.toString(new FileInputStream(path.toFile()));
} catch (IOException e) {
throw new HalException(Problem.Severity.FATAL, "Failed to read config file " + path.toString() + ": " + e.getMessage());
}
publishSecret(deploymentConfiguration, name, contents);
}
use of com.netflix.spinnaker.halyard.core.error.v1.HalException in project halyard by spinnaker.
the class ServiceProviderFactory method createDeployableServiceProvider.
private SpinnakerServiceProvider createDeployableServiceProvider(DeploymentConfiguration deploymentConfiguration) {
DeploymentEnvironment deploymentEnvironment = deploymentConfiguration.getDeploymentEnvironment();
String accountName = deploymentEnvironment.getAccountName();
if (accountName == null || accountName.isEmpty()) {
throw new HalException(new ConfigProblemBuilder(Problem.Severity.FATAL, "An account name must be " + "specified as the desired place to run your simple clustered deployment.").build());
}
Account account = accountService.getAnyProviderAccount(deploymentConfiguration.getName(), accountName);
Provider.ProviderType providerType = ((Provider) account.getParent()).providerType();
switch(providerType) {
case KUBERNETES:
switch(account.getProviderVersion()) {
case V1:
return kubernetesV1DistributedServiceProvider;
case V2:
return kubectlServiceProvider;
default:
return kubernetesV1DistributedServiceProvider;
}
case GOOGLE:
return googleDistributedServiceProvider;
default:
throw new IllegalArgumentException("No Clustered Simple Deployment for " + providerType.getName());
}
}
use of com.netflix.spinnaker.halyard.core.error.v1.HalException in project halyard by spinnaker.
the class ArtifactAccountService method deleteArtifactAccount.
public void deleteArtifactAccount(String deploymentName, String providerName, String accountName) {
ArtifactProvider provider = artifactProviderService.getArtifactProvider(deploymentName, providerName);
boolean removed = provider.getAccounts().removeIf(account -> ((ArtifactAccount) account).getName().equals(accountName));
if (!removed) {
throw new HalException(new ConfigProblemBuilder(Severity.FATAL, "Artifact account \"" + accountName + "\" wasn't found").build());
}
}
use of com.netflix.spinnaker.halyard.core.error.v1.HalException in project halyard by spinnaker.
the class BakeryService method deleteBaseImage.
public void deleteBaseImage(String deploymentName, String bakeryDefaultsName, String baseImageId) {
BakeryDefaults bakeryDefaults = getBakeryDefaults(deploymentName, bakeryDefaultsName);
boolean removed = bakeryDefaults.getBaseImages().removeIf(baseImage -> ((BaseImage) baseImage).getBaseImage().getId().equals(baseImageId));
if (!removed) {
throw new HalException(new ConfigProblemBuilder(Severity.FATAL, "BaseImage \"" + baseImageId + "\" wasn't found").build());
}
}
Aggregations