use of com.netflix.spinnaker.halyard.core.resource.v1.StringReplaceJarResource in project halyard by spinnaker.
the class LocalDebianServiceProvider method getInstallCommand.
@Override
public String getInstallCommand(DeploymentDetails deploymentDetails, GenerateService.ResolvedConfiguration resolvedConfiguration, Map<String, String> installCommands) {
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 = getLocalServices(serviceTypes).stream().filter(i -> resolvedConfiguration.getServiceSettings(i.getService()).getEnabled()).map(i -> ((LocalDebianService) 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/install.sh");
bindings = new HashMap<>();
bindings.put("prepare-environment", "true");
bindings.put("install-redis", "true");
bindings.put("debian-repository", artifactSourcesConfig.mergeWithBomSources(artifactSources).getDebianRepository());
bindings.put("install-commands", String.join("\n", serviceInstalls));
bindings.put("service-action", "restart");
bindings.put("upstart-init", upstartInit);
return resource.setBindings(bindings).toString();
}
use of com.netflix.spinnaker.halyard.core.resource.v1.StringReplaceJarResource in project halyard by spinnaker.
the class LocalGitDeckService method commitWrapperScripts.
@Override
public void commitWrapperScripts() {
Map<String, Object> bindings = new HashMap<>();
bindings.put("git-root", getGitRoot());
bindings.put("scripts-dir", getScriptsDir());
bindings.put("artifact", getArtifact().getName());
bindings.put("start-command", getStartCommand());
TemplatedResource scriptResource = new StringReplaceJarResource("/git/deck-start.sh");
scriptResource.setBindings(bindings);
String script = scriptResource.toString();
new RemoteAction().setScript(script).commitScript(Paths.get(getScriptsDir(), getArtifact().getName() + "-start.sh"));
scriptResource = new StringReplaceJarResource("/git/stop.sh");
scriptResource.setBindings(bindings);
script = scriptResource.toString();
new RemoteAction().setScript(script).commitScript(Paths.get(getScriptsDir(), getArtifact().getName() + "-stop.sh"));
}
use of com.netflix.spinnaker.halyard.core.resource.v1.StringReplaceJarResource in project halyard by spinnaker.
the class BakeDebianService method installArtifactCommand.
default String installArtifactCommand(DeploymentDetails deploymentDetails) {
Map<String, Object> bindings = new HashMap<>();
String artifactName = getArtifact().getName();
bindings.put("artifact", artifactName);
bindings.put("version", deploymentDetails.getArtifactVersion(artifactName));
// pin as well as install at a particular version to ensure `apt-get uprade` doesn't accidentally upgrade to `nightly`
TemplatedResource pinResource = new StringReplaceJarResource("/debian/pin.sh");
TemplatedResource installResource = new StringReplaceJarResource("/debian/install-component.sh");
String ensureStopped = String.join("\n", "set +e", "service " + getUpstartServiceName() + " stop", "set -e");
pinResource.setBindings(bindings);
installResource.setBindings(bindings);
return Strings.join("\n", pinResource, installResource, ensureStopped);
}
use of com.netflix.spinnaker.halyard.core.resource.v1.StringReplaceJarResource in project halyard by spinnaker.
the class LocalGitService method prepArtifactCommand.
default String prepArtifactCommand(DeploymentDetails deploymentDetails) {
Map<String, Object> bindings = new HashMap<>();
String artifactName = getArtifact().getName();
bindings.put("artifact", artifactName);
// TODO(lwander): make configurable
bindings.put("repo", artifactName);
bindings.put("version", getArtifactCommit(deploymentDetails.getDeploymentName()));
bindings.put("git-root", getGitRoot());
DeploymentEnvironment env = deploymentDetails.getDeploymentConfiguration().getDeploymentEnvironment();
DeploymentEnvironment.GitConfig gitConfig = env.getGitConfig();
boolean update = env.getUpdateVersions();
bindings.put("update", update ? "true" : "");
bindings.put("origin", gitConfig.getOriginUser());
bindings.put("upstream", gitConfig.getUpstreamUser());
TemplatedResource prepResource = new StringReplaceJarResource("/git/prep-component.sh");
prepResource.setBindings(bindings);
return prepResource.toString();
}
use of com.netflix.spinnaker.halyard.core.resource.v1.StringReplaceJarResource in project halyard by spinnaker.
the class LocalGitService method commitWrapperScripts.
default void commitWrapperScripts() {
Map<String, Object> bindings = new HashMap<>();
bindings.put("git-root", getGitRoot());
bindings.put("scripts-dir", getScriptsDir());
bindings.put("artifact", getArtifact().getName());
bindings.put("start-command", getStartCommand());
TemplatedResource scriptResource = new StringReplaceJarResource("/git/start.sh");
scriptResource.setBindings(bindings);
String script = scriptResource.toString();
new RemoteAction().setScript(script).commitScript(Paths.get(getScriptsDir(), getArtifact().getName() + "-start.sh"));
scriptResource = new StringReplaceJarResource("/git/stop.sh");
scriptResource.setBindings(bindings);
script = scriptResource.toString();
new RemoteAction().setScript(script).commitScript(Paths.get(getScriptsDir(), getArtifact().getName() + "-stop.sh"));
}
Aggregations