github.com/treeverse/lakefs@v1.24.1-0.20240520134607-95648127bfb0/webui/test/e2e/credentialsFile.ts (about) 1 import fs from "fs/promises"; 2 import {RAW_CREDENTIALS_FILE_PATH} from "./consts"; 3 4 interface Credentials { 5 accessKeyId: string; 6 secretAccessKey: string; 7 } 8 9 export const getCredentials = async (): Promise<Credentials|null> => { 10 try { 11 return JSON.parse(await fs.readFile(RAW_CREDENTIALS_FILE_PATH, "utf-8")); 12 } catch (e) { 13 if (e.code === "ENOENT") { 14 return null; 15 } 16 throw e; 17 } 18 } 19 20 export const writeCredentials = async (credentials: Credentials): Promise<void> => { 21 const jsonCredentials = JSON.stringify(credentials); 22 await fs.writeFile(RAW_CREDENTIALS_FILE_PATH, jsonCredentials); 23 }