private Optional<URL> createUrlForService(Service service) { final String scheme = (service.getMetadata() != null && service.getMetadata().getAnnotations() != null) ? service.getMetadata().getAnnotations().get("api.service.kubernetes.io/scheme") : "http"; final String path = (service.getMetadata() != null && service.getMetadata().getAnnotations() != null) ? service.getMetadata().getAnnotations().get("api.service.kubernetes.io/path") : "/"; final int port = resolvePort(service); try { if (port > 0) { return Optional.of(new URL(scheme, LOCALHOST, port, path)); } else { return Optional.of(new URL(scheme, LOCALHOST, path)); } } catch (MalformedURLException e) { throw new IllegalStateException( "Cannot resolve URL for service: [" + service.getMetadata().getName() + "] in namespace:[" + namespace + "]."); } }
private Optional<URL> createUrlForService(Service service) { final String scheme = (service.getMetadata() != null && service.getMetadata().getAnnotations() != null) ? service.getMetadata().getAnnotations().get("api.service.kubernetes.io/scheme") : "http"; final String path = (service.getMetadata() != null && service.getMetadata().getAnnotations() != null) ? service.getMetadata().getAnnotations().get("api.service.kubernetes.io/path") : "/"; final int port = resolvePort(service); try { if (port > 0) { return Optional.of(new URL(scheme, LOCALHOST, port, path)); } else { return Optional.of(new URL(scheme, LOCALHOST, path)); } } catch (MalformedURLException e) { throw new IllegalStateException( "Cannot resolve URL for service: [" + service.getMetadata().getName() + "] in namespace:[" + namespace + "]."); } }
/** * Find the path to use . * Uses java annotations first and if not found, uses kubernetes annotations on the service object. * * @param service * The target service. * @param qualifiers * The set of qualifiers. * * @return Returns the resolved path of '/' as a fallback. */ private static String getPath(Service service, Annotation... qualifiers) { for (Annotation q : qualifiers) { if (q instanceof Scheme) { return ((Scheme) q).value(); } } if (service.getMetadata() != null && service.getMetadata().getAnnotations() != null) { String s = service.getMetadata().getAnnotations().get(SERVICE_SCHEME); if (s != null && s.isEmpty()) { return s; } } return DEFAULT_PATH; }
/** * Find the scheme to use to connect to the service. * Uses java annotations first and if not found, uses kubernetes annotations on the service object. * * @param service * The target service. * @param qualifiers * The set of qualifiers. * * @return Returns the resolved scheme of 'http' as a fallback. */ private static String getScheme(Service service, Annotation... qualifiers) { for (Annotation q : qualifiers) { if (q instanceof Scheme) { return ((Scheme) q).value(); } } if (service.getMetadata() != null && service.getMetadata().getAnnotations() != null) { String s = service.getMetadata().getAnnotations().get(SERVICE_SCHEME); if (s != null && s.isEmpty()) { return s; } } return DEFAULT_SCHEME; }
/** * Find the scheme to use to connect to the service. * Uses java annotations first and if not found, uses kubernetes annotations on the service object. * * @param service * The target service. * @param qualifiers * The set of qualifiers. * * @return Returns the resolved scheme of 'http' as a fallback. */ private static String getScheme(Service service, Annotation... qualifiers) { for (Annotation q : qualifiers) { if (q instanceof Scheme) { return ((Scheme) q).value(); } } if (service.getMetadata() != null && service.getMetadata().getAnnotations() != null) { String s = service.getMetadata().getAnnotations().get(SERVICE_SCHEME); if (s != null && s.isEmpty()) { return s; } } return DEFAULT_SCHEME; }
/** * Find the path to use . * Uses java annotations first and if not found, uses kubernetes annotations on the service object. * * @param service * The target service. * @param qualifiers * The set of qualifiers. * * @return Returns the resolved path of '/' as a fallback. */ private static String getPath(Service service, Annotation... qualifiers) { for (Annotation q : qualifiers) { if (q instanceof Scheme) { return ((Scheme) q).value(); } } if (service.getMetadata() != null && service.getMetadata().getAnnotations() != null) { String s = service.getMetadata().getAnnotations().get(SERVICE_SCHEME); if (s != null && s.isEmpty()) { return s; } } return DEFAULT_PATH; }
Map<String, String> annotations = meta.getAnnotations(); if (annotations != null && !annotations.isEmpty()) { for (Map.Entry<String, String> entry : annotations.entrySet()) {