فهرست منبع

Merge branch 'master' of github.com:porter-dev/porter into debug-tab

Feroze Mohideen 2 سال پیش
والد
کامیت
b6ae264cfa

+ 1 - 1
api/server/handlers/environment_groups/list.go

@@ -75,7 +75,7 @@ func (c *ListEnvironmentGroupsHandler) ServeHTTP(w http.ResponseWriter, r *http.
 		return
 		return
 	}
 	}
 
 
-	allEnvGroupVersions, err := environmentgroups.ListEnvironmentGroups(ctx, agent, environmentgroups.WithNamespace(environmentgroups.Namespace_EnvironmentGroups), environmentgroups.WithoutDefaultAppEnvironmentGroups())
+	allEnvGroupVersions, err := environmentgroups.ListEnvironmentGroups(ctx, agent, environmentgroups.WithNamespace(environmentgroups.Namespace_EnvironmentGroups), environmentgroups.WithoutDefaultAppEnvironmentGroups(), environmentgroups.WithoutDefaultAddonEnvironmentGroups())
 	if err != nil {
 	if err != nil {
 		err = telemetry.Error(ctx, span, err, "unable to list all environment groups")
 		err = telemetry.Error(ctx, span, err, "unable to list all environment groups")
 		c.HandleAPIError(w, r, apierrors.NewErrPassThroughToClient(err, http.StatusInternalServerError))
 		c.HandleAPIError(w, r, apierrors.NewErrPassThroughToClient(err, http.StatusInternalServerError))

+ 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 { ControlledInput } from "components/porter/ControlledInput";
 import CopyToClipboard from "components/CopyToClipboard";
 import CopyToClipboard from "components/CopyToClipboard";
 import copy from "assets/copy-left.svg";
 import copy from "assets/copy-left.svg";
+import {stringifiedDNSRecordType} from "utils/ip";
 
 
 interface Props {
 interface Props {
   index: number;
   index: number;
@@ -91,7 +92,7 @@ const CustomDomains: React.FC<Props> = ({
         <>
         <>
           <Spacer y={0.5} />
           <Spacer y={0.5} />
           <div style={{width: "550px"}}>
           <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>
           </div>
           <Spacer y={0.5} />
           <Spacer y={0.5} />
           <IdContainer>
           <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 CopyToClipboard from "components/CopyToClipboard";
 import { DetailedIngressError } from "shared/types";
 import { DetailedIngressError } from "shared/types";
 import { RouteComponentProps } from "react-router";
 import { RouteComponentProps } from "react-router";
+import {stringifiedDNSRecordType} from "utils/ip";
 
 
 type Props = RouteComponentProps & {
 type Props = RouteComponentProps & {
   ingressIp: string;
   ingressIp: string;
@@ -271,7 +272,7 @@ const ClusterSettings: React.FC<Props> = (props) => {
         <div>
         <div>
           <Heading>Configure Custom Domain</Heading>
           <Heading>Configure Custom Domain</Heading>
           <Helper>
           <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:
             pointing to the following Ingress IP:
           </Helper>
           </Helper>
           <CopyToClipboard
           <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"
+    }
+};

+ 28 - 4
internal/kubernetes/environment_groups/list.go

@@ -23,6 +23,8 @@ const (
 	LabelKey_PorterManaged = "porter.run/managed"
 	LabelKey_PorterManaged = "porter.run/managed"
 
 
 	LabelKey_DefaultAppEnvironment = "porter.run/default-app-environment"
 	LabelKey_DefaultAppEnvironment = "porter.run/default-app-environment"
+	// LabelKey_DefaultAddonEnvironment is the label key signifying the resource is the default addon environment
+	LabelKey_DefaultAddonEnvironment = "porter.run/default-addon-environment"
 
 
 	// Namespace_EnvironmentGroups is the base namespace for storing all environment groups.
 	// Namespace_EnvironmentGroups is the base namespace for storing all environment groups.
 	// The configmaps and secrets here should be considered the source's of truth for a given version
 	// The configmaps and secrets here should be considered the source's of truth for a given version
@@ -51,10 +53,11 @@ type EnvironmentGroup struct {
 }
 }
 
 
 type environmentGroupOptions struct {
 type environmentGroupOptions struct {
-	namespace                          string
-	environmentGroupLabelName          string
-	environmentGroupLabelVersion       int
-	excludeDefaultAppEnvironmentGroups bool
+	namespace                            string
+	environmentGroupLabelName            string
+	environmentGroupLabelVersion         int
+	excludeDefaultAppEnvironmentGroups   bool
+	excludeDefaultAddonEnvironmentGroups bool
 }
 }
 
 
 // EnvironmentGroupOption is a function that modifies ListEnvironmentGroups
 // EnvironmentGroupOption is a function that modifies ListEnvironmentGroups
@@ -88,6 +91,13 @@ func WithoutDefaultAppEnvironmentGroups() EnvironmentGroupOption {
 	}
 	}
 }
 }
 
 
+// WithoutDefaultAddonEnvironmentGroups includes default addon environment groups in the list
+func WithoutDefaultAddonEnvironmentGroups() EnvironmentGroupOption {
+	return func(opts *environmentGroupOptions) {
+		opts.excludeDefaultAddonEnvironmentGroups = true
+	}
+}
+
 // listEnvironmentGroups returns all environment groups stored in the provided namespace. If none is set, it will use the namespace "porter-env-group".
 // listEnvironmentGroups returns all environment groups stored in the provided namespace. If none is set, it will use the namespace "porter-env-group".
 // This method returns all secret values, which should never be returned out of this package.  If you are trying to get the environment group values to return to the user,
 // This method returns all secret values, which should never be returned out of this package.  If you are trying to get the environment group values to return to the user,
 // use the exported ListEnvironmentGroups instead.
 // use the exported ListEnvironmentGroups instead.
@@ -152,6 +162,13 @@ func listEnvironmentGroups(ctx context.Context, a *kubernetes.Agent, listOpts ..
 			}
 			}
 		}
 		}
 
 
+		if opts.excludeDefaultAddonEnvironmentGroups {
+			value := cm.Labels[LabelKey_DefaultAddonEnvironment]
+			if value == "true" {
+				continue // do not include default addon environment groups
+			}
+		}
+
 		if _, ok := envGroupSet[cm.Name]; !ok {
 		if _, ok := envGroupSet[cm.Name]; !ok {
 			envGroupSet[cm.Name] = EnvironmentGroup{}
 			envGroupSet[cm.Name] = EnvironmentGroup{}
 		}
 		}
@@ -192,6 +209,13 @@ func listEnvironmentGroups(ctx context.Context, a *kubernetes.Agent, listOpts ..
 			}
 			}
 		}
 		}
 
 
+		if opts.excludeDefaultAddonEnvironmentGroups {
+			value, ok := secret.Labels[LabelKey_DefaultAddonEnvironment]
+			if ok && value == "true" {
+				continue // do not include default addon environment groups
+			}
+		}
+
 		if _, ok := envGroupSet[secret.Name]; !ok {
 		if _, ok := envGroupSet[secret.Name]; !ok {
 			envGroupSet[secret.Name] = EnvironmentGroup{}
 			envGroupSet[secret.Name] = EnvironmentGroup{}
 		}
 		}