From 6a7c87f2f17a59bee5a8fb4f3efc2772b6d0cc39 Mon Sep 17 00:00:00 2001 From: Moshe Immerman Date: Tue, 15 Apr 2025 15:17:55 +0000 Subject: [PATCH 01/10] feat: add connection method options for Kubeconfig, EKS, GKE, and CNRM Co-authored-by: Genie --- .../Connections/connectionTypes.tsx | 248 +++++++++++++++++- 1 file changed, 244 insertions(+), 4 deletions(-) diff --git a/src/components/Connections/connectionTypes.tsx b/src/components/Connections/connectionTypes.tsx index 5f4981b28..60087cdae 100644 --- a/src/components/Connections/connectionTypes.tsx +++ b/src/components/Connections/connectionTypes.tsx @@ -807,13 +807,253 @@ export const connectionTypes: ConnectionType[] = [ fields: [ ...commonConnectionFormFields, { - label: "Certificate", - key: "certificate", + label: "Connection Method", + key: "connectionMethod", + type: ConnectionsFieldTypes.SwitchField, + default: "kubeconfig", + switchFieldProps: { + options: [ + { + label: "Kubeconfig", + key: "kubeconfig" + }, + { + label: "Connection URL", + key: "connection" + }, + { + label: "EKS", + key: "eks" + }, + { + label: "GKE", + key: "gke" + }, + { + label: "CNRM", + key: "cnrm" + } + ] + }, + required: true + }, + // Kubeconfig option + { + label: "Kubeconfig", + key: "kubeconfig", type: ConnectionsFieldTypes.EnvVarSource, variant: variants.large, + required: false, + hint: "Source for kubeconfig" + }, + // Connection URL option + { + label: "Connection URL", + key: "connection", + type: ConnectionsFieldTypes.input, + required: false, + hint: "The connection URL to use" + }, + // EKS Connection options + { + label: "EKS Cluster Name", + key: "eksCluster", + type: ConnectionsFieldTypes.input, + required: false, + hint: "Name of the EKS cluster" + }, + { + label: "EKS Connection URL", + key: "eksConnection", + type: ConnectionsFieldTypes.input, + required: false, + hint: "The connection URL to use for EKS, mutually exclusive with access key and secret key" + }, + { + label: "EKS Access Key", + key: "eksAccessKey", + type: ConnectionsFieldTypes.EnvVarSource, + required: false + }, + { + label: "EKS Secret Key", + key: "eksSecretKey", + type: ConnectionsFieldTypes.EnvVarSource, required: false + }, + { + label: "EKS Region", + key: "eksRegion", + type: ConnectionsFieldTypes.input, + required: false, + hint: "The AWS region" + }, + { + label: "EKS Endpoint", + key: "eksEndpoint", + type: ConnectionsFieldTypes.input, + required: false, + hint: "Custom AWS Endpoint to use" + }, + { + label: "EKS Skip TLS Verify", + key: "eksSkipTLSVerify", + type: ConnectionsFieldTypes.checkbox, + hint: "Skip TLS verify when connecting to AWS" + }, + // GKE Connection options + { + label: "GKE Cluster Name", + key: "gkeCluster", + type: ConnectionsFieldTypes.input, + required: false, + hint: "Name of the GKE cluster" + }, + { + label: "GKE Project", + key: "gkeProject", + type: ConnectionsFieldTypes.input, + required: false, + hint: "Name of the GCP project" + }, + { + label: "GKE Zone", + key: "gkeZone", + type: ConnectionsFieldTypes.input, + required: false, + hint: "Name of the GCP zone" + }, + { + label: "GKE Connection URL", + key: "gkeConnection", + type: ConnectionsFieldTypes.input, + required: false, + hint: "The connection URL to use for GKE, mutually exclusive with credentials" + }, + { + label: "GKE Credentials", + key: "gkeCredentials", + type: ConnectionsFieldTypes.EnvVarSource, + variant: variants.large, + required: false, + hint: "The credentials to use for authentication" + }, + { + label: "GKE Endpoint", + key: "gkeEndpoint", + type: ConnectionsFieldTypes.input, + required: false, + hint: "Custom GCP Endpoint to use" + }, + { + label: "GKE Skip TLS Verify", + key: "gkeSkipTLSVerify", + type: ConnectionsFieldTypes.checkbox, + hint: "Skip TLS verification when connecting to GCP" + }, + // CNRM Connection options + { + label: "CNRM Cluster Resource", + key: "cnrmClusterResource", + type: ConnectionsFieldTypes.input, + required: false, + hint: "Name of the cluster resource" + }, + { + label: "CNRM Cluster Resource Namespace", + key: "cnrmClusterResourceNamespace", + type: ConnectionsFieldTypes.input, + required: false, + hint: "Namespace of the cluster resource" } - ] + ], + convertToFormSpecificValue: (data: Record) => { + return { + ...data, + connectionMethod: data?.properties?.connectionMethod || "kubeconfig", + kubeconfig: data?.properties?.kubeconfig, + connection: data?.properties?.connection, + + // EKS fields + eksCluster: data?.properties?.eksCluster, + eksConnection: data?.properties?.eksConnection, + eksAccessKey: data?.properties?.eksAccessKey, + eksSecretKey: data?.properties?.eksSecretKey, + eksRegion: data?.properties?.eksRegion, + eksEndpoint: data?.properties?.eksEndpoint, + eksSkipTLSVerify: data?.properties?.eksSkipTLSVerify === true, + + // GKE fields + gkeCluster: data?.properties?.gkeCluster, + gkeProject: data?.properties?.gkeProject, + gkeZone: data?.properties?.gkeZone, + gkeConnection: data?.properties?.gkeConnection, + gkeCredentials: data?.properties?.gkeCredentials, + gkeEndpoint: data?.properties?.gkeEndpoint, + gkeSkipTLSVerify: data?.properties?.gkeSkipTLSVerify === true, + + // CNRM fields + cnrmClusterResource: data?.properties?.cnrmClusterResource, + cnrmClusterResourceNamespace: data?.properties?.cnrmClusterResourceNamespace + } as Connection; + }, + preSubmitConverter: (data: Record) => { + const connectionMethod = data.connectionMethod || "kubeconfig"; + + const properties: Record = { + connectionMethod + }; + + if (connectionMethod === "kubeconfig" && data.kubeconfig) { + properties.kubeconfig = data.kubeconfig; + } + + if (connectionMethod === "connection" && data.connection) { + properties.connection = data.connection; + } + + if (connectionMethod === "eks") { + properties.eksCluster = data.eksCluster; + properties.eksConnection = data.eksConnection; + properties.eksAccessKey = data.eksAccessKey; + properties.eksSecretKey = data.eksSecretKey; + properties.eksRegion = data.eksRegion; + properties.eksEndpoint = data.eksEndpoint; + properties.eksSkipTLSVerify = data.eksSkipTLSVerify; + } + + if (connectionMethod === "gke") { + properties.gkeCluster = data.gkeCluster; + properties.gkeProject = data.gkeProject; + properties.gkeZone = data.gkeZone; + properties.gkeConnection = data.gkeConnection; + properties.gkeCredentials = data.gkeCredentials; + properties.gkeEndpoint = data.gkeEndpoint; + properties.gkeSkipTLSVerify = data.gkeSkipTLSVerify; + } + + if (connectionMethod === "cnrm") { + properties.cnrmClusterResource = data.cnrmClusterResource; + properties.cnrmClusterResourceNamespace = data.cnrmClusterResourceNamespace; + + // If CNRM is using GKE, include those fields + if (data.gkeCluster) { + properties.gkeCluster = data.gkeCluster; + properties.gkeProject = data.gkeProject; + properties.gkeZone = data.gkeZone; + properties.gkeConnection = data.gkeConnection; + properties.gkeCredentials = data.gkeCredentials; + properties.gkeEndpoint = data.gkeEndpoint; + properties.gkeSkipTLSVerify = data.gkeSkipTLSVerify; + } + } + + return { + name: data.name, + namespace: data.namespace, + properties + }; + } }, { title: "Azure Devops", @@ -2069,4 +2309,4 @@ export const connectionTypes: ConnectionType[] = [ .sort((v1, v2) => { return stringSortHelper(v1.title, v2.title); }) - .filter((item) => !item.hide); + .filter((item) => !item.hide); \ No newline at end of file From 8f40d9d56975545b18a5cae2cbaf04d2c891b6db Mon Sep 17 00:00:00 2001 From: Moshe Immerman Date: Tue, 15 Apr 2025 15:42:17 +0000 Subject: [PATCH 02/10] chore: remove unused connection URL option from connection types Co-authored-by: Genie --- src/components/Connections/connectionTypes.tsx | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/components/Connections/connectionTypes.tsx b/src/components/Connections/connectionTypes.tsx index 60087cdae..3bb3c03ea 100644 --- a/src/components/Connections/connectionTypes.tsx +++ b/src/components/Connections/connectionTypes.tsx @@ -817,10 +817,6 @@ export const connectionTypes: ConnectionType[] = [ label: "Kubeconfig", key: "kubeconfig" }, - { - label: "Connection URL", - key: "connection" - }, { label: "EKS", key: "eks" @@ -846,14 +842,6 @@ export const connectionTypes: ConnectionType[] = [ required: false, hint: "Source for kubeconfig" }, - // Connection URL option - { - label: "Connection URL", - key: "connection", - type: ConnectionsFieldTypes.input, - required: false, - hint: "The connection URL to use" - }, // EKS Connection options { label: "EKS Cluster Name", @@ -972,7 +960,6 @@ export const connectionTypes: ConnectionType[] = [ ...data, connectionMethod: data?.properties?.connectionMethod || "kubeconfig", kubeconfig: data?.properties?.kubeconfig, - connection: data?.properties?.connection, // EKS fields eksCluster: data?.properties?.eksCluster, @@ -1008,10 +995,6 @@ export const connectionTypes: ConnectionType[] = [ properties.kubeconfig = data.kubeconfig; } - if (connectionMethod === "connection" && data.connection) { - properties.connection = data.connection; - } - if (connectionMethod === "eks") { properties.eksCluster = data.eksCluster; properties.eksConnection = data.eksConnection; From 9000b724542074222b82681b61224d0e6f5d493f Mon Sep 17 00:00:00 2001 From: Moshe Immerman Date: Tue, 15 Apr 2025 15:49:48 +0000 Subject: [PATCH 03/10] refactor: streamline connection data handling in convertToFormSpecificValue Co-authored-by: Genie --- .../Connections/connectionTypes.tsx | 48 +++++++++++-------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/src/components/Connections/connectionTypes.tsx b/src/components/Connections/connectionTypes.tsx index 3bb3c03ea..dfe7970e6 100644 --- a/src/components/Connections/connectionTypes.tsx +++ b/src/components/Connections/connectionTypes.tsx @@ -956,33 +956,41 @@ export const connectionTypes: ConnectionType[] = [ } ], convertToFormSpecificValue: (data: Record) => { - return { + const connectionData: Connection = { ...data, - connectionMethod: data?.properties?.connectionMethod || "kubeconfig", - kubeconfig: data?.properties?.kubeconfig, + name: data.name, + type: ConnectionValueType.Kubernetes + }; + + // Custom properties + if (data?.properties) { + connectionData.connectionMethod = data.properties.connectionMethod || "kubeconfig"; + connectionData.kubeconfig = data.properties.kubeconfig; // EKS fields - eksCluster: data?.properties?.eksCluster, - eksConnection: data?.properties?.eksConnection, - eksAccessKey: data?.properties?.eksAccessKey, - eksSecretKey: data?.properties?.eksSecretKey, - eksRegion: data?.properties?.eksRegion, - eksEndpoint: data?.properties?.eksEndpoint, - eksSkipTLSVerify: data?.properties?.eksSkipTLSVerify === true, + connectionData.eksCluster = data.properties.eksCluster; + connectionData.eksConnection = data.properties.eksConnection; + connectionData.eksAccessKey = data.properties.eksAccessKey; + connectionData.eksSecretKey = data.properties.eksSecretKey; + connectionData.eksRegion = data.properties.eksRegion; + connectionData.eksEndpoint = data.properties.eksEndpoint; + connectionData.eksSkipTLSVerify = data.properties.eksSkipTLSVerify === true; // GKE fields - gkeCluster: data?.properties?.gkeCluster, - gkeProject: data?.properties?.gkeProject, - gkeZone: data?.properties?.gkeZone, - gkeConnection: data?.properties?.gkeConnection, - gkeCredentials: data?.properties?.gkeCredentials, - gkeEndpoint: data?.properties?.gkeEndpoint, - gkeSkipTLSVerify: data?.properties?.gkeSkipTLSVerify === true, + connectionData.gkeCluster = data.properties.gkeCluster; + connectionData.gkeProject = data.properties.gkeProject; + connectionData.gkeZone = data.properties.gkeZone; + connectionData.gkeConnection = data.properties.gkeConnection; + connectionData.gkeCredentials = data.properties.gkeCredentials; + connectionData.gkeEndpoint = data.properties.gkeEndpoint; + connectionData.gkeSkipTLSVerify = data.properties.gkeSkipTLSVerify === true; // CNRM fields - cnrmClusterResource: data?.properties?.cnrmClusterResource, - cnrmClusterResourceNamespace: data?.properties?.cnrmClusterResourceNamespace - } as Connection; + connectionData.cnrmClusterResource = data.properties.cnrmClusterResource; + connectionData.cnrmClusterResourceNamespace = data.properties.cnrmClusterResourceNamespace; + } + + return connectionData; }, preSubmitConverter: (data: Record) => { const connectionMethod = data.connectionMethod || "kubeconfig"; From decfbe81108febb4c9ef98d6111d719cf63a009b Mon Sep 17 00:00:00 2001 From: Moshe Immerman Date: Tue, 15 Apr 2025 15:56:54 +0000 Subject: [PATCH 04/10] refactor: simplify connection data handling in connectionTypes Co-authored-by: Genie --- .../Connections/connectionTypes.tsx | 39 ++++--------------- 1 file changed, 8 insertions(+), 31 deletions(-) diff --git a/src/components/Connections/connectionTypes.tsx b/src/components/Connections/connectionTypes.tsx index dfe7970e6..8aaef2af1 100644 --- a/src/components/Connections/connectionTypes.tsx +++ b/src/components/Connections/connectionTypes.tsx @@ -662,7 +662,7 @@ export const connectionTypes: ConnectionType[] = [ convertToFormSpecificValue: (data: Record) => { return { ...data, - port: data.properties?.port ?? 4 + port: data?.properties?.port ?? 4 } as Connection; }, preSubmitConverter: (data: Record) => { @@ -956,41 +956,18 @@ export const connectionTypes: ConnectionType[] = [ } ], convertToFormSpecificValue: (data: Record) => { - const connectionData: Connection = { + // Create a base Connection object with standard fields + const connection: Connection = { ...data, name: data.name, + namespace: data.namespace, type: ConnectionValueType.Kubernetes }; - // Custom properties - if (data?.properties) { - connectionData.connectionMethod = data.properties.connectionMethod || "kubeconfig"; - connectionData.kubeconfig = data.properties.kubeconfig; - - // EKS fields - connectionData.eksCluster = data.properties.eksCluster; - connectionData.eksConnection = data.properties.eksConnection; - connectionData.eksAccessKey = data.properties.eksAccessKey; - connectionData.eksSecretKey = data.properties.eksSecretKey; - connectionData.eksRegion = data.properties.eksRegion; - connectionData.eksEndpoint = data.properties.eksEndpoint; - connectionData.eksSkipTLSVerify = data.properties.eksSkipTLSVerify === true; - - // GKE fields - connectionData.gkeCluster = data.properties.gkeCluster; - connectionData.gkeProject = data.properties.gkeProject; - connectionData.gkeZone = data.properties.gkeZone; - connectionData.gkeConnection = data.properties.gkeConnection; - connectionData.gkeCredentials = data.properties.gkeCredentials; - connectionData.gkeEndpoint = data.properties.gkeEndpoint; - connectionData.gkeSkipTLSVerify = data.properties.gkeSkipTLSVerify === true; - - // CNRM fields - connectionData.cnrmClusterResource = data.properties.cnrmClusterResource; - connectionData.cnrmClusterResourceNamespace = data.properties.cnrmClusterResourceNamespace; - } - - return connectionData; + // Properties are already in data.properties, so no need to restructure them + // Just pass the data through as is + + return connection; }, preSubmitConverter: (data: Record) => { const connectionMethod = data.connectionMethod || "kubeconfig"; From b58a554fdcd5004343d60510ea4b2a537764ce37 Mon Sep 17 00:00:00 2001 From: Moshe Immerman Date: Tue, 15 Apr 2025 20:41:19 +0000 Subject: [PATCH 05/10] feat: add conditional fields for connection methods in connectionTypes Co-authored-by: Genie --- .../Connections/connectionTypes.tsx | 84 +++++++++++-------- 1 file changed, 51 insertions(+), 33 deletions(-) diff --git a/src/components/Connections/connectionTypes.tsx b/src/components/Connections/connectionTypes.tsx index 8aaef2af1..7ff49eb19 100644 --- a/src/components/Connections/connectionTypes.tsx +++ b/src/components/Connections/connectionTypes.tsx @@ -44,6 +44,7 @@ export type ConnectionFormFields = { key: string; fields: Omit[]; }[]; + condition?: (data: Record) => boolean; }; export const enum ConnectionValueType { @@ -840,119 +841,136 @@ export const connectionTypes: ConnectionType[] = [ type: ConnectionsFieldTypes.EnvVarSource, variant: variants.large, required: false, - hint: "Source for kubeconfig" + hint: "Source for kubeconfig", + condition: (data) => data.connectionMethod === "kubeconfig" }, // EKS Connection options { - label: "EKS Cluster Name", + label: "Cluster Name", key: "eksCluster", type: ConnectionsFieldTypes.input, required: false, - hint: "Name of the EKS cluster" + hint: "Name of the EKS cluster", + condition: (data) => data.connectionMethod === "eks" }, { - label: "EKS Connection URL", + label: "Connection URL", key: "eksConnection", type: ConnectionsFieldTypes.input, required: false, - hint: "The connection URL to use for EKS, mutually exclusive with access key and secret key" + hint: "The connection URL to use for EKS, mutually exclusive with access key and secret key", + condition: (data) => data.connectionMethod === "eks" }, { - label: "EKS Access Key", + label: "Access Key", key: "eksAccessKey", type: ConnectionsFieldTypes.EnvVarSource, - required: false + required: false, + condition: (data) => data.connectionMethod === "eks" }, { - label: "EKS Secret Key", + label: "Secret Key", key: "eksSecretKey", type: ConnectionsFieldTypes.EnvVarSource, - required: false + required: false, + condition: (data) => data.connectionMethod === "eks" }, { - label: "EKS Region", + label: "Region", key: "eksRegion", type: ConnectionsFieldTypes.input, required: false, - hint: "The AWS region" + hint: "The AWS region", + condition: (data) => data.connectionMethod === "eks" }, { - label: "EKS Endpoint", + label: "Endpoint", key: "eksEndpoint", type: ConnectionsFieldTypes.input, required: false, - hint: "Custom AWS Endpoint to use" + hint: "Custom AWS Endpoint to use", + condition: (data) => data.connectionMethod === "eks" }, { - label: "EKS Skip TLS Verify", + label: "Skip TLS Verify", key: "eksSkipTLSVerify", type: ConnectionsFieldTypes.checkbox, - hint: "Skip TLS verify when connecting to AWS" + hint: "Skip TLS verify when connecting to AWS", + condition: (data) => data.connectionMethod === "eks" }, // GKE Connection options { - label: "GKE Cluster Name", + label: "Cluster Name", key: "gkeCluster", type: ConnectionsFieldTypes.input, required: false, - hint: "Name of the GKE cluster" + hint: "Name of the GKE cluster", + condition: (data) => data.connectionMethod === "gke" }, { - label: "GKE Project", + label: "Project", key: "gkeProject", type: ConnectionsFieldTypes.input, required: false, - hint: "Name of the GCP project" + hint: "Name of the GCP project", + condition: (data) => data.connectionMethod === "gke" }, { - label: "GKE Zone", + label: "Zone", key: "gkeZone", type: ConnectionsFieldTypes.input, required: false, - hint: "Name of the GCP zone" + hint: "Name of the GCP zone", + condition: (data) => data.connectionMethod === "gke" }, { - label: "GKE Connection URL", + label: "Connection URL", key: "gkeConnection", type: ConnectionsFieldTypes.input, required: false, - hint: "The connection URL to use for GKE, mutually exclusive with credentials" + hint: "The connection URL to use for GKE, mutually exclusive with credentials", + condition: (data) => data.connectionMethod === "gke" }, { - label: "GKE Credentials", + label: "Credentials", key: "gkeCredentials", type: ConnectionsFieldTypes.EnvVarSource, variant: variants.large, required: false, - hint: "The credentials to use for authentication" + hint: "The credentials to use for authentication", + condition: (data) => data.connectionMethod === "gke" }, { - label: "GKE Endpoint", + label: "Endpoint", key: "gkeEndpoint", type: ConnectionsFieldTypes.input, required: false, - hint: "Custom GCP Endpoint to use" + hint: "Custom GCP Endpoint to use", + condition: (data) => data.connectionMethod === "gke" }, { - label: "GKE Skip TLS Verify", + label: "Skip TLS Verify", key: "gkeSkipTLSVerify", type: ConnectionsFieldTypes.checkbox, - hint: "Skip TLS verification when connecting to GCP" + hint: "Skip TLS verification when connecting to GCP", + condition: (data) => data.connectionMethod === "gke" }, // CNRM Connection options { - label: "CNRM Cluster Resource", + label: "Cluster Resource", key: "cnrmClusterResource", type: ConnectionsFieldTypes.input, required: false, - hint: "Name of the cluster resource" + hint: "Name of the cluster resource", + condition: (data) => data.connectionMethod === "cnrm" }, { - label: "CNRM Cluster Resource Namespace", + label: "Cluster Resource Namespace", key: "cnrmClusterResourceNamespace", type: ConnectionsFieldTypes.input, required: false, - hint: "Namespace of the cluster resource" + hint: "Namespace of the cluster resource", + condition: (data) => data.connectionMethod === "cnrm" } ], convertToFormSpecificValue: (data: Record) => { From f9d7ac2e8e78f617dc90acf76250ef8f774e9a3f Mon Sep 17 00:00:00 2001 From: Moshe Immerman Date: Tue, 15 Apr 2025 20:48:51 +0000 Subject: [PATCH 06/10] fix: add type annotations to connection condition functions Co-authored-by: Genie --- .../Connections/connectionTypes.tsx | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/components/Connections/connectionTypes.tsx b/src/components/Connections/connectionTypes.tsx index 7ff49eb19..5408d5087 100644 --- a/src/components/Connections/connectionTypes.tsx +++ b/src/components/Connections/connectionTypes.tsx @@ -842,7 +842,7 @@ export const connectionTypes: ConnectionType[] = [ variant: variants.large, required: false, hint: "Source for kubeconfig", - condition: (data) => data.connectionMethod === "kubeconfig" + condition: (data: Record) => data.connectionMethod === "kubeconfig" }, // EKS Connection options { @@ -851,7 +851,7 @@ export const connectionTypes: ConnectionType[] = [ type: ConnectionsFieldTypes.input, required: false, hint: "Name of the EKS cluster", - condition: (data) => data.connectionMethod === "eks" + condition: (data: Record) => data.connectionMethod === "eks" }, { label: "Connection URL", @@ -859,21 +859,21 @@ export const connectionTypes: ConnectionType[] = [ type: ConnectionsFieldTypes.input, required: false, hint: "The connection URL to use for EKS, mutually exclusive with access key and secret key", - condition: (data) => data.connectionMethod === "eks" + condition: (data: Record) => data.connectionMethod === "eks" }, { label: "Access Key", key: "eksAccessKey", type: ConnectionsFieldTypes.EnvVarSource, required: false, - condition: (data) => data.connectionMethod === "eks" + condition: (data: Record) => data.connectionMethod === "eks" }, { label: "Secret Key", key: "eksSecretKey", type: ConnectionsFieldTypes.EnvVarSource, required: false, - condition: (data) => data.connectionMethod === "eks" + condition: (data: Record) => data.connectionMethod === "eks" }, { label: "Region", @@ -881,7 +881,7 @@ export const connectionTypes: ConnectionType[] = [ type: ConnectionsFieldTypes.input, required: false, hint: "The AWS region", - condition: (data) => data.connectionMethod === "eks" + condition: (data: Record) => data.connectionMethod === "eks" }, { label: "Endpoint", @@ -889,14 +889,14 @@ export const connectionTypes: ConnectionType[] = [ type: ConnectionsFieldTypes.input, required: false, hint: "Custom AWS Endpoint to use", - condition: (data) => data.connectionMethod === "eks" + condition: (data: Record) => data.connectionMethod === "eks" }, { label: "Skip TLS Verify", key: "eksSkipTLSVerify", type: ConnectionsFieldTypes.checkbox, hint: "Skip TLS verify when connecting to AWS", - condition: (data) => data.connectionMethod === "eks" + condition: (data: Record) => data.connectionMethod === "eks" }, // GKE Connection options { @@ -905,7 +905,7 @@ export const connectionTypes: ConnectionType[] = [ type: ConnectionsFieldTypes.input, required: false, hint: "Name of the GKE cluster", - condition: (data) => data.connectionMethod === "gke" + condition: (data: Record) => data.connectionMethod === "gke" }, { label: "Project", @@ -913,7 +913,7 @@ export const connectionTypes: ConnectionType[] = [ type: ConnectionsFieldTypes.input, required: false, hint: "Name of the GCP project", - condition: (data) => data.connectionMethod === "gke" + condition: (data: Record) => data.connectionMethod === "gke" }, { label: "Zone", @@ -921,7 +921,7 @@ export const connectionTypes: ConnectionType[] = [ type: ConnectionsFieldTypes.input, required: false, hint: "Name of the GCP zone", - condition: (data) => data.connectionMethod === "gke" + condition: (data: Record) => data.connectionMethod === "gke" }, { label: "Connection URL", @@ -929,7 +929,7 @@ export const connectionTypes: ConnectionType[] = [ type: ConnectionsFieldTypes.input, required: false, hint: "The connection URL to use for GKE, mutually exclusive with credentials", - condition: (data) => data.connectionMethod === "gke" + condition: (data: Record) => data.connectionMethod === "gke" }, { label: "Credentials", @@ -938,7 +938,7 @@ export const connectionTypes: ConnectionType[] = [ variant: variants.large, required: false, hint: "The credentials to use for authentication", - condition: (data) => data.connectionMethod === "gke" + condition: (data: Record) => data.connectionMethod === "gke" }, { label: "Endpoint", @@ -946,14 +946,14 @@ export const connectionTypes: ConnectionType[] = [ type: ConnectionsFieldTypes.input, required: false, hint: "Custom GCP Endpoint to use", - condition: (data) => data.connectionMethod === "gke" + condition: (data: Record) => data.connectionMethod === "gke" }, { label: "Skip TLS Verify", key: "gkeSkipTLSVerify", type: ConnectionsFieldTypes.checkbox, hint: "Skip TLS verification when connecting to GCP", - condition: (data) => data.connectionMethod === "gke" + condition: (data: Record) => data.connectionMethod === "gke" }, // CNRM Connection options { @@ -962,7 +962,7 @@ export const connectionTypes: ConnectionType[] = [ type: ConnectionsFieldTypes.input, required: false, hint: "Name of the cluster resource", - condition: (data) => data.connectionMethod === "cnrm" + condition: (data: Record) => data.connectionMethod === "cnrm" }, { label: "Cluster Resource Namespace", @@ -970,7 +970,7 @@ export const connectionTypes: ConnectionType[] = [ type: ConnectionsFieldTypes.input, required: false, hint: "Namespace of the cluster resource", - condition: (data) => data.connectionMethod === "cnrm" + condition: (data: Record) => data.connectionMethod === "cnrm" } ], convertToFormSpecificValue: (data: Record) => { From 7002f0c2ba210de8ebf75403e21cdc243f7f21a8 Mon Sep 17 00:00:00 2001 From: Moshe Immerman Date: Wed, 16 Apr 2025 06:16:51 +0000 Subject: [PATCH 07/10] feat: add conditional rendering for connection form fields based on values Co-authored-by: Genie --- src/components/Connections/ConnectionForm.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/Connections/ConnectionForm.tsx b/src/components/Connections/ConnectionForm.tsx index d38a20bcb..14027f326 100644 --- a/src/components/Connections/ConnectionForm.tsx +++ b/src/components/Connections/ConnectionForm.tsx @@ -119,7 +119,7 @@ export function ConnectionForm({ }} onSubmit={handleSubmit} > - {() => ( + {({ values }) => (
{connectionType.fields.map((field, index) => { + // Only render the field if it doesn't have a condition or its condition returns true + if (field.condition && !field.condition(values)) { + return null; + } + return ( ); @@ -216,4 +221,4 @@ export function ConnectionForm({ ); } -export default ConnectionForm; +export default ConnectionForm; \ No newline at end of file From 518e23279a5854ff7f42124a19816c448bcb096a Mon Sep 17 00:00:00 2001 From: Moshe Immerman Date: Wed, 16 Apr 2025 06:42:15 +0000 Subject: [PATCH 08/10] feat: add ConnectionSelect field type with dynamic connection fetching Co-authored-by: Genie --- .../RenderConnectionFormFields.tsx | 45 +++- .../Connections/connectionTypes.tsx | 224 ++++++++++++++---- 2 files changed, 216 insertions(+), 53 deletions(-) diff --git a/src/components/Connections/RenderConnectionFormFields.tsx b/src/components/Connections/RenderConnectionFormFields.tsx index 3fd364a3b..4f4fa47ae 100644 --- a/src/components/Connections/RenderConnectionFormFields.tsx +++ b/src/components/Connections/RenderConnectionFormFields.tsx @@ -4,7 +4,10 @@ import { FormikEnvVarSource } from "../Forms/Formik/FormikEnvVarSource"; import FormikSwitchField from "../Forms/Formik/FormikSwitchField"; import FormikTextInput from "../Forms/Formik/FormikTextInput"; import FormikConnectionOptionsSwitchField from "./FormikConnectionOptionsSwitchField"; -import { ConnectionFormFields } from "./connectionTypes"; +import { ConnectionFormFields, ConnectionValueType } from "./connectionTypes"; +import { useFormikContext } from "formik"; +import { useQuery } from "@tanstack/react-query"; +import { getAllConnections } from "../../api/query-functions"; interface FieldViewProps { field: ConnectionFormFields; @@ -12,6 +15,22 @@ interface FieldViewProps { export default function RenderConnectionFormFields({ field }: FieldViewProps) { const type = field.type ?? "input"; + + // For ConnectionSelect type, we need to query for connections + let connections: any[] = []; + + const { data: allConnections } = useQuery(['connections'], getAllConnections, { + staleTime: 30000, + enabled: type === "ConnectionSelect" + }); + + if (allConnections && field.connectionType) { + // Filter connections by the requested connection type + connections = allConnections.filter( + (connection) => connection.type === field.connectionType + ); + } + switch (type) { case "input": return ( @@ -56,6 +75,28 @@ export default function RenderConnectionFormFields({ field }: FieldViewProps) { ); case "ConnectionSwitch": return ; + + case "ConnectionSelect": + return ( +
+ + + {field.hint &&

{field.hint}

} +
+ ); case "SwitchField": return ( @@ -91,4 +132,4 @@ export default function RenderConnectionFormFields({ field }: FieldViewProps) { default: return null; } -} +} \ No newline at end of file diff --git a/src/components/Connections/connectionTypes.tsx b/src/components/Connections/connectionTypes.tsx index 5408d5087..57a023a2d 100644 --- a/src/components/Connections/connectionTypes.tsx +++ b/src/components/Connections/connectionTypes.tsx @@ -11,7 +11,8 @@ const enum ConnectionsFieldTypes { SwitchField = "SwitchField", ConnectionSwitch = "ConnectionSwitch", Authentication = "authentication", - GroupField = "GroupField" + GroupField = "GroupField", + ConnectionSelect = "ConnectionSelect" } type Variant = "small" | "large"; @@ -45,6 +46,8 @@ export type ConnectionFormFields = { fields: Omit[]; }[]; condition?: (data: Record) => boolean; + connectionType?: ConnectionValueType; + dependsOn?: string; }; export const enum ConnectionValueType { @@ -844,7 +847,25 @@ export const connectionTypes: ConnectionType[] = [ hint: "Source for kubeconfig", condition: (data: Record) => data.connectionMethod === "kubeconfig" }, - // EKS Connection options + + // EKS Connection options - Use existing AWS connection + { + label: "Use Existing AWS Connection", + key: "eksUseExistingConnection", + type: ConnectionsFieldTypes.checkbox, + hint: "Use an existing AWS connection instead of configuring credentials directly", + condition: (data: Record) => data.connectionMethod === "eks" + }, + { + label: "AWS Connection", + key: "eksAwsConnection", + type: ConnectionsFieldTypes.ConnectionSelect, + connectionType: ConnectionValueType.AWS, + required: false, + hint: "Select an existing AWS connection to use with EKS", + condition: (data: Record) => + data.connectionMethod === "eks" && data.eksUseExistingConnection === true + }, { label: "Cluster Name", key: "eksCluster", @@ -854,34 +875,32 @@ export const connectionTypes: ConnectionType[] = [ condition: (data: Record) => data.connectionMethod === "eks" }, { - label: "Connection URL", - key: "eksConnection", + label: "Region", + key: "eksRegion", type: ConnectionsFieldTypes.input, required: false, - hint: "The connection URL to use for EKS, mutually exclusive with access key and secret key", + hint: "The AWS region", condition: (data: Record) => data.connectionMethod === "eks" }, + + // EKS Manual configuration options { label: "Access Key", key: "eksAccessKey", type: ConnectionsFieldTypes.EnvVarSource, required: false, - condition: (data: Record) => data.connectionMethod === "eks" + condition: (data: Record) => + data.connectionMethod === "eks" && + (!data.eksUseExistingConnection || data.eksUseExistingConnection === false) }, { label: "Secret Key", key: "eksSecretKey", type: ConnectionsFieldTypes.EnvVarSource, required: false, - condition: (data: Record) => data.connectionMethod === "eks" - }, - { - label: "Region", - key: "eksRegion", - type: ConnectionsFieldTypes.input, - required: false, - hint: "The AWS region", - condition: (data: Record) => data.connectionMethod === "eks" + condition: (data: Record) => + data.connectionMethod === "eks" && + (!data.eksUseExistingConnection || data.eksUseExistingConnection === false) }, { label: "Endpoint", @@ -889,16 +908,38 @@ export const connectionTypes: ConnectionType[] = [ type: ConnectionsFieldTypes.input, required: false, hint: "Custom AWS Endpoint to use", - condition: (data: Record) => data.connectionMethod === "eks" + condition: (data: Record) => + data.connectionMethod === "eks" && + (!data.eksUseExistingConnection || data.eksUseExistingConnection === false) }, { label: "Skip TLS Verify", key: "eksSkipTLSVerify", type: ConnectionsFieldTypes.checkbox, hint: "Skip TLS verify when connecting to AWS", - condition: (data: Record) => data.connectionMethod === "eks" + condition: (data: Record) => + data.connectionMethod === "eks" && + (!data.eksUseExistingConnection || data.eksUseExistingConnection === false) + }, + + // GKE Connection options - Use existing GCP connection + { + label: "Use Existing Google Cloud Connection", + key: "gkeUseExistingConnection", + type: ConnectionsFieldTypes.checkbox, + hint: "Use an existing Google Cloud connection instead of configuring credentials directly", + condition: (data: Record) => data.connectionMethod === "gke" + }, + { + label: "Google Cloud Connection", + key: "gkeGcpConnection", + type: ConnectionsFieldTypes.ConnectionSelect, + connectionType: ConnectionValueType.GCP, + required: false, + hint: "Select an existing Google Cloud connection to use with GKE", + condition: (data: Record) => + data.connectionMethod === "gke" && data.gkeUseExistingConnection === true }, - // GKE Connection options { label: "Cluster Name", key: "gkeCluster", @@ -923,14 +964,8 @@ export const connectionTypes: ConnectionType[] = [ hint: "Name of the GCP zone", condition: (data: Record) => data.connectionMethod === "gke" }, - { - label: "Connection URL", - key: "gkeConnection", - type: ConnectionsFieldTypes.input, - required: false, - hint: "The connection URL to use for GKE, mutually exclusive with credentials", - condition: (data: Record) => data.connectionMethod === "gke" - }, + + // GKE Manual configuration options { label: "Credentials", key: "gkeCredentials", @@ -938,7 +973,9 @@ export const connectionTypes: ConnectionType[] = [ variant: variants.large, required: false, hint: "The credentials to use for authentication", - condition: (data: Record) => data.connectionMethod === "gke" + condition: (data: Record) => + data.connectionMethod === "gke" && + (!data.gkeUseExistingConnection || data.gkeUseExistingConnection === false) }, { label: "Endpoint", @@ -946,15 +983,20 @@ export const connectionTypes: ConnectionType[] = [ type: ConnectionsFieldTypes.input, required: false, hint: "Custom GCP Endpoint to use", - condition: (data: Record) => data.connectionMethod === "gke" + condition: (data: Record) => + data.connectionMethod === "gke" && + (!data.gkeUseExistingConnection || data.gkeUseExistingConnection === false) }, { label: "Skip TLS Verify", key: "gkeSkipTLSVerify", type: ConnectionsFieldTypes.checkbox, hint: "Skip TLS verification when connecting to GCP", - condition: (data: Record) => data.connectionMethod === "gke" + condition: (data: Record) => + data.connectionMethod === "gke" && + (!data.gkeUseExistingConnection || data.gkeUseExistingConnection === false) }, + // CNRM Connection options { label: "Cluster Resource", @@ -982,8 +1024,87 @@ export const connectionTypes: ConnectionType[] = [ type: ConnectionValueType.Kubernetes }; - // Properties are already in data.properties, so no need to restructure them - // Just pass the data through as is + // Set the form values based on properties + if (data.properties) { + // Set connectionMethod + if (data.properties.connectionMethod) { + connection.connectionMethod = data.properties.connectionMethod; + } + + // Set kubeconfig fields + if (data.properties.kubeconfig) { + connection.kubeconfig = data.properties.kubeconfig; + } + + // Set EKS fields + if (data.properties.eksAwsConnection) { + connection.eksUseExistingConnection = true; + connection.eksAwsConnection = data.properties.eksAwsConnection; + } + + if (data.properties.eksCluster) { + connection.eksCluster = data.properties.eksCluster; + } + + if (data.properties.eksRegion) { + connection.eksRegion = data.properties.eksRegion; + } + + if (data.properties.eksAccessKey) { + connection.eksAccessKey = data.properties.eksAccessKey; + } + + if (data.properties.eksSecretKey) { + connection.eksSecretKey = data.properties.eksSecretKey; + } + + if (data.properties.eksEndpoint) { + connection.eksEndpoint = data.properties.eksEndpoint; + } + + if (data.properties.eksSkipTLSVerify) { + connection.eksSkipTLSVerify = data.properties.eksSkipTLSVerify; + } + + // Set GKE fields + if (data.properties.gkeGcpConnection) { + connection.gkeUseExistingConnection = true; + connection.gkeGcpConnection = data.properties.gkeGcpConnection; + } + + if (data.properties.gkeCluster) { + connection.gkeCluster = data.properties.gkeCluster; + } + + if (data.properties.gkeProject) { + connection.gkeProject = data.properties.gkeProject; + } + + if (data.properties.gkeZone) { + connection.gkeZone = data.properties.gkeZone; + } + + if (data.properties.gkeCredentials) { + connection.gkeCredentials = data.properties.gkeCredentials; + } + + if (data.properties.gkeEndpoint) { + connection.gkeEndpoint = data.properties.gkeEndpoint; + } + + if (data.properties.gkeSkipTLSVerify) { + connection.gkeSkipTLSVerify = data.properties.gkeSkipTLSVerify; + } + + // Set CNRM fields + if (data.properties.cnrmClusterResource) { + connection.cnrmClusterResource = data.properties.cnrmClusterResource; + } + + if (data.properties.cnrmClusterResourceNamespace) { + connection.cnrmClusterResourceNamespace = data.properties.cnrmClusterResourceNamespace; + } + } return connection; }, @@ -1000,40 +1121,41 @@ export const connectionTypes: ConnectionType[] = [ if (connectionMethod === "eks") { properties.eksCluster = data.eksCluster; - properties.eksConnection = data.eksConnection; - properties.eksAccessKey = data.eksAccessKey; - properties.eksSecretKey = data.eksSecretKey; properties.eksRegion = data.eksRegion; - properties.eksEndpoint = data.eksEndpoint; - properties.eksSkipTLSVerify = data.eksSkipTLSVerify; + + // Handle existing connection + if (data.eksUseExistingConnection === "true" && data.eksAwsConnection) { + properties.eksUseExistingConnection = true; + properties.eksAwsConnection = data.eksAwsConnection; + } else { + properties.eksAccessKey = data.eksAccessKey; + properties.eksSecretKey = data.eksSecretKey; + properties.eksEndpoint = data.eksEndpoint; + properties.eksSkipTLSVerify = data.eksSkipTLSVerify; + } } if (connectionMethod === "gke") { properties.gkeCluster = data.gkeCluster; properties.gkeProject = data.gkeProject; properties.gkeZone = data.gkeZone; - properties.gkeConnection = data.gkeConnection; - properties.gkeCredentials = data.gkeCredentials; - properties.gkeEndpoint = data.gkeEndpoint; - properties.gkeSkipTLSVerify = data.gkeSkipTLSVerify; - } - - if (connectionMethod === "cnrm") { - properties.cnrmClusterResource = data.cnrmClusterResource; - properties.cnrmClusterResourceNamespace = data.cnrmClusterResourceNamespace; - // If CNRM is using GKE, include those fields - if (data.gkeCluster) { - properties.gkeCluster = data.gkeCluster; - properties.gkeProject = data.gkeProject; - properties.gkeZone = data.gkeZone; - properties.gkeConnection = data.gkeConnection; + // Handle existing connection + if (data.gkeUseExistingConnection === "true" && data.gkeGcpConnection) { + properties.gkeUseExistingConnection = true; + properties.gkeGcpConnection = data.gkeGcpConnection; + } else { properties.gkeCredentials = data.gkeCredentials; properties.gkeEndpoint = data.gkeEndpoint; properties.gkeSkipTLSVerify = data.gkeSkipTLSVerify; } } + if (connectionMethod === "cnrm") { + properties.cnrmClusterResource = data.cnrmClusterResource; + properties.cnrmClusterResourceNamespace = data.cnrmClusterResourceNamespace; + } + return { name: data.name, namespace: data.namespace, From 9da053c88a77b07571343b2556c10dc190226f04 Mon Sep 17 00:00:00 2001 From: Moshe Immerman Date: Wed, 16 Apr 2025 06:47:42 +0000 Subject: [PATCH 09/10] feat: add ConnectionSelect component for improved connection selection in form fields Co-authored-by: Genie --- .../RenderConnectionFormFields.tsx | 86 +++++++++++-------- 1 file changed, 50 insertions(+), 36 deletions(-) diff --git a/src/components/Connections/RenderConnectionFormFields.tsx b/src/components/Connections/RenderConnectionFormFields.tsx index 4f4fa47ae..8d650b215 100644 --- a/src/components/Connections/RenderConnectionFormFields.tsx +++ b/src/components/Connections/RenderConnectionFormFields.tsx @@ -7,29 +7,62 @@ import FormikConnectionOptionsSwitchField from "./FormikConnectionOptionsSwitchF import { ConnectionFormFields, ConnectionValueType } from "./connectionTypes"; import { useFormikContext } from "formik"; import { useQuery } from "@tanstack/react-query"; -import { getAllConnections } from "../../api/query-functions"; +import { Connection } from "./ConnectionFormModal"; interface FieldViewProps { field: ConnectionFormFields; } -export default function RenderConnectionFormFields({ field }: FieldViewProps) { - const type = field.type ?? "input"; - - // For ConnectionSelect type, we need to query for connections - let connections: any[] = []; +// Connection Select component for choosing connections by type +function ConnectionSelect({ field }: { field: ConnectionFormFields }) { + const { values, setFieldValue } = useFormikContext(); - const { data: allConnections } = useQuery(['connections'], getAllConnections, { - staleTime: 30000, - enabled: type === "ConnectionSelect" - }); + // Use the connections API endpoint to fetch all connections + const { data: connections, isLoading } = useQuery( + ['connections'], + async () => { + const response = await fetch('/api/connections'); + if (!response.ok) { + throw new Error('Failed to fetch connections'); + } + return response.json(); + }, + { staleTime: 30000 } + ); - if (allConnections && field.connectionType) { - // Filter connections by the requested connection type - connections = allConnections.filter( - (connection) => connection.type === field.connectionType - ); - } + // Filter connections by the specified connection type + const filteredConnections = connections?.filter( + (connection: Connection) => connection.type === field.connectionType + ) || []; + + return ( +
+ + + {isLoading &&
Loading connections...
} + {field.hint &&

{field.hint}

} +
+ ); +} + +export default function RenderConnectionFormFields({ field }: FieldViewProps) { + const type = field.type ?? "input"; switch (type) { case "input": @@ -77,26 +110,7 @@ export default function RenderConnectionFormFields({ field }: FieldViewProps) { return ; case "ConnectionSelect": - return ( -
- - - {field.hint &&

{field.hint}

} -
- ); + return ; case "SwitchField": return ( From 5afeab999c5aa226dae10887d561dda9bb30bf7d Mon Sep 17 00:00:00 2001 From: Moshe Immerman Date: Wed, 16 Apr 2025 06:55:12 +0000 Subject: [PATCH 10/10] refactor: streamline connection properties handling in convertToFormSpecificValue Co-authored-by: Genie --- .../Connections/connectionTypes.tsx | 168 +++++++++--------- 1 file changed, 86 insertions(+), 82 deletions(-) diff --git a/src/components/Connections/connectionTypes.tsx b/src/components/Connections/connectionTypes.tsx index 57a023a2d..6d7ed760e 100644 --- a/src/components/Connections/connectionTypes.tsx +++ b/src/components/Connections/connectionTypes.tsx @@ -1016,7 +1016,7 @@ export const connectionTypes: ConnectionType[] = [ } ], convertToFormSpecificValue: (data: Record) => { - // Create a base Connection object with standard fields + // Create a base connection object with standard fields const connection: Connection = { ...data, name: data.name, @@ -1024,89 +1024,93 @@ export const connectionTypes: ConnectionType[] = [ type: ConnectionValueType.Kubernetes }; - // Set the form values based on properties - if (data.properties) { - // Set connectionMethod - if (data.properties.connectionMethod) { - connection.connectionMethod = data.properties.connectionMethod; - } - - // Set kubeconfig fields - if (data.properties.kubeconfig) { - connection.kubeconfig = data.properties.kubeconfig; - } - - // Set EKS fields - if (data.properties.eksAwsConnection) { - connection.eksUseExistingConnection = true; - connection.eksAwsConnection = data.properties.eksAwsConnection; - } - - if (data.properties.eksCluster) { - connection.eksCluster = data.properties.eksCluster; - } - - if (data.properties.eksRegion) { - connection.eksRegion = data.properties.eksRegion; - } - - if (data.properties.eksAccessKey) { - connection.eksAccessKey = data.properties.eksAccessKey; - } - - if (data.properties.eksSecretKey) { - connection.eksSecretKey = data.properties.eksSecretKey; - } - - if (data.properties.eksEndpoint) { - connection.eksEndpoint = data.properties.eksEndpoint; - } - - if (data.properties.eksSkipTLSVerify) { - connection.eksSkipTLSVerify = data.properties.eksSkipTLSVerify; - } - - // Set GKE fields - if (data.properties.gkeGcpConnection) { - connection.gkeUseExistingConnection = true; - connection.gkeGcpConnection = data.properties.gkeGcpConnection; - } - - if (data.properties.gkeCluster) { - connection.gkeCluster = data.properties.gkeCluster; - } - - if (data.properties.gkeProject) { - connection.gkeProject = data.properties.gkeProject; - } - - if (data.properties.gkeZone) { - connection.gkeZone = data.properties.gkeZone; - } - - if (data.properties.gkeCredentials) { - connection.gkeCredentials = data.properties.gkeCredentials; - } - - if (data.properties.gkeEndpoint) { - connection.gkeEndpoint = data.properties.gkeEndpoint; - } - - if (data.properties.gkeSkipTLSVerify) { - connection.gkeSkipTLSVerify = data.properties.gkeSkipTLSVerify; - } - - // Set CNRM fields - if (data.properties.cnrmClusterResource) { - connection.cnrmClusterResource = data.properties.cnrmClusterResource; - } - - if (data.properties.cnrmClusterResourceNamespace) { - connection.cnrmClusterResourceNamespace = data.properties.cnrmClusterResourceNamespace; - } + // Create a form values object to store all the Kubernetes-specific fields + const formValues: Record = {}; + + // Set connection method from properties + if (data.properties?.connectionMethod) { + formValues.connectionMethod = data.properties.connectionMethod; } - return connection; + // Handle kubeconfig + if (data.properties?.kubeconfig) { + formValues.kubeconfig = data.properties.kubeconfig; + } + + // Handle EKS configuration + if (data.properties?.eksAwsConnection) { + formValues.eksUseExistingConnection = true; + formValues.eksAwsConnection = data.properties.eksAwsConnection; + } + + if (data.properties?.eksCluster) { + formValues.eksCluster = data.properties.eksCluster; + } + + if (data.properties?.eksRegion) { + formValues.eksRegion = data.properties.eksRegion; + } + + if (data.properties?.eksAccessKey) { + formValues.eksAccessKey = data.properties.eksAccessKey; + } + + if (data.properties?.eksSecretKey) { + formValues.eksSecretKey = data.properties.eksSecretKey; + } + + if (data.properties?.eksEndpoint) { + formValues.eksEndpoint = data.properties.eksEndpoint; + } + + if (data.properties?.eksSkipTLSVerify) { + formValues.eksSkipTLSVerify = data.properties.eksSkipTLSVerify; + } + + // Handle GKE configuration + if (data.properties?.gkeGcpConnection) { + formValues.gkeUseExistingConnection = true; + formValues.gkeGcpConnection = data.properties.gkeGcpConnection; + } + + if (data.properties?.gkeCluster) { + formValues.gkeCluster = data.properties.gkeCluster; + } + + if (data.properties?.gkeProject) { + formValues.gkeProject = data.properties.gkeProject; + } + + if (data.properties?.gkeZone) { + formValues.gkeZone = data.properties.gkeZone; + } + + if (data.properties?.gkeCredentials) { + formValues.gkeCredentials = data.properties.gkeCredentials; + } + + if (data.properties?.gkeEndpoint) { + formValues.gkeEndpoint = data.properties.gkeEndpoint; + } + + if (data.properties?.gkeSkipTLSVerify) { + formValues.gkeSkipTLSVerify = data.properties.gkeSkipTLSVerify; + } + + // Handle CNRM configuration + if (data.properties?.cnrmClusterResource) { + formValues.cnrmClusterResource = data.properties.cnrmClusterResource; + } + + if (data.properties?.cnrmClusterResourceNamespace) { + formValues.cnrmClusterResourceNamespace = data.properties.cnrmClusterResourceNamespace; + } + + // Merge the form values with the connection + return { + ...connection, + ...formValues + }; }, preSubmitConverter: (data: Record) => { const connectionMethod = data.connectionMethod || "kubeconfig";