public String getArtifactId(String deploymentName) { return LocalGitService.super.getArtifactId(deploymentName); }
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")); }
default String prepArtifactCommand(DeploymentDetails deploymentDetails) { Map<String, Object> bindings = new HashMap<>(); String artifactName = getArtifact().getName(); bindings.put("artifact", artifactName); bindings.put("repo", artifactName); // TODO(lwander): make configurable 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(); }
@Override public RemoteAction prep(LocalServiceProvider serviceProvider, DeploymentDetails deploymentDetails, SpinnakerRuntimeSettings runtimeSettings, List<SpinnakerService.Type> serviceTypes) { LocalGitServiceProvider localGitServiceProvider = (LocalGitServiceProvider) serviceProvider; List<LocalGitService> enabledServices = localGitServiceProvider .getLocalGitServices(serviceTypes); List<String> prepCommands = enabledServices.stream() .filter(i -> { ServiceSettings serviceSettings = runtimeSettings.getServiceSettings(i.getService()); return serviceSettings != null && !serviceSettings.getSkipLifeCycleManagement(); }) .map(s -> { s.commitWrapperScripts(); return s.prepArtifactCommand(deploymentDetails); }) .collect(Collectors.toList()); String prepCommand = localGitServiceProvider.getPrepCommand(deploymentDetails, prepCommands); RemoteAction result = new RemoteAction(); result.setAutoRun(true); result.setScript(prepCommand); return result; } }
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(); }
default String getArtifactCommit(String deploymentName) { SpinnakerArtifact artifact = getArtifact(); return getArtifactService().getArtifactCommit(deploymentName, artifact); }
default String getArtifactId(String deploymentName) { return String.join("@", getArtifact().getName(), getArtifactCommit(deploymentName)); }
default String stageProfilesCommand(DeploymentDetails details, GenerateService.ResolvedConfiguration resolvedConfiguration) { Map<String, Profile> profiles = resolvedConfiguration.getProfilesForService(getService().getType()); List<String> allCommands = new ArrayList<>(); for (Map.Entry<String, Profile> entry : profiles.entrySet()) { Profile profile = entry.getValue(); String source = profile.getStagedFile(getSpinnakerStagingPath(details.getDeploymentName())); String dest = profile.getOutputFile(); allCommands.add(String.format("mkdir -p $(dirname %s)", dest)); allCommands.add(String.format("cp -p %s %s", source, dest)); if (profile.isExecutable()) { allCommands.add(String.format("chmod +x %s", dest)); } } return Strings.join(allCommands, "\n"); } }
public List<LocalGitService> getLocalGitServices(List<SpinnakerService.Type> serviceTypes) { return getFieldsOfType(LocalGitService.class) .stream() .filter(s -> s != null && serviceTypes.contains(s.getService().getType())) .collect(Collectors.toList()); } }
default String getScriptsDir() { return Paths.get(getGitRoot(), "scripts").toString(); }
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")); }
default String prepArtifactCommand(DeploymentDetails deploymentDetails) { Map<String, Object> bindings = new HashMap<>(); String artifactName = getArtifact().getName(); bindings.put("artifact", artifactName); bindings.put("repo", artifactName); // TODO(lwander): make configurable 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(); }
@Override public RemoteAction prep(LocalServiceProvider serviceProvider, DeploymentDetails deploymentDetails, SpinnakerRuntimeSettings runtimeSettings, List<SpinnakerService.Type> serviceTypes) { LocalGitServiceProvider localGitServiceProvider = (LocalGitServiceProvider) serviceProvider; List<LocalGitService> enabledServices = localGitServiceProvider .getLocalGitServices(serviceTypes); List<String> prepCommands = enabledServices.stream() .filter(i -> { ServiceSettings serviceSettings = runtimeSettings.getServiceSettings(i.getService()); return serviceSettings != null && !serviceSettings.getSkipLifeCycleManagement(); }) .map(s -> { s.commitWrapperScripts(); return s.prepArtifactCommand(deploymentDetails); }) .collect(Collectors.toList()); String prepCommand = localGitServiceProvider.getPrepCommand(deploymentDetails, prepCommands); RemoteAction result = new RemoteAction(); result.setAutoRun(true); result.setScript(prepCommand); return result; } }
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(); }
default String getArtifactCommit(String deploymentName) { SpinnakerArtifact artifact = getArtifact(); return getArtifactService().getArtifactCommit(deploymentName, artifact); }
default String getArtifactId(String deploymentName) { return String.join("@", getArtifact().getName(), getArtifactCommit(deploymentName)); }
default String stageProfilesCommand(DeploymentDetails details, GenerateService.ResolvedConfiguration resolvedConfiguration) { Map<String, Profile> profiles = resolvedConfiguration.getProfilesForService(getService().getType()); List<String> allCommands = new ArrayList<>(); for (Map.Entry<String, Profile> entry : profiles.entrySet()) { Profile profile = entry.getValue(); String source = profile.getStagedFile(getSpinnakerStagingPath(details.getDeploymentName())); String dest = profile.getOutputFile(); allCommands.add(String.format("mkdir -p $(dirname %s)", dest)); allCommands.add(String.format("cp -p %s %s", source, dest)); if (profile.isExecutable()) { allCommands.add(String.format("chmod +x %s", dest)); } } return Strings.join(allCommands, "\n"); } }
public List<LocalGitService> getLocalGitServices(List<SpinnakerService.Type> serviceTypes) { return getFieldsOfType(LocalGitService.class) .stream() .filter(s -> s != null && serviceTypes.contains(s.getService().getType())) .collect(Collectors.toList()); } }
default String getScriptsDir() { return Paths.get(getGitRoot(), "scripts").toString(); }
public String getArtifactId(String deploymentName) { return LocalGitService.super.getArtifactId(deploymentName); }