use of com.netflix.spinnaker.halyard.deploy.deployment.v1.DeploymentDetails in project halyard by spinnaker.
the class DeployService method getDeploymentDetails.
private DeploymentDetails getDeploymentDetails(DeploymentConfiguration deploymentConfiguration) {
String deploymentName = deploymentConfiguration.getName();
BillOfMaterials billOfMaterials = artifactService.getBillOfMaterials(deploymentName);
DeploymentEnvironment.DeploymentType type = deploymentConfiguration.getDeploymentEnvironment().getType();
switch(type) {
case BakeDebian:
case LocalDebian:
case LocalGit:
return new DeploymentDetails().setDeploymentConfiguration(deploymentConfiguration).setDeploymentName(deploymentName).setBillOfMaterials(billOfMaterials);
case Distributed:
DeploymentEnvironment deploymentEnvironment = deploymentConfiguration.getDeploymentEnvironment();
String accountName = deploymentEnvironment.getAccountName();
if (accountName == null || accountName.isEmpty()) {
throw new HalException(FATAL, "An account name must be " + "specified as the desired place to deploy your simple clustered deployment.");
}
Account account = accountService.getAnyProviderAccount(deploymentConfiguration.getName(), accountName);
return new AccountDeploymentDetails().setAccount(account).setDeploymentConfiguration(deploymentConfiguration).setDeploymentName(deploymentName).setBillOfMaterials(billOfMaterials);
default:
throw new IllegalArgumentException("Unrecognized deployment type " + type);
}
}
use of com.netflix.spinnaker.halyard.deploy.deployment.v1.DeploymentDetails in project halyard by spinnaker.
the class DeployService method rollback.
public void rollback(String deploymentName, List<String> serviceNames) {
DeploymentConfiguration deploymentConfiguration = deploymentService.getDeploymentConfiguration(deploymentName);
SpinnakerServiceProvider<DeploymentDetails> serviceProvider = serviceProviderFactory.create(deploymentConfiguration);
List<SpinnakerService.Type> serviceTypes = serviceNames.stream().map(SpinnakerService.Type::fromCanonicalName).collect(Collectors.toList());
if (serviceTypes.isEmpty()) {
serviceTypes = serviceProvider.getServices().stream().map(SpinnakerService::getType).collect(Collectors.toList());
}
SpinnakerRuntimeSettings runtimeSettings = serviceProvider.buildRuntimeSettings(deploymentConfiguration);
Deployer deployer = getDeployer(deploymentConfiguration);
DeploymentDetails deploymentDetails = getDeploymentDetails(deploymentConfiguration);
deployer.rollback(serviceProvider, deploymentDetails, runtimeSettings, serviceTypes);
}
use of com.netflix.spinnaker.halyard.deploy.deployment.v1.DeploymentDetails in project halyard by spinnaker.
the class DeployService method clean.
public void clean(String deploymentName) {
DeploymentConfiguration deploymentConfiguration = deploymentService.getDeploymentConfiguration(deploymentName);
SpinnakerServiceProvider<DeploymentDetails> serviceProvider = serviceProviderFactory.create(deploymentConfiguration);
DeploymentDetails deploymentDetails = getDeploymentDetails(deploymentConfiguration);
RemoteAction action = serviceProvider.clean(deploymentDetails, serviceProvider.buildRuntimeSettings(deploymentConfiguration));
action.commitScript(halconfigDirectoryStructure.getUnInstallScriptPath(deploymentName));
}
use of com.netflix.spinnaker.halyard.deploy.deployment.v1.DeploymentDetails in project halyard by spinnaker.
the class LocalGitServiceProvider method getInstallCommand.
@Override
public String getInstallCommand(DeploymentDetails deploymentDetails, GenerateService.ResolvedConfiguration resolvedConfiguration, Map<String, String> installCommands) {
Map<String, Object> bindings;
List<SpinnakerService.Type> serviceTypes = new ArrayList<>(installCommands.keySet()).stream().map(SpinnakerService.Type::fromCanonicalName).collect(Collectors.toList());
List<String> serviceInstalls = serviceTypes.stream().map(t -> installCommands.get(t.getCanonicalName())).collect(Collectors.toList());
TemplatedResource resource = new StringReplaceJarResource("/git/install.sh");
bindings = new HashMap<>();
bindings.put("install-commands", String.join("\n", serviceInstalls));
return resource.setBindings(bindings).toString();
}
use of com.netflix.spinnaker.halyard.deploy.deployment.v1.DeploymentDetails in project halyard by spinnaker.
the class BakeDebianServiceProvider method getInstallCommand.
@Override
public String getInstallCommand(DeploymentDetails deploymentDetails, GenerateService.ResolvedConfiguration resolvedConfiguration, Map<String, String> installCommands, String startupCommand) {
Map<String, Object> bindings = new HashMap<>();
List<SpinnakerService.Type> serviceTypes = new ArrayList<>(installCommands.keySet()).stream().map(SpinnakerService.Type::fromCanonicalName).collect(Collectors.toList());
List<String> upstartNames = getPrioritizedBakeableServices(serviceTypes).stream().filter(i -> resolvedConfiguration.getServiceSettings(i.getService()).getEnabled()).map(i -> ((BakeDebianService) i).getUpstartServiceName()).filter(Objects::nonNull).collect(Collectors.toList());
List<String> systemdServiceConfigs = upstartNames.stream().map(n -> n + ".service").collect(Collectors.toList());
List<String> serviceInstalls = serviceTypes.stream().map(t -> installCommands.get(t.getCanonicalName())).collect(Collectors.toList());
TemplatedResource resource = new StringReplaceJarResource("/debian/init.sh");
bindings.put("services", Strings.join(upstartNames, " "));
bindings.put("systemd-service-configs", Strings.join(systemdServiceConfigs, " "));
String upstartInit = resource.setBindings(bindings).toString();
BillOfMaterials.ArtifactSources artifactSources = artifactService.getArtifactSources(deploymentDetails.getDeploymentName());
resource = new StringReplaceJarResource("/debian/pre-bake.sh");
bindings = new HashMap<>();
bindings.put("debian-repository", artifactSourcesConfig.mergeWithBomSources(artifactSources).getDebianRepository());
bindings.put("install-commands", String.join("\n", serviceInstalls));
bindings.put("upstart-init", upstartInit);
bindings.put("startup-file", Paths.get(startupScriptPath, "startup.sh").toString());
bindings.put("startup-command", startupCommand);
return resource.setBindings(bindings).toString();
}
Aggregations