private URI getHostUri(RegistryState hostState) { return UriUtilsExtended.buildDockerRegistryUri(hostState.address); }
@Test public void testBuildDockerRegistryUri() throws Exception { URI uri = UriUtilsExtended.buildDockerRegistryUri("hostname.local"); assertEquals("https://hostname.local:443", uri.toString()); uri = UriUtilsExtended.buildDockerRegistryUri("hostname.local:80"); assertEquals("https://hostname.local:80", uri.toString()); uri = UriUtilsExtended.buildDockerRegistryUri("http://hostname.local"); assertEquals("http://hostname.local:80", uri.toString()); uri = UriUtilsExtended.buildDockerRegistryUri("https://hostname.local:443"); assertEquals("https://hostname.local:443", uri.toString()); try { UriUtilsExtended.buildDockerRegistryUri("ftp://a.b.c"); fail("ftp protocol should not be supported!"); } catch (LocalizableValidationException e) { assertEquals("Unsupported scheme, must be http or https: ftp", e.getMessage()); } }
private void fetchRegistry(RequestContext context, Runnable callback) { URI registryStateUri = UriUtils.extendUriWithQuery(context.request.resourceReference, UriUtils.URI_PARAM_ODATA_EXPAND, Boolean.TRUE.toString()); Operation getRegistry = Operation.createGet(registryStateUri) .setCompletion((o, ex) -> { if (ex != null) { context.operation.fail(ex); return; } context.registryState = o.getBody(RegistryAuthState.class); // needed because the mock registries contains path if (!DeploymentProfileConfig.getInstance().isTest()) { context.registryState.address = UriUtilsExtended.buildDockerRegistryUri(context.registryState.address).toString(); } processAuthentication(context, context.registryState.authCredentials); callback.run(); }); sendRequest(getRegistry); }
String address = UriUtilsExtended.buildDockerRegistryUri(registryState.address).toString(); if (!registryLinks.containsKey(address)) { registryLinks.put(address, registryState.documentSelfLink);