Search in sources :

Example 6 with TemplatedResource

use of com.netflix.spinnaker.halyard.core.resource.v1.TemplatedResource 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();
}
Also used : StringReplaceJarResource(com.netflix.spinnaker.halyard.core.resource.v1.StringReplaceJarResource) DeploymentEnvironment(com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentEnvironment) HashMap(java.util.HashMap) TemplatedResource(com.netflix.spinnaker.halyard.core.resource.v1.TemplatedResource)

Example 7 with TemplatedResource

use of com.netflix.spinnaker.halyard.core.resource.v1.TemplatedResource 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"));
}
Also used : StringReplaceJarResource(com.netflix.spinnaker.halyard.core.resource.v1.StringReplaceJarResource) HashMap(java.util.HashMap) TemplatedResource(com.netflix.spinnaker.halyard.core.resource.v1.TemplatedResource) RemoteAction(com.netflix.spinnaker.halyard.core.RemoteAction)

Example 8 with TemplatedResource

use of com.netflix.spinnaker.halyard.core.resource.v1.TemplatedResource 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();
}
Also used : DeploymentDetails(com.netflix.spinnaker.halyard.deploy.deployment.v1.DeploymentDetails) Autowired(org.springframework.beans.factory.annotation.Autowired) 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) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) Component(org.springframework.stereotype.Component) List(java.util.List) LocalServiceProvider(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.local.LocalServiceProvider) StringReplaceJarResource(com.netflix.spinnaker.halyard.core.resource.v1.StringReplaceJarResource) Map(java.util.Map) RemoteAction(com.netflix.spinnaker.halyard.core.RemoteAction) SpinnakerService(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.SpinnakerService) 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) SpinnakerService(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.SpinnakerService)

Example 9 with TemplatedResource

use of com.netflix.spinnaker.halyard.core.resource.v1.TemplatedResource 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);
}
Also used : StringReplaceJarResource(com.netflix.spinnaker.halyard.core.resource.v1.StringReplaceJarResource) HashMap(java.util.HashMap) TemplatedResource(com.netflix.spinnaker.halyard.core.resource.v1.TemplatedResource)

Example 10 with TemplatedResource

use of com.netflix.spinnaker.halyard.core.resource.v1.TemplatedResource 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();
}
Also used : StringReplaceJarResource(com.netflix.spinnaker.halyard.core.resource.v1.StringReplaceJarResource) HashMap(java.util.HashMap) TemplatedResource(com.netflix.spinnaker.halyard.core.resource.v1.TemplatedResource)

Aggregations

TemplatedResource (com.netflix.spinnaker.halyard.core.resource.v1.TemplatedResource)16 HashMap (java.util.HashMap)12 StringReplaceJarResource (com.netflix.spinnaker.halyard.core.resource.v1.StringReplaceJarResource)11 RemoteAction (com.netflix.spinnaker.halyard.core.RemoteAction)6 ArtifactService (com.netflix.spinnaker.halyard.deploy.services.v1.ArtifactService)5 GenerateService (com.netflix.spinnaker.halyard.deploy.services.v1.GenerateService)5 SpinnakerRuntimeSettings (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerRuntimeSettings)5 Collectors (java.util.stream.Collectors)5 JinjaJarResource (com.netflix.spinnaker.halyard.core.resource.v1.JinjaJarResource)4 DeploymentDetails (com.netflix.spinnaker.halyard.deploy.deployment.v1.DeploymentDetails)4 SpinnakerService (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.SpinnakerService)4 Strings (io.fabric8.utils.Strings)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 HasServiceSettings (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.HasServiceSettings)3 ServiceSettings (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings)3 KubernetesSharedServiceSettings (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.distributed.kubernetes.KubernetesSharedServiceSettings)3 LocalServiceProvider (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.local.LocalServiceProvider)3