private String getName(AppDeploymentRequest request) { if (request.getDeploymentProperties() .containsKey(AppDeployer.PREFIX + ThinJarLauncher.THIN_NAME)) { return request.getDeploymentProperties() .get(AppDeployer.PREFIX + ThinJarLauncher.THIN_NAME); } return this.name; }
private String[] getProfiles(AppDeploymentRequest request) { if (request.getDeploymentProperties() .containsKey(AppDeployer.PREFIX + ThinJarLauncher.THIN_PROFILE)) { return StringUtils .commaDelimitedListToStringArray(request.getDeploymentProperties() .get(AppDeployer.PREFIX + ThinJarLauncher.THIN_PROFILE)); } return this.profiles; }
/** * Will check if {@link LocalDeployerProperties#INHERIT_LOGGING} is set by checking * deployment properties. */ private boolean shouldInheritLogging(AppDeploymentRequest request) { boolean inheritLogging = false; if (request.getDeploymentProperties().containsKey(LocalDeployerProperties.INHERIT_LOGGING)) { inheritLogging = Boolean .parseBoolean(request.getDeploymentProperties().get(LocalDeployerProperties.INHERIT_LOGGING)); } return inheritLogging; }
private String routePath(AppDeploymentRequest request) { String routePath = request.getDeploymentProperties().get(ROUTE_PATH_PROPERTY); if (StringUtils.hasText(routePath) && !routePath.startsWith("/")) { throw new IllegalArgumentException( "Cloud Foundry routes must start with \"/\". Route passed = [" + routePath + "]."); } return routePath; }
private Integer healthCheckTimeout(AppDeploymentRequest request) { String timeoutString = request.getDeploymentProperties() .getOrDefault(HEALTHCHECK_TIMEOUT_PROPERTY_KEY, this.deploymentProperties.getHealthCheckTimeout()); return Integer.parseInt(timeoutString); }
private boolean useSpringApplicationJson(AppDeploymentRequest request) { return Optional.ofNullable(request.getDeploymentProperties().get(USE_SPRING_APPLICATION_JSON_KEY)) .map(Boolean::valueOf) .orElse(this.deploymentProperties.isUseSpringApplicationJson()); }
private String getDeploymentServiceAccountName(AppDeploymentRequest request) { String deploymentServiceAccountName = request.getDeploymentProperties().get("spring.cloud.deployer.kubernetes.deploymentServiceAccountName"); if (StringUtils.isEmpty(deploymentServiceAccountName)) { deploymentServiceAccountName = properties.getDeploymentServiceAccountName(); } return deploymentServiceAccountName; }
private Double deduceCpus(AppDeploymentRequest request) { String override = request.getDeploymentProperties().get("spring.cloud.deployer.chronos.cpu"); return override != null ? Double.valueOf(override) : properties.getCpu(); }
Set<String> servicesToBind(AppDeploymentRequest request) { Set<String> services = new HashSet<>(); services.addAll(this.deploymentProperties.getServices()); services.addAll(StringUtils.commaDelimitedListToSet(request.getDeploymentProperties().get(SERVICES_PROPERTY_KEY))); return services; }
private Secret getProbeCredentialsSecret(AppDeploymentRequest request) { Secret secret = null; String probeCredentialsSecret = "spring.cloud.deployer.kubernetes.probeCredentialsSecret"; if (request.getDeploymentProperties().containsKey(probeCredentialsSecret)) { String secretName = request.getDeploymentProperties().get(probeCredentialsSecret); secret = client.secrets().withName(secretName).get(); } return secret; } }
private String deploymentId(AppDeploymentRequest request) { String prefix = Optional.ofNullable(request.getDeploymentProperties().get(GROUP_PROPERTY_KEY)) .map(group -> String.format("%s-", group)) .orElse(""); String appName = String.format("%s%s", prefix, request.getDefinition().getName()); return this.applicationNameGenerator.generateAppName(appName); }
private Map<String, String> getServiceAnnotations(AppDeploymentRequest request) { String annotationsProperty = request.getDeploymentProperties() .getOrDefault("spring.cloud.deployer.kubernetes.serviceAnnotations", ""); if (StringUtils.isEmpty(annotationsProperty)) { annotationsProperty = properties.getServiceAnnotations(); } return PropertyParserUtils.getAnnotations(annotationsProperty); }
private Map<String, String> getPodAnnotations(AppDeploymentRequest request) { String annotationsProperty = request.getDeploymentProperties() .getOrDefault("spring.cloud.deployer.kubernetes.podAnnotations", ""); if (StringUtils.isEmpty(annotationsProperty)) { annotationsProperty = properties.getPodAnnotations(); } return PropertyParserUtils.getAnnotations(annotationsProperty); }
private Map<String, String> getJobAnnotations(AppDeploymentRequest request) { String annotationsProperty = request.getDeploymentProperties() .getOrDefault("spring.cloud.deployer.kubernetes.jobAnnotations", ""); if (StringUtils.isEmpty(annotationsProperty)) { annotationsProperty = properties.getJobAnnotations(); } return PropertyParserUtils.getAnnotations(annotationsProperty); }
/** * The list represents a single command with many arguments. * * @param request AppDeploymentRequest - used to gather application overridden * container command * @return a list of strings that represents the command and any arguments for that command */ private List<String> getContainerCommand(AppDeploymentRequest request) { String containerCommand = request.getDeploymentProperties() .getOrDefault("spring.cloud.deployer.kubernetes.containerCommand", ""); return new CommandLineTokenizer(containerCommand).getArgs(); }
int memory(AppDeploymentRequest request) { String withUnit = request.getDeploymentProperties() .getOrDefault(AppDeployer.MEMORY_PROPERTY_KEY, this.deploymentProperties.getMemory()); return (int) ByteSizeUtils.parseToMebibytes(withUnit); }
private String deduceAppId(AppDeploymentRequest request) { String groupId = request.getDeploymentProperties().get(GROUP_PROPERTY_KEY); String name = request.getDefinition().getName(); if (groupId != null) { return "/" + groupId + "/" + name; } else { return "/" + name; } }
protected String createDeploymentId(AppDeploymentRequest request) { String groupId = request.getDeploymentProperties().get(AppDeployer.GROUP_PROPERTY_KEY); String deploymentId; if (groupId == null) { deploymentId = String.format("%s", request.getDefinition().getName()); } else { deploymentId = String.format("%s-%s", groupId, request.getDefinition().getName()); } // Kubernetes does not allow . in the name and does not allow uppercase in the name return deploymentId.replace('.', '-').toLowerCase(); }
protected String getStatefulSetStorageClassName(AppDeploymentRequest request) { String storageClassName = request.getDeploymentProperties().get("spring.cloud.deployer.kubernetes.statefulSet.volumeClaimTemplate.storageClassName"); if (storageClassName == null && properties.getStatefulSet() != null && properties.getStatefulSet().getVolumeClaimTemplate() != null) { storageClassName = properties.getStatefulSet().getVolumeClaimTemplate().getStorageClassName(); } return storageClassName; }
protected String getStatefulSetStorage(AppDeploymentRequest request) { String storage = request.getDeploymentProperties().get("spring.cloud.deployer.kubernetes.statefulSet.volumeClaimTemplate.storage"); if (storage == null && properties.getStatefulSet() != null && properties.getStatefulSet().getVolumeClaimTemplate() != null) { storage = properties.getStatefulSet().getVolumeClaimTemplate().getStorage(); } long storageAmount = ByteSizeUtils.parseToMebibytes(storage); return storageAmount + "Mi"; }