Просмотр исходного кода

update doks and gke calls with cluster name

Alexander Belanger 5 лет назад
Родитель
Сommit
6ea08ad2e8

+ 5 - 4
dashboard/src/main/home/Home.tsx

@@ -143,13 +143,13 @@ class Home extends Component<PropsType, StateType> {
     return callback();
   };
 
-  provisionDOKS = async (integrationId: number, region: string) => {
+  provisionDOKS = async (integrationId: number, region: string, clusterName: string) => {
     console.log("Provisioning DOKS...");
     await api.createDOKS(
       "<token>",
       {
         do_integration_id: integrationId,
-        doks_name: this.props.currentProject.name,
+        doks_name: clusterName,
         do_region: region,
       },
       {
@@ -178,17 +178,18 @@ class Home extends Component<PropsType, StateType> {
           let urlParams = new URLSearchParams(queryString);
           let tier = urlParams.get("tier");
           let region = urlParams.get("region");
+          let clusterName = urlParams.get("cluster_name")
           let infras = urlParams.getAll("infras");
           if (infras.length === 2) {
             this.provisionDOCR(tgtIntegration.id, tier, () => {
-              this.provisionDOKS(tgtIntegration.id, region);
+              this.provisionDOKS(tgtIntegration.id, region, clusterName);
             });
           } else if (infras[0] === "docr") {
             this.provisionDOCR(tgtIntegration.id, tier, () => {
               this.props.history.push("dashboard?tab=provisioner");
             });
           } else {
-            this.provisionDOKS(tgtIntegration.id, region);
+            this.provisionDOKS(tgtIntegration.id, region, clusterName);
           }
         })
         .catch(console.log);

+ 2 - 2
dashboard/src/main/home/provisioner/DOFormSection.tsx

@@ -149,9 +149,9 @@ export default class DOFormSection extends Component<PropsType, StateType> {
   };
 
   doRedirect = (projectId: number) => {
-    let { subscriptionTier, doRegion, selectedInfras } = this.state;
+    let { subscriptionTier, doRegion, selectedInfras, clusterName } = this.state;
     let redirectUrl = `/api/oauth/projects/${projectId}/digitalocean?project_id=${projectId}&provision=do`;
-    redirectUrl += `&tier=${subscriptionTier}&region=${doRegion}`;
+    redirectUrl += `&tier=${subscriptionTier}&region=${doRegion}&cluster_name=${clusterName}`;
     selectedInfras.forEach((option: { value: string; label: string }) => {
       redirectUrl += `&infras=${option.value}`;
     });

+ 1 - 2
dashboard/src/main/home/provisioner/GCPFormSection.tsx

@@ -191,12 +191,11 @@ class GCPFormSection extends Component<PropsType, StateType> {
     let { handleError } = this.props;
     let { currentProject } = this.context;
 
-    let clusterName = `${currentProject.name}-cluster`;
     api
       .createGKE(
         "<token>",
         {
-          gke_name: clusterName,
+          gke_name: this.state.clusterName,
           gcp_integration_id: id,
         },
         { project_id: currentProject.id }