Browse Source

display A record when IP (#4108)

d-g-town 2 years ago
parent
commit
1966b2b5e8

+ 2 - 1
dashboard/src/main/home/app-dashboard/validate-apply/services-settings/tabs/CustomDomains.tsx

@@ -8,6 +8,7 @@ import { PorterAppFormData } from "lib/porter-apps";
 import { ControlledInput } from "components/porter/ControlledInput";
 import CopyToClipboard from "components/CopyToClipboard";
 import copy from "assets/copy-left.svg";
+import {stringifiedDNSRecordType} from "utils/ip";
 
 interface Props {
   index: number;
@@ -91,7 +92,7 @@ const CustomDomains: React.FC<Props> = ({
         <>
           <Spacer y={0.5} />
           <div style={{width: "550px"}}>
-            <Text color="helper">To configure a custom domain, you must add a CNAME record pointing to the following Ingress IP for your cluster: </Text>
+            <Text color="helper">To configure a custom domain, you must add {stringifiedDNSRecordType(clusterIngressIp)} pointing to the following Ingress IP for your cluster: </Text>
           </div>
           <Spacer y={0.5} />
           <IdContainer>

+ 2 - 1
dashboard/src/main/home/cluster-dashboard/dashboard/ClusterSettings.tsx

@@ -10,6 +10,7 @@ import Loading from "components/Loading";
 import CopyToClipboard from "components/CopyToClipboard";
 import { DetailedIngressError } from "shared/types";
 import { RouteComponentProps } from "react-router";
+import {stringifiedDNSRecordType} from "utils/ip";
 
 type Props = RouteComponentProps & {
   ingressIp: string;
@@ -271,7 +272,7 @@ const ClusterSettings: React.FC<Props> = (props) => {
         <div>
           <Heading>Configure Custom Domain</Heading>
           <Helper>
-            To configure custom domains for your apps, add a CNAME record
+            To configure custom domains for your apps, add {stringifiedDNSRecordType(ingressIp)} record
             pointing to the following Ingress IP:
           </Helper>
           <CopyToClipboard

+ 17 - 0
dashboard/src/utils/ip.ts

@@ -0,0 +1,17 @@
+import {z} from "zod";
+
+export const isIP = (value: string): boolean => {
+    const ip = z.string().ip();
+
+    const parsed = ip.safeParse(value);
+
+    return parsed.success;
+};
+
+export const stringifiedDNSRecordType = (value: string): string => {
+    if (isIP(value)) {
+       return "an A record"
+    } else {
+        return "a CNAME record"
+    }
+};