private void setEnv(String var, String value) { if (StringUtils.isNotEmpty(value)) { setStartCommand(String.join("\n", "export " + var + "=" + value, getStartCommand())); } }
@Override public ServiceSettings buildServiceSettings(DeploymentConfiguration deploymentConfiguration) { Security security = deploymentConfiguration.getSecurity(); if (security.getUiSecurity().getSsl().isEnabled()) { setEnvTrue("DECK_HTTPS"); setEnv("DECK_CERT", security.getUiSecurity().getSsl().getSslCertificateFile()); setEnv("DECK_KEY", security.getUiSecurity().getSsl().getSslCertificateKeyFile()); setEnv("DECK_CA_CERT", security.getUiSecurity().getSsl().getSslCACertificateFile()); } if (security.getAuthn().isEnabled()) { setEnvTrue("AUTH_ENABLED"); setEnv("DECK_HOST", "0.0.0.0"); } if (security.getAuthz().isEnabled()) { setEnvTrue("FIAT_ENABLED"); } return new Settings(security.getUiSecurity()) .setArtifactId(getArtifactId(deploymentConfiguration.getName())) .setHost(security.getAuthn().isEnabled() ? "0.0.0.0" : getDefaultHost()) .setEnabled(true); }
@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")); }
@Override public List<Profile> getProfiles(DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) { List<Profile> result = new ArrayList<>(); Profile deckProfile = deckProfileFactory.getProfile(deckSettingsPath, deckPath, deploymentConfiguration, endpoints); String deploymentName = deploymentConfiguration.getName(); Path userProfilePath = halconfigDirectoryStructure.getUserProfilePath(deploymentName); Optional<Profile> settingsLocalProfile = this.customProfile( deploymentConfiguration, endpoints, Paths.get(userProfilePath.toString(), deckSettingsLocalPath), deckSettingsLocalPath); settingsLocalProfile.ifPresent(p -> deckProfile.appendContents(p.getContents())); result.add(deckProfile); return result; }
@Override public ServiceSettings buildServiceSettings(DeploymentConfiguration deploymentConfiguration) { Security security = deploymentConfiguration.getSecurity(); if (security.getUiSecurity().getSsl().isEnabled()) { setEnvTrue("DECK_HTTPS"); setEnv("DECK_CERT", security.getUiSecurity().getSsl().getSslCertificateFile()); setEnv("DECK_KEY", security.getUiSecurity().getSsl().getSslCertificateKeyFile()); setEnv("DECK_CA_CERT", security.getUiSecurity().getSsl().getSslCACertificateFile()); } if (security.getAuthn().isEnabled()) { setEnvTrue("AUTH_ENABLED"); setEnv("DECK_HOST", "0.0.0.0"); } if (security.getAuthz().isEnabled()) { setEnvTrue("FIAT_ENABLED"); } return new Settings(security.getUiSecurity()) .setArtifactId(getArtifactId(deploymentConfiguration.getName())) .setHost(security.getAuthn().isEnabled() ? "0.0.0.0" : getDefaultHost()) .setEnabled(true); }
@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")); } }
private void setEnvTrue(String var) { setStartCommand(String.join("\n", "export " + var + "=true", getStartCommand())); }
private void setEnvTrue(String var) { setStartCommand(String.join("\n", "export " + var + "=true", getStartCommand())); }
private void setEnv(String var, String value) { if (StringUtils.isNotEmpty(value)) { setStartCommand(String.join("\n", "export " + var + "=" + value, getStartCommand())); } }