use of com.netflix.spinnaker.halyard.core.resource.v1.StringReplaceJarResource 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.core.resource.v1.StringReplaceJarResource in project halyard by spinnaker.
the class NestableCommand method commandCompletorCase.
private String commandCompletorCase(int depth) {
StringReplaceJarResource completorCase = new StringReplaceJarResource("/hal-completor-case");
Map<String, Object> bindings = new HashMap<>();
String flagNames = commander.getParameters().stream().map(ParameterDescription::getLongestName).reduce("", (a, b) -> a + " " + b);
String subcommandNames = subcommands.entrySet().stream().map(Map.Entry::getKey).reduce("", (a, b) -> a + " " + b);
bindings.put("subcommands", subcommandNames);
bindings.put("flags", flagNames);
bindings.put("command", getCommandName());
bindings.put("depth", depth + "");
bindings.put("next", (depth + 1) + "");
String subCases = subcommands.entrySet().stream().map(c -> c.getValue().commandCompletorCase(depth + 1)).reduce("", (a, b) -> a + b);
bindings.put("recurse", subCases.isEmpty() ? ":" : subCases);
return completorCase.setBindings(bindings).toString();
}
use of com.netflix.spinnaker.halyard.core.resource.v1.StringReplaceJarResource in project halyard by spinnaker.
the class LocalDebianService 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 upstartServiceName = getUpstartServiceName();
String ensureStopped = StringUtils.isEmpty(upstartServiceName) ? "" : String.join("\n", "set +e", String.join(" ", "service", upstartServiceName, "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 LocalGitServiceProvider method getPrepCommand.
@Override
public String getPrepCommand(DeploymentDetails deploymentDetails, List<String> prepCommands) {
String servicePrep = String.join("\n", prepCommands);
TemplatedResource resource = new StringReplaceJarResource("/git/prep.sh");
Map<String, Object> bindings = new HashMap<>();
bindings.put("prep-commands", servicePrep);
return resource.setBindings(bindings).toString();
}
use of com.netflix.spinnaker.halyard.core.resource.v1.StringReplaceJarResource in project halyard by spinnaker.
the class LocalGitService method installArtifactCommand.
default String installArtifactCommand(DeploymentDetails deploymentDetails) {
Map<String, Object> bindings = new HashMap<>();
bindings.put("scripts-dir", getScriptsDir());
bindings.put("artifact", getArtifact().getName());
TemplatedResource installResource = new StringReplaceJarResource("/git/install-component.sh");
installResource.setBindings(bindings);
return installResource.toString();
}
Aggregations