Search in sources :

Example 11 with StringReplaceJarResource

use of com.netflix.spinnaker.halyard.core.resource.v1.StringReplaceJarResource 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();
}
Also used : DeploymentDetails(com.netflix.spinnaker.halyard.deploy.deployment.v1.DeploymentDetails) ArtifactSourcesConfig(com.netflix.spinnaker.halyard.config.config.v1.ArtifactSourcesConfig) Autowired(org.springframework.beans.factory.annotation.Autowired) HalException(com.netflix.spinnaker.halyard.core.error.v1.HalException) HashMap(java.util.HashMap) ArtifactService(com.netflix.spinnaker.halyard.deploy.services.v1.ArtifactService) GenerateService(com.netflix.spinnaker.halyard.deploy.services.v1.GenerateService) SpinnakerRuntimeSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerRuntimeSettings) BakeServiceProvider(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.bake.BakeServiceProvider) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) Objects(java.util.Objects) Component(org.springframework.stereotype.Component) List(java.util.List) Paths(java.nio.file.Paths) StringReplaceJarResource(com.netflix.spinnaker.halyard.core.resource.v1.StringReplaceJarResource) Map(java.util.Map) Problem(com.netflix.spinnaker.halyard.core.problem.v1.Problem) RemoteAction(com.netflix.spinnaker.halyard.core.RemoteAction) BillOfMaterials(com.netflix.spinnaker.halyard.core.registry.v1.BillOfMaterials) SpinnakerService(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.SpinnakerService) Strings(io.fabric8.utils.Strings) TemplatedResource(com.netflix.spinnaker.halyard.core.resource.v1.TemplatedResource) HashMap(java.util.HashMap) TemplatedResource(com.netflix.spinnaker.halyard.core.resource.v1.TemplatedResource) SpinnakerService(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.SpinnakerService) BillOfMaterials(com.netflix.spinnaker.halyard.core.registry.v1.BillOfMaterials) StringReplaceJarResource(com.netflix.spinnaker.halyard.core.resource.v1.StringReplaceJarResource)

Example 12 with StringReplaceJarResource

use of com.netflix.spinnaker.halyard.core.resource.v1.StringReplaceJarResource in project halyard by spinnaker.

the class LocalDebianServiceProvider method clean.

@Override
public RemoteAction clean(DeploymentDetails details, SpinnakerRuntimeSettings runtimeSettings) {
    String uninstallArtifacts = String.join("\n", getServices().stream().filter(s -> s != null && runtimeSettings.getServiceSettings(s).getEnabled()).map(s -> ((LocalDebianService) s).uninstallArtifactCommand()).collect(Collectors.toList()));
    Map<String, Object> bindings = new HashMap<>();
    TemplatedResource resource = new StringReplaceJarResource("/debian/uninstall.sh");
    bindings.put("uninstall-artifacts", uninstallArtifacts);
    return new RemoteAction().setScript(resource.setBindings(bindings).toString()).setAutoRun(true).setScriptDescription("This script apt-get purges all spinnaker components & deletes their config");
}
Also used : DeploymentDetails(com.netflix.spinnaker.halyard.deploy.deployment.v1.DeploymentDetails) java.util(java.util) ArtifactSourcesConfig(com.netflix.spinnaker.halyard.config.config.v1.ArtifactSourcesConfig) Autowired(org.springframework.beans.factory.annotation.Autowired) ArtifactService(com.netflix.spinnaker.halyard.deploy.services.v1.ArtifactService) GenerateService(com.netflix.spinnaker.halyard.deploy.services.v1.GenerateService) SpinnakerRuntimeSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerRuntimeSettings) Collectors(java.util.stream.Collectors) Component(org.springframework.stereotype.Component) LocalServiceProvider(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.local.LocalServiceProvider) StringReplaceJarResource(com.netflix.spinnaker.halyard.core.resource.v1.StringReplaceJarResource) RemoteAction(com.netflix.spinnaker.halyard.core.RemoteAction) BillOfMaterials(com.netflix.spinnaker.halyard.core.registry.v1.BillOfMaterials) SpinnakerService(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.SpinnakerService) Strings(io.fabric8.utils.Strings) TemplatedResource(com.netflix.spinnaker.halyard.core.resource.v1.TemplatedResource) StringReplaceJarResource(com.netflix.spinnaker.halyard.core.resource.v1.StringReplaceJarResource) TemplatedResource(com.netflix.spinnaker.halyard.core.resource.v1.TemplatedResource) RemoteAction(com.netflix.spinnaker.halyard.core.RemoteAction)

Example 13 with StringReplaceJarResource

use of com.netflix.spinnaker.halyard.core.resource.v1.StringReplaceJarResource in project halyard by spinnaker.

the class NestableCommand method commandCompletor.

public String commandCompletor() {
    StringReplaceJarResource completorBody = new StringReplaceJarResource("/hal-completor-body");
    Map<String, Object> bindings = new HashMap<>();
    String body = commandCompletorCase(0);
    bindings.put("body", body);
    return completorBody.setBindings(bindings).toString();
}
Also used : StringReplaceJarResource(com.netflix.spinnaker.halyard.core.resource.v1.StringReplaceJarResource) HashMap(java.util.HashMap)

Aggregations

StringReplaceJarResource (com.netflix.spinnaker.halyard.core.resource.v1.StringReplaceJarResource)13 TemplatedResource (com.netflix.spinnaker.halyard.core.resource.v1.TemplatedResource)11 HashMap (java.util.HashMap)11 RemoteAction (com.netflix.spinnaker.halyard.core.RemoteAction)6 Collectors (java.util.stream.Collectors)5 DeploymentDetails (com.netflix.spinnaker.halyard.deploy.deployment.v1.DeploymentDetails)4 ArtifactService (com.netflix.spinnaker.halyard.deploy.services.v1.ArtifactService)4 GenerateService (com.netflix.spinnaker.halyard.deploy.services.v1.GenerateService)4 SpinnakerRuntimeSettings (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerRuntimeSettings)4 SpinnakerService (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.SpinnakerService)4 Autowired (org.springframework.beans.factory.annotation.Autowired)4 Component (org.springframework.stereotype.Component)4 ArtifactSourcesConfig (com.netflix.spinnaker.halyard.config.config.v1.ArtifactSourcesConfig)3 BillOfMaterials (com.netflix.spinnaker.halyard.core.registry.v1.BillOfMaterials)3 LocalServiceProvider (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.local.LocalServiceProvider)3 Strings (io.fabric8.utils.Strings)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Map (java.util.Map)3 java.util (java.util)2