You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by GitBox <gi...@apache.org> on 2022/03/22 16:24:14 UTC

[GitHub] [flink-kubernetes-operator] morhidi commented on a change in pull request #93: [FLINK-26706] Introduce Ingress URL templating

morhidi commented on a change in pull request #93:
URL: https://github.com/apache/flink-kubernetes-operator/pull/93#discussion_r832368355



##########
File path: flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/utils/IngressUtils.java
##########
@@ -122,4 +154,27 @@ public static void setOwnerReference(HasMetadata owner, List<HasMetadata> resour
                         resource.getMetadata()
                                 .setOwnerReferences(Collections.singletonList(ownerReference)));
     }
+
+    public static URL getIngressUrl(String ingressTemplate, String name, String namespace) {
+        String template = addProtocol(ingressTemplate);
+        template = NAME_PTN.matcher(template).replaceAll(name);
+        template = NAMESPACE_PTN.matcher(template).replaceAll(namespace);
+        try {
+            return new URL(template);
+        } catch (MalformedURLException e) {
+            LOG.error(e.getMessage());
+            throw new ReconciliationException(
+                    String.format(
+                            "Unable to process the Ingress template(%s). Error: %s",
+                            ingressTemplate, e.getMessage()));
+        }
+    }
+
+    private static String addProtocol(String url) {

Review comment:
       I used the `URL` class as a parser to get the domain/path parts from the template (instead of writing our own parser) A valid URL needs the protocol though, so it's a bit of a hack:)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org