Fix not using the users configured shell for sync (#6589)

* Fix not using the users configured shell for sync

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Fix issue with use of userShellSetting in ShellSessions

Signed-off-by: Sebastian Malton <sebastian@malton.name>

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton authored and GitHub committed 2022-11-17 10:15:56 -05:00
1 parent a89eb486d8
commit a91e3a7f8e
10 files changed
+56 -32

No files matched your search

@@ -3,12 +3,11 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import { homedir } from "os";
import userInfoInjectable from "../user-store/user-info.injectable";
const homeDirectoryPathInjectable = getInjectable({
id: "home-directory-path",
instantiate: () => homedir(),
causesSideEffects: true,
instantiate: (di) => di.inject(userInfoInjectable).homedir,
});
export default homeDirectoryPathInjectable;
@@ -1,13 +0,0 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import userStoreInjectable from "./user-store.injectable";
const resolvedShellInjectable = getInjectable({
id: "resolved-shell",
instantiate: (di) => di.inject(userStoreInjectable).resolvedShell,
});
export default resolvedShellInjectable;
@@ -0,0 +1,20 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import { computed } from "mobx";
import userInfoInjectable from "./user-info.injectable";
import userStoreInjectable from "./user-store.injectable";
const userShellSettingInjectable = getInjectable({
id: "user-shell-setting",
instantiate: (di) => {
const userStore = di.inject(userStoreInjectable);
const userInfo = di.inject(userInfoInjectable);
return computed(() => userStore.shell || userInfo.shell);
},
});
export default userShellSettingInjectable;
@@ -4,6 +4,12 @@
*/
import { getGlobalOverride } from "../test-utils/get-global-override";
import homeDirectoryPathInjectable from "./home-directory-path.injectable";
import userInfoInjectable from "./user-info.injectable";
export default getGlobalOverride(homeDirectoryPathInjectable, () => "/some-home-directory");
export default getGlobalOverride(userInfoInjectable, () => ({
gid: 1,
homedir: "/some-home-dir",
shell: "bash",
uid: 2,
username: "some-user-name",
}));
@@ -0,0 +1,14 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import { userInfo } from "os";
const userInfoInjectable = getInjectable({
id: "user-info",
instantiate: () => userInfo(),
causesSideEffects: true,
});
export default userInfoInjectable;
+1 -5
View File
@@ -4,7 +4,7 @@
*/
import { app } from "electron";
import { action, computed, observable, reaction, makeObservable, isObservableArray, isObservableSet, isObservableMap } from "mobx";
import { action, observable, reaction, makeObservable, isObservableArray, isObservableSet, isObservableMap } from "mobx";
import { BaseStore } from "../base-store";
import migrations from "../../migrations/user-store";
import { getOrInsertSet, toggle, toJS, object } from "../../renderer/utils";
@@ -91,10 +91,6 @@ export class UserStore extends BaseStore<UserStoreModel> /* implements UserStore
*/
@observable syncKubeconfigEntries!: StoreType<typeof DESCRIPTORS["syncKubeconfigEntries"]>;
@computed get resolvedShell(): string | undefined {
return this.shell || process.env.SHELL || process.env.PTYSHELL;
}
startMainReactions() {
// open at system start-up
reaction(() => this.openAtLogin, openAtLogin => {