TenantManager_impl_k8s_anywhere #47
@ -21,49 +21,46 @@ impl TenantManager for K8sTenantManager {
 | 
				
			|||||||
                "metadata": {
 | 
					                "metadata": {
 | 
				
			||||||
                    "labels": {
 | 
					                    "labels": {
 | 
				
			||||||
                        "harmony.nationtech.io/tenant.id": config.id,
 | 
					                        "harmony.nationtech.io/tenant.id": config.id,
 | 
				
			||||||
                        "name": config.name,
 | 
					                        "harmony.nationtech.io/tenant.name": config.name,
 | 
				
			||||||
 | 
					 | 
				
			||||||
                    },
 | 
					                    },
 | 
				
			||||||
                "name": config.name,
 | 
					                "name": config.name,
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
       todo!("Validate that when tenant already exists (by id) that name has not changed"); 
 | 
					        todo!("Validate that when tenant already exists (by id) that name has not changed");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
       let namespace: Namespace = serde_json::from_value(namespace).unwrap();
 | 
					        let namespace: Namespace = serde_json::from_value(namespace).unwrap();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        let resource_quota = json!(
 | 
				
			||||||
 | 
					         {
 | 
				
			||||||
 | 
					           "apiVersion": "v1",
 | 
				
			||||||
 | 
					           "kind": "List",
 | 
				
			||||||
 | 
					           "items": [
 | 
				
			||||||
 | 
					             {
 | 
				
			||||||
 | 
					               "apiVersion": "v1",
 | 
				
			||||||
 | 
					               "kind": "ResourceQuota",
 | 
				
			||||||
 | 
					               "metadata": {
 | 
				
			||||||
 | 
					                 "name": config.name,
 | 
				
			||||||
 | 
					                 "labels": {
 | 
				
			||||||
 | 
					                  "harmony.nationtech.io/tenant.id": config.id,
 | 
				
			||||||
 | 
					                  "harmony.nationtech.io/tenant.name": config.name,
 | 
				
			||||||
 | 
					                 },
 | 
				
			||||||
 | 
					                 "namespace": config.name,
 | 
				
			||||||
 | 
					               },
 | 
				
			||||||
 | 
					               "spec": {
 | 
				
			||||||
 | 
					                 "hard": {
 | 
				
			||||||
 | 
					                   "limits.cpu": format!("{:.0}",config.resource_limits.cpu_limit_cores),
 | 
				
			||||||
 | 
					                   "limits.memory": format!("{:.3}Gi", config.resource_limits.memory_limit_gb),
 | 
				
			||||||
 | 
					                   "requests.cpu": format!("{:.0}",config.resource_limits.cpu_request_cores),
 | 
				
			||||||
 | 
					                   "requests.memory": format!("{:.3}Gi", config.resource_limits.memory_request_gb),
 | 
				
			||||||
 | 
					                   "requests.storage": format!("{:.3}", config.resource_limits.storage_total_gb)
 | 
				
			||||||
 | 
					                 }
 | 
				
			||||||
 | 
					               }
 | 
				
			||||||
 | 
					             }
 | 
				
			||||||
 | 
					           ]
 | 
				
			||||||
 | 
					         }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
       let resource_quota = json!(
 | 
					        );
 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
              "apiVersion": "v1",
 | 
					 | 
				
			||||||
              "kind": "List",
 | 
					 | 
				
			||||||
              "items": [
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                  "apiVersion": "v1",
 | 
					 | 
				
			||||||
                  "kind": "ResourceQuota",
 | 
					 | 
				
			||||||
                  "metadata": {
 | 
					 | 
				
			||||||
                    "name": config.name
 | 
					 | 
				
			||||||
                  },
 | 
					 | 
				
			||||||
                  "spec": {
 | 
					 | 
				
			||||||
                    "hard": {
 | 
					 | 
				
			||||||
                      "cpu": config.resource_limits.cpu_limit_cores,
 | 
					 | 
				
			||||||
                      "memory": format!("{:.3}Gi", config.resource_limits.memory_limit_gb),
 | 
					 | 
				
			||||||
                    },
 | 
					 | 
				
			||||||
                    "scopeSelector": {
 | 
					 | 
				
			||||||
                      "matchExpressions": [
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                          "operator": "In",
 | 
					 | 
				
			||||||
                          "scopeName": "PriorityClass",
 | 
					 | 
				
			||||||
                          "values": ["high"]
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                      ]
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                  }
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
              ]
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
           );
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    async fn update_tenant_resource_limits(
 | 
					    async fn update_tenant_resource_limits(
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user