Kaynağa Gözat

retrieve new cluster fields from db

Justin Rhee 3 yıl önce
ebeveyn
işleme
0d4d43ea12

+ 14 - 0
api/types/cluster.go

@@ -38,6 +38,9 @@ type Cluster struct {
 
 	// Whether preview environments is enabled on this cluster
 	PreviewEnvsEnabled bool `json:"preview_envs_enabled"`
+
+	// Cluster provisioning status if managed by Porter
+	Status ClusterStatus `json:"status"`
 }
 
 type ClusterCandidate struct {
@@ -168,6 +171,17 @@ type ClusterGetResponse struct {
 	IngressError error `json:"ingress_error"`
 }
 
+// ClusterStatus to track provisioning state
+type ClusterStatus string
+
+const (
+	Ready    ClusterStatus = "READY"
+	Updating ClusterStatus = "UPDATING"
+
+	// For initial provisioning or for when the cluster is updating but not ready
+	UpdatingUnavailable ClusterStatus = "UPDATING_UNAVAILABLE"
+)
+
 type ClusterService string
 
 const (

+ 1 - 42
dashboard/src/main/home/dashboard/ClusterList.tsx

@@ -32,48 +32,6 @@ const ClusterList: React.FC<Props> = ({}) => {
         console.error(err);
         setIsLoading(false);
       });
-   /*
-    const dummyData = [
-      {
-        id: 3,
-        project_id: 2,
-        name: "dummy-cluster-one",
-        server: "https://73727E5A0EF0FD07D24D7C1FDCE041E6.gr7.us-east-1.eks.amazonaws.com",
-        service: "eks",
-        agent_integration_enabled: false,
-        infra_id: 0,
-        aws_integration_id: 5,
-        preview_envs_enabled: true,
-        status: "READY",
-      },
-      {
-        id: 4,
-        project_id: 2,
-        name: "dummy-cluster-two",
-        server: "https://73727E5A0EF0FD07D24D7C1FDCE041E6.gr7.us-east-1.eks.amazonaws.com",
-        service: "eks",
-        agent_integration_enabled: false,
-        infra_id: 0,
-        aws_integration_id: 5,
-        preview_envs_enabled: true,
-        status: "UPDATING",
-      },
-      {
-        id: 5,
-        project_id: 2,
-        name: "dummy-cluster-three",
-        server: "https://73727E5A0EF0FD07D24D7C1FDCE041E6.gr7.us-east-1.eks.amazonaws.com",
-        service: "eks",
-        agent_integration_enabled: false,
-        infra_id: 0,
-        aws_integration_id: 5,
-        preview_envs_enabled: true,
-        status: "UPDATING_UNAVAILABLE",
-      },
-    ];
-    setClusters(dummyData);
-    setIsLoading(false);
-    */
   }, [currentProject]);
 
   const renderIcon = () => {
@@ -147,6 +105,7 @@ const ClusterList: React.FC<Props> = ({}) => {
             {clusters.map((cluster: any) => {
               return (
                 <ClusterRow
+                  key={cluster.id}
                   onClick={() => {
                     setCurrentCluster(cluster);
                     pushFiltered({ location, history }, "/applications", ["project_id"], {

+ 0 - 0
docker/Untitled-1


+ 2 - 1
internal/models/cluster.go

@@ -66,7 +66,7 @@ type Cluster struct {
 	AWSClusterID string
 
 	// Status defines the current status of the cluster. Accepted values: [READY, UPDATING]
-	Status string `json:"status"`
+	Status types.ClusterStatus `json:"status"`
 
 	// ProvisionedBy is used for identifing the provisioner used for the cluster. Accepted values: [CAPI, ]
 	ProvisionedBy string `json:"provisioned_by"`
@@ -127,6 +127,7 @@ func (c *Cluster) ToClusterType() *types.Cluster {
 		AWSIntegrationID:        c.AWSIntegrationID,
 		AWSClusterID:            c.AWSClusterID,
 		PreviewEnvsEnabled:      c.PreviewEnvsEnabled,
+		Status:                  c.Status,
 	}
 }