|
|
@@ -56,42 +56,46 @@ export const SharedStatus: React.FC<{
|
|
|
})
|
|
|
|
|
|
var modules : TFModule[] = []
|
|
|
-
|
|
|
+
|
|
|
// query for desired and current state, and convert to tf module
|
|
|
matchedInfras.forEach((infra : any) => {
|
|
|
- api.getInfraDesired("<token>", {}, { project_id: project_id, infra_id: infra?.id }).then((resDesired) => {
|
|
|
- api.getInfraCurrent("<token>", {}, { project_id: project_id, infra_id: infra?.id }).then((resCurrent) => {
|
|
|
- var desired = resDesired.data
|
|
|
- var current = resCurrent.data
|
|
|
-
|
|
|
- // convert current state to a lookup table
|
|
|
- var currentMap : Map<string, string> = new Map()
|
|
|
-
|
|
|
- current?.resources?.forEach((val : any) => {
|
|
|
- currentMap.set(val?.type + "." + val?.name, "")
|
|
|
- })
|
|
|
-
|
|
|
- // map desired state to list of resources
|
|
|
- var resources : TFResource[] = desired?.map((val : any) => {
|
|
|
- return {
|
|
|
- addr: val?.addr,
|
|
|
- provisioned: currentMap.has(val?.addr),
|
|
|
- errored: {
|
|
|
- errored_out: val?.errored?.errored_out,
|
|
|
- error_context: val?.errored?.error_context,
|
|
|
- },
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
- var module : TFModule = {
|
|
|
- id: infra.id,
|
|
|
- kind: infra.kind,
|
|
|
- resources: resources,
|
|
|
- }
|
|
|
-
|
|
|
- modules.push(module)
|
|
|
- })
|
|
|
- })
|
|
|
+ var module : TFModule = {
|
|
|
+ id: infra.id,
|
|
|
+ kind: infra.kind,
|
|
|
+ status: infra.status,
|
|
|
+ }
|
|
|
+
|
|
|
+ if (infra?.status != "created" && infra?.status != "destroyed") {
|
|
|
+ api.getInfraDesired("<token>", {}, { project_id: project_id, infra_id: infra?.id }).then((resDesired) => {
|
|
|
+ api.getInfraCurrent("<token>", {}, { project_id: project_id, infra_id: infra?.id }).then((resCurrent) => {
|
|
|
+ var desired = resDesired.data
|
|
|
+ var current = resCurrent.data
|
|
|
+
|
|
|
+ // convert current state to a lookup table
|
|
|
+ var currentMap : Map<string, string> = new Map()
|
|
|
+
|
|
|
+ current?.resources?.forEach((val : any) => {
|
|
|
+ currentMap.set(val?.type + "." + val?.name, "")
|
|
|
+ })
|
|
|
+
|
|
|
+ // map desired state to list of resources
|
|
|
+ var resources : TFResource[] = desired?.map((val : any) => {
|
|
|
+ return {
|
|
|
+ addr: val?.addr,
|
|
|
+ provisioned: currentMap.has(val?.addr),
|
|
|
+ errored: {
|
|
|
+ errored_out: val?.errored?.errored_out,
|
|
|
+ error_context: val?.errored?.error_context,
|
|
|
+ },
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ module.resources = resources
|
|
|
+ }).catch((err) => console.log(err))
|
|
|
+ }).catch((err) => console.log(err))
|
|
|
+ }
|
|
|
+
|
|
|
+ modules.push(module)
|
|
|
});
|
|
|
|
|
|
setTFModules(modules)
|