From 03a735fa6a5926618b2e00c35f4d387365d3d711 Mon Sep 17 00:00:00 2001 From: Pratap2018 Date: Mon, 19 Aug 2024 16:31:13 +0530 Subject: [PATCH] update --- script.sh | 2 +- src/index.js | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/script.sh b/script.sh index 17799b3..1dd5f51 100644 --- a/script.sh +++ b/script.sh @@ -1,6 +1,6 @@ #!/bin/bash -gcloud auth login --cred-file=/data/fyre-400407-9c9f737ef3f7.json + gcloud config set project fyre-400407 diff --git a/src/index.js b/src/index.js index b15d77f..a485d47 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,10 @@ import { configDotenv } from 'dotenv'; import { getKubeconfig } from './auth.js'; +import { exec } from 'child_process' + + + + configDotenv() @@ -8,8 +13,44 @@ import k8s from '@kubernetes/client-node'; +function execute() { + try { + + exec(`gcloud auth login --cred-file=${process.env.GOOGLE_APPLICATION_CREDENTIALS}`, (err, stdout, stderr) => { + if (err) { + console.log(err); + + // node couldn't execute the command + return; + } + + // the *entire* stdout and stderr (buffered) + console.log(`stdout: ${stdout}`); + console.log(`stderr: ${stderr}`); + + }) + exec(`gcloud container clusters get-credentials hypermine-gke --region asia-south1`, (err, stdout, stderr) => { + if (err) { + console.log(err); + + // node couldn't execute the command + return; + } + + // the *entire* stdout and stderr (buffered) + console.log(`stdout: ${stdout}`); + console.log(`stderr: ${stderr}`); + + }) + } catch (e) { + console.log(e); + + } + +} + @@ -127,6 +168,7 @@ const queueName = process.env.GLOBAL_TXN_CONTROLLER_QUEUE || 'GLOBAL_TXN_CONTROL (async () => { try { + execute() console.log("Start Service"); const namespace = 'hypermine-development'