Skip to content

Commit

Permalink
fix: hide dependency warning if the user can run kubectl kustomize
Browse files Browse the repository at this point in the history
  • Loading branch information
EduardIvanov22 committed Nov 23, 2021
1 parent 3ffff09 commit 7ff4520
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {setAlert} from '@redux/reducers/alert';
import {checkNewVersion, runHelm, runKustomize, selectFile} from '@root/electron/commands';
import {setAppRehydrating} from '@redux/reducers/main';
import autoUpdater from './auto-update';
import { indexOf } from 'lodash';

Object.assign(console, ElectronLog.functions);

Expand Down Expand Up @@ -181,6 +182,12 @@ export const createWindow = (givenPath?: string) => {
await initKubeconfig(mainStore, userHomeDir);
mainStore.dispatch(setAppRehydrating(false));
const missingDependencies = checkMissingDependencies(APP_DEPENDENCIES);
const isUserAbleToRunKubectlKustomize = !checkMissingDependencies(['kubectl kustomize']).length;

if (missingDependencies.includes('kustomize') && isUserAbleToRunKubectlKustomize) {
missingDependencies.splice(indexOf(missingDependencies, 'kustomize'), 1);

}

if (missingDependencies.length > 0) {
const alert: AlertType = {
Expand Down
7 changes: 6 additions & 1 deletion src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ export const checkMissingDependencies = (dependencies: Array<string>): Array<str
},
});
return false;
} catch (e) {
} catch (e: any) {
// If kubectl kustomize was ran and threw an exception that it could not find any kustomization file - should return false
if (e.message.includes("unable to find one of 'kustomization.yaml', 'kustomization.yml' or 'Kustomization'")) {
return false;
}

return true;
}
});
Expand Down

0 comments on commit 7ff4520

Please sign in to comment.