Don't change permissions when deleting a cluster (#3798)

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton authored and GitHub committed 2021-09-15 12:27:48 -04:00
1 parent f68cbabbc9
commit b43086a386
3 files changed
+4 -30

No files matched your search

@@ -19,25 +19,18 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
import type { KubeConfig } from "@kubernetes/client-node";
import { dumpYaml, KubeConfig } from "@kubernetes/client-node";
import fs from "fs";
import tempy from "tempy";
import * as lockFile from "proper-lockfile";
import YAML from "json-to-pretty-yaml";
import { noop } from "../../utils";
export async function saveKubeconfig(config: KubeConfig, path: string) {
const tmpFilePath = tempy.file();
try {
const release = await lockFile.lock(path);
const contents = YAML.stringify(JSON.parse(config.exportConfig()));
const contents = dumpYaml(JSON.parse(config.exportConfig()));
await fs.promises.writeFile(tmpFilePath, contents);
await fs.promises.rename(tmpFilePath, path);
release();
await fs.promises.writeFile(path, contents);
await release();
} catch (e) {
await fs.unlink(tmpFilePath, noop);
throw new Error(`Failed to acquire lock file.\n${e}`);
}
}