mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Don't change permissions when deleting a cluster (#3798)
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
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}`);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user