public RemoteAction install() { RemoteAction result = new RemoteAction(); String script = "#!/bin/bash\n" + "curl -LO https://storage.googleapis.com/spinnaker-artifacts/spin/$(curl -s https://storage.googleapis.com/spinnaker-artifacts/spin/latest)/linux/amd64/spin\n" + "chmod +x spin\n" + "sudo mv spin /usr/local/bin/spin"; result.setScript(script); result.setScriptDescription("The generated script will install the latest version of spin CLI"); result.setAutoRun(true); result.commitScript(halconfigDirectoryStructure.getSpinInstallScriptPath()); return result; } }
default RemoteAction prep( S serviceProvider, D deploymentDetails, SpinnakerRuntimeSettings runtimeSettings, List<SpinnakerService.Type> serviceTypes ) { RemoteAction result = new RemoteAction(); result.setAutoRun(true); result.setScript(""); return result; }
@Override public RemoteAction connectCommand( LocalServiceProvider serviceProvider, DeploymentDetails deploymentDetails, SpinnakerRuntimeSettings runtimeSettings, List<SpinnakerService.Type> serviceTypes) { RemoteAction result = new RemoteAction(); result.setScript(String.join("\n", "#!/usr/bin/env bash", "", "echo \"Spinnaker is installed locally on this machine - no work to do.\"")); return result; }
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")); }
protected void runRemoteAction(OperationHandler<RemoteAction> operation) { RemoteAction action = operation.get(); String scriptPath = action.getScriptPath(); shouldRun = action.isAutoRun(); } else { shouldRun = action.isAutoRun() && autoRun; paragraphBuilder.addSnippet(action.getScriptDescription()); storyBuilder.addNewline(); paragraphBuilder.addSnippet(action.getScriptPath()).addStyle(AnsiStyle.UNDERLINE);
public RemoteAction prep(String deploymentName, List<String> serviceNames, List<String> excludeServiceNames) { DeploymentConfiguration deploymentConfiguration = deploymentService.getDeploymentConfiguration(deploymentName); DeploymentDetails deploymentDetails = getDeploymentDetails(deploymentConfiguration); Deployer deployer = getDeployer(deploymentConfiguration); SpinnakerServiceProvider<DeploymentDetails> serviceProvider = serviceProviderFactory.create(deploymentConfiguration); SpinnakerRuntimeSettings runtimeSettings = serviceProvider.buildRuntimeSettings(deploymentConfiguration); List<SpinnakerService.Type> serviceTypes = serviceNames.stream() .map(SpinnakerService.Type::fromCanonicalName) .collect(Collectors.toList()); if (serviceTypes.isEmpty()) { serviceTypes = serviceProvider .getServices() .stream() .map(SpinnakerService::getType) .collect(Collectors.toList()); } if (!excludeServiceNames.isEmpty()) { serviceTypes = serviceTypes .stream() .filter(serviceType -> !excludeServiceNames.contains(serviceType.getCanonicalName())) .collect(Collectors.toList()); } RemoteAction action = deployer.prep(serviceProvider, deploymentDetails, runtimeSettings, serviceTypes); if (!action.getScript().isEmpty()) { action.commitScript(halconfigDirectoryStructure.getPrepScriptPath(deploymentName)); } return action; }
@Override public RemoteAction clean(AccountDeploymentDetails<KubernetesAccount> details, SpinnakerRuntimeSettings runtimeSettings) { KubernetesSharedServiceSettings kubernetesSharedServiceSettings = new KubernetesSharedServiceSettings(details.getDeploymentConfiguration()); KubernetesV1ProviderUtils.kubectlDeleteNamespaceCommand(DaemonTaskHandler.getJobExecutor(), details, kubernetesSharedServiceSettings.getDeployLocation()); return new RemoteAction(); } }
public RemoteAction connectCommand(String deploymentName, List<String> serviceNames) { DeploymentConfiguration deploymentConfiguration = deploymentService.getDeploymentConfiguration(deploymentName); SpinnakerServiceProvider<DeploymentDetails> serviceProvider = serviceProviderFactory.create(deploymentConfiguration); SpinnakerRuntimeSettings runtimeSettings = serviceProvider.buildRuntimeSettings(deploymentConfiguration); Deployer deployer = getDeployer(deploymentConfiguration); DeploymentDetails deploymentDetails = getDeploymentDetails(deploymentConfiguration); List<SpinnakerService.Type> serviceTypes = serviceNames.stream() .map(SpinnakerService.Type::fromCanonicalName) .collect(Collectors.toList()); if (serviceTypes.isEmpty()) { serviceTypes.add(SpinnakerService.Type.DECK); serviceTypes.add(SpinnakerService.Type.GATE); } RemoteAction result = deployer.connectCommand(serviceProvider, deploymentDetails, runtimeSettings, serviceTypes); result.setAutoRun(true); result.commitScript(halconfigDirectoryStructure.getConnectScriptPath(deploymentName)); return result; }
public void clean(String deploymentName) { DeploymentConfiguration deploymentConfiguration = deploymentService.getDeploymentConfiguration(deploymentName); SpinnakerServiceProvider<DeploymentDetails> serviceProvider = serviceProviderFactory.create(deploymentConfiguration); DeploymentDetails deploymentDetails = getDeploymentDetails(deploymentConfiguration); RemoteAction action = serviceProvider.clean(deploymentDetails, serviceProvider.buildRuntimeSettings(deploymentConfiguration)); action.commitScript(halconfigDirectoryStructure.getUnInstallScriptPath(deploymentName)); }
default RemoteAction prep( S serviceProvider, D deploymentDetails, SpinnakerRuntimeSettings runtimeSettings, List<SpinnakerService.Type> serviceTypes ) { RemoteAction result = new RemoteAction(); result.setAutoRun(true); result.setScript(""); return result; } }
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")); }
protected void runRemoteAction(OperationHandler<RemoteAction> operation) { RemoteAction action = operation.get(); String scriptPath = action.getScriptPath(); shouldRun = action.isAutoRun(); } else { shouldRun = action.isAutoRun() && autoRun; paragraphBuilder.addSnippet(action.getScriptDescription()); storyBuilder.addNewline(); paragraphBuilder.addSnippet(action.getScriptPath()).addStyle(AnsiStyle.UNDERLINE);
public RemoteAction prep(String deploymentName, List<String> serviceNames, List<String> excludeServiceNames) { DeploymentConfiguration deploymentConfiguration = deploymentService.getDeploymentConfiguration(deploymentName); DeploymentDetails deploymentDetails = getDeploymentDetails(deploymentConfiguration); Deployer deployer = getDeployer(deploymentConfiguration); SpinnakerServiceProvider<DeploymentDetails> serviceProvider = serviceProviderFactory.create(deploymentConfiguration); SpinnakerRuntimeSettings runtimeSettings = serviceProvider.buildRuntimeSettings(deploymentConfiguration); List<SpinnakerService.Type> serviceTypes = serviceNames.stream() .map(SpinnakerService.Type::fromCanonicalName) .collect(Collectors.toList()); if (serviceTypes.isEmpty()) { serviceTypes = serviceProvider .getServices() .stream() .map(SpinnakerService::getType) .collect(Collectors.toList()); } if (!excludeServiceNames.isEmpty()) { serviceTypes = serviceTypes .stream() .filter(serviceType -> !excludeServiceNames.contains(serviceType.getCanonicalName())) .collect(Collectors.toList()); } RemoteAction action = deployer.prep(serviceProvider, deploymentDetails, runtimeSettings, serviceTypes); if (!action.getScript().isEmpty()) { action.commitScript(halconfigDirectoryStructure.getPrepScriptPath(deploymentName)); } return action; }
@Override public RemoteAction connectCommand( LocalServiceProvider serviceProvider, DeploymentDetails deploymentDetails, SpinnakerRuntimeSettings runtimeSettings, List<SpinnakerService.Type> serviceTypes) { RemoteAction result = new RemoteAction(); result.setScript(String.join("\n", "#!/usr/bin/env bash", "", "echo \"Spinnaker is installed locally on this machine - no work to do.\"")); return result; }
@Override public RemoteAction clean(AccountDeploymentDetails<KubernetesAccount> details, SpinnakerRuntimeSettings runtimeSettings) { KubernetesSharedServiceSettings kubernetesSharedServiceSettings = new KubernetesSharedServiceSettings(details.getDeploymentConfiguration()); KubernetesV1ProviderUtils.kubectlDeleteNamespaceCommand(DaemonTaskHandler.getJobExecutor(), details, kubernetesSharedServiceSettings.getDeployLocation()); return new RemoteAction(); } }
public RemoteAction connectCommand(String deploymentName, List<String> serviceNames) { DeploymentConfiguration deploymentConfiguration = deploymentService.getDeploymentConfiguration(deploymentName); SpinnakerServiceProvider<DeploymentDetails> serviceProvider = serviceProviderFactory.create(deploymentConfiguration); SpinnakerRuntimeSettings runtimeSettings = serviceProvider.buildRuntimeSettings(deploymentConfiguration); Deployer deployer = getDeployer(deploymentConfiguration); DeploymentDetails deploymentDetails = getDeploymentDetails(deploymentConfiguration); List<SpinnakerService.Type> serviceTypes = serviceNames.stream() .map(SpinnakerService.Type::fromCanonicalName) .collect(Collectors.toList()); if (serviceTypes.isEmpty()) { serviceTypes.add(SpinnakerService.Type.DECK); serviceTypes.add(SpinnakerService.Type.GATE); } RemoteAction result = deployer.connectCommand(serviceProvider, deploymentDetails, runtimeSettings, serviceTypes); result.setAutoRun(true); result.commitScript(halconfigDirectoryStructure.getConnectScriptPath(deploymentName)); return result; }
public void clean(String deploymentName) { DeploymentConfiguration deploymentConfiguration = deploymentService.getDeploymentConfiguration(deploymentName); SpinnakerServiceProvider<DeploymentDetails> serviceProvider = serviceProviderFactory.create(deploymentConfiguration); DeploymentDetails deploymentDetails = getDeploymentDetails(deploymentConfiguration); RemoteAction action = serviceProvider.clean(deploymentDetails, serviceProvider.buildRuntimeSettings(deploymentConfiguration)); action.commitScript(halconfigDirectoryStructure.getUnInstallScriptPath(deploymentName)); }
public RemoteAction install() { RemoteAction result = new RemoteAction(); String script = "#!/bin/bash\n" + "curl -LO https://storage.googleapis.com/spinnaker-artifacts/spin/$(curl -s https://storage.googleapis.com/spinnaker-artifacts/spin/latest)/linux/amd64/spin\n" + "chmod +x spin\n" + "sudo mv spin /usr/local/bin/spin"; result.setScript(script); result.setScriptDescription("The generated script will install the latest version of spin CLI"); result.setAutoRun(true); result.commitScript(halconfigDirectoryStructure.getSpinInstallScriptPath()); return result; } }
@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; } }
@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")); }