Skip to content

Commit

Permalink
Fix #339: Https should be considered default while converting tcp urls
Browse files Browse the repository at this point in the history
  • Loading branch information
rohanKanojia authored and manusa committed Aug 20, 2020
1 parent a0440eb commit a8a7bf8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Usage:
* Fix #341: JKube doesn't add ImageChange triggers in DC when merging from a deployment fragment
* Fix #326: Add default `/metrics` path for `prometheus.io/path` annotation
(Sort of [redundant](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config), this makes it explicit)
* Fix #339: Https should be considered default while converting tcp urls

### 1.0.0-rc-1 (2020-07-23)
* Fix #252: Replace Quarkus Native Base image with ubi-minimal (same as in `Dockerfile.native`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,17 @@ public class EnvUtil {

public static final String MAVEN_PROPERTY_REGEXP = "\\s*\\$\\{\\s*([^}]+)\\s*}\\s*$";

// Standard HTTPS port (IANA registered). The other 2375 with plain HTTP is used only in older
// docker installations.
public static final String DOCKER_HTTPS_PORT = "2376";
// Standard HTTP port (IANA registered). It is used only in older docker installations.
public static final String DOCKER_HTTP_PORT = "2375";

public static final String PROPERTY_COMBINE_POLICY_SUFFIX = "_combine";

private EnvUtil() {
}

// Convert docker host URL to an http URL
// Convert docker host URL to an HTTP(s) URL
public static String convertTcpToHttpUrl(String connect) {
String protocol = connect.contains(":" + DOCKER_HTTPS_PORT) ? "https:" : "http:";
String protocol = connect.contains(":" + DOCKER_HTTP_PORT) ? "http:" : "https:";
return connect.replaceFirst("^tcp:", protocol);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ public void testConvertTcpToHttpUrl() {
assertEquals("http://0.0.0.0:2375", result2);
}

@Test
public void testConvertTcpToHttpUrlShouldDefaultToHttps() {
// Given
String url = "tcp://127.0.0.1:32770";
// When
String result = EnvUtil.convertTcpToHttpUrl(url);
// Then
assertEquals("https://127.0.0.1:32770", result);
}

@Test
public void testExtractLargerVersionWhenBothNull(){
assertNull(EnvUtil.extractLargerVersion(null,null));
Expand Down

0 comments on commit a8a7bf8

Please sign in to comment.