Explorar o código

update gcp response with time, fix desired state loading

Alexander Belanger %!s(int64=4) %!d(string=hai) anos
pai
achega
9a6b3364f6

+ 1 - 0
dashboard/src/components/ProvisionerStatus.tsx

@@ -16,6 +16,7 @@ export interface TFModule {
   status: string;
   created_at: string;
   global_errors?: TFResourceError[];
+  got_desired: boolean;
   // optional resources, if not created
   resources?: TFResource[];
 }

+ 14 - 2
dashboard/src/main/home/onboarding/steps/ProvisionResources/forms/SharedStatus.tsx

@@ -25,7 +25,8 @@ export const SharedStatus: React.FC<{
     index: number,
     addedResources: TFResource[],
     erroredResources: TFResource[],
-    globalErrors: TFResourceError[]
+    globalErrors: TFResourceError[],
+    gotDesired?: boolean
   ) => {
     if (!tfModules[index]?.resources) {
       tfModules[index].resources = [];
@@ -35,6 +36,10 @@ export const SharedStatus: React.FC<{
       tfModules[index].global_errors = [];
     }
 
+    if (gotDesired) {
+      tfModules[index].got_desired = true;
+    }
+
     let resources = tfModules[index].resources;
 
     // construct map of tf resources addresses to indices
@@ -53,6 +58,12 @@ export const SharedStatus: React.FC<{
       } else {
         resources.push(addedResource);
         resourceAddrMap.set(addedResource.addr, resources.length - 1);
+
+        // if the resource is being added but there's not a desired state, re-query for the
+        // desired state
+        if (!tfModules[index].got_desired) {
+          updateDesiredState(index, tfModules[index]);
+        }
       }
     }
 
@@ -240,7 +251,7 @@ export const SharedStatus: React.FC<{
       };
     });
 
-    updateTFModules(index, addedResources, [], []);
+    updateTFModules(index, addedResources, [], [], true);
   };
 
   const updateDesiredState = (index: number, val: TFModule) => {
@@ -303,6 +314,7 @@ export const SharedStatus: React.FC<{
           id: infra.id,
           kind: infra.kind,
           status: infra.status,
+          got_desired: false,
           created_at: infra.created_at,
         };
 

+ 0 - 4
internal/kubernetes/provisioner/global_stream.go

@@ -106,13 +106,9 @@ func GlobalStreamListener(
 
 		// parse messages from the global stream
 		for _, msg := range xstreams[0].Messages {
-			fmt.Println("GOT REDIS GLOBAL MSG", msg, msg.Values["id"], msg.Values["status"])
-
 			// parse the id to identify the infra
 			kind, projID, infraID, err := models.ParseUniqueName(fmt.Sprintf("%v", msg.Values["id"]))
 
-			fmt.Println("PARSED DATA IS", kind, projID, infraID, err)
-
 			if fmt.Sprintf("%v", msg.Values["status"]) == "created" {
 				infra, err := repo.Infra().ReadInfra(projID, infraID)
 

+ 1 - 0
internal/models/integrations/gcp.go

@@ -44,6 +44,7 @@ type GCPIntegration struct {
 
 func (g *GCPIntegration) ToGCPIntegrationType() *types.GCPIntegration {
 	return &types.GCPIntegration{
+		CreatedAt:    g.CreatedAt,
 		ID:           g.ID,
 		UserID:       g.UserID,
 		ProjectID:    g.ProjectID,