public Map<String, String> getPorts() { if (ports == null) { ports = new HashMap<>(); } if (ports.isEmpty()) { ports = findPropertiesWithPrefix(project.getProperties(), "docker.port.container."); } return ports; }
protected static void addPropertiesFileToMap(URL url, Map<String, String> answer) throws AbortException { if (url != null) { try (InputStream in = url.openStream()) { Properties properties = new Properties(); properties.load(in); Map<String, String> map = toMap(properties); answer.putAll(map); } catch (IOException e) { throw new AbortException("Failed to load properties URL: " + url + ". " + e); } } }
public static long getLongValue(Properties properties, String key, long defaultValue) { return getLong(properties, key, defaultValue); }
protected Probe buildProbe(Properties springBootProperties, Integer initialDelay, Integer period, Integer timeout) { SpringBootConfigurationHelper propertyHelper = new SpringBootConfigurationHelper(SpringBootUtil.getSpringBootVersion(getContext().getProject())); Integer managementPort = PropertiesHelper.getInteger(springBootProperties, propertyHelper.getManagementPortPropertyKey()); boolean usingManagementPort = managementPort != null; port = PropertiesHelper.getInteger(springBootProperties, propertyHelper.getServerPortPropertyKey(), DEFAULT_SERVER_PORT);
protected static void addPropertiesFileToMap(File file, Map<String, String> answer) throws AbortException { if (file != null && file.isFile() && file.exists()) { try (FileInputStream in = new FileInputStream(file)) { Properties properties = new Properties(); properties.load(in); Map<String, String> map = toMap(properties); answer.putAll(map); } catch (IOException e) { throw new AbortException("Failed to load properties file: " + file + ". " + e); } } }
/** * Returns the map of entries in the properties object which have keys starting with the given prefix, removing the prefix * from the returned map. */ public static Map<String, String> findPropertiesWithPrefix(Properties properties, String prefix) { return findPropertiesWithPrefix(properties, prefix, Functions.<String>noop()); }
public static long getLongValue(Map<String, String> map, String key, long defaultValue) { Properties properties = new Properties(); properties.putAll(map); return getLong(properties, key, defaultValue); }
protected static void addPropertiesFileToMap(File file, Map<String, String> answer) throws AbortException { if (file != null && file.isFile() && file.exists()) { try (FileInputStream in = new FileInputStream(file)) { Properties properties = new Properties(); properties.load(in); Map<String, String> map = toMap(properties); answer.putAll(map); } catch (IOException e) { throw new AbortException("Failed to load properties file: " + file + ". " + e); } } }
public Map<String, String> getEnvironmentVariables() { if (environmentVariables == null) { environmentVariables = new HashMap<>(); } if (environmentVariables.isEmpty()) { environmentVariables = new HashMap<>(); Map<String, String> lowerCaseProperties = findPropertiesWithPrefix(project.getProperties(), "docker.env."); Set<Map.Entry<String, String>> entries = lowerCaseProperties.entrySet(); for (Map.Entry<String, String> entry : entries) { String key = entry.getKey(); if (key != null) { environmentVariables.put(key.toUpperCase(), entry.getValue()); } } } if (!environmentVariables.containsKey("SERVICE")) { environmentVariables.put("SERVICE", service); } if (!environmentVariables.containsKey("SERVICE_NAME")) { environmentVariables.put("SERVICE_NAME", serviceName); } return environmentVariables; }
protected static void addPropertiesFileToMap(URL url, Map<String, String> answer) throws AbortException { if (url != null) { try (InputStream in = url.openStream()) { Properties properties = new Properties(); properties.load(in); Map<String, String> map = toMap(properties); answer.putAll(map); } catch (IOException e) { throw new AbortException("Failed to load properties URL: " + url + ". " + e); } } }
private static Map<String, String> createConfigMapAnnotations(Session session, String status) { Map<String, String> annotations = new HashMap<>(); File dir = Util.getProjectBaseDir(session); String gitUrl = Util.findGitUrl(session, dir); annotations.put(Annotations.Tests.SESSION_ID, session.getId()); annotations.put(Annotations.Tests.TEST_SESSION_STATUS, status); if (Strings.isNotBlank(gitUrl)) { annotations.put(Annotations.Builds.GIT_URL, gitUrl); } // lets see if there's a maven generated set of pom properties File pomProperties = new File(dir, "target/maven-archiver/pom.properties"); if (pomProperties.isFile()) { try { Properties properties = new Properties(); properties.load(new FileInputStream(pomProperties)); Map<String, String> map = PropertiesHelper.toMap(properties); for (Map.Entry<String, String> entry : map.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); if (Strings.isNotBlank(key) && Strings.isNotBlank(value)) { annotations.put(Annotations.Project.PREFIX + key, value); } } } catch (IOException e) { session.getLogger().warn("Failed to load " + pomProperties + " file to annotate the namespace: " + e); } } return annotations; }