Skip to content

Commit

Permalink
Merge pull request #1318 from kubeshop/erdikose/feature/321
Browse files Browse the repository at this point in the history
Support multiple k8s versions
  • Loading branch information
erdkse authored Feb 21, 2022
2 parents e82cd7d + 6f7ecbe commit 76c5dd5
Show file tree
Hide file tree
Showing 33 changed files with 5,521 additions and 5,414 deletions.
3 changes: 2 additions & 1 deletion electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ import {AnyTemplate, TemplatePack} from '@models/template';
import {AnyPlugin} from '@models/plugin';
import {AnyExtension, DownloadPluginResult, DownloadTemplatePackResult, DownloadTemplateResult, UpdateExtensionsResult} from '@models/extension';
import {KustomizeCommandOptions} from '@redux/thunks/previewKustomization';
import { convertRecentFilesToRecentProjects, getSerializedProcessEnv, setProjectsRootFolder } from './utils';
import { convertRecentFilesToRecentProjects, getSerializedProcessEnv, saveInitialK8sSchema, setProjectsRootFolder } from './utils';
import {InterpolateTemplateOptions} from '@redux/services/templates';
import {StartupFlags} from '@utils/startupFlag';

Expand All @@ -83,6 +83,7 @@ const templatePacksDir = path.join(userDataDir, 'monokleTemplatePacks');
const APP_DEPENDENCIES = ['kubectl', 'helm', 'kustomize'];

setProjectsRootFolder(userHomeDir);
saveInitialK8sSchema(userDataDir);

ipcMain.on('get-user-home-dir', event => {
event.returnValue = userHomeDir;
Expand Down
20 changes: 19 additions & 1 deletion electron/utils.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import {AnyAction} from '@reduxjs/toolkit';

import {existsSync, mkdirSync, writeFileSync} from 'fs';
import _ from 'lodash';
import path from 'path';
import path, {join} from 'path';

import {PREDEFINED_K8S_VERSION} from '@constants/constants';

import {AnyExtension} from '@models/extension';

import {createProject} from '@redux/reducers/appConfig';
import {loadResource} from '@redux/services';

import electronStore from '@utils/electronStore';
import {PROCESS_ENV} from '@utils/env';
Expand Down Expand Up @@ -94,3 +98,17 @@ export const getSerializedProcessEnv = () => {
return undefined;
}
};

export const saveInitialK8sSchema = (userDataDir: string) => {
const dirName = join(String(userDataDir), path.sep, 'schemas');
const schemaPath = join(dirName, path.sep, `${PREDEFINED_K8S_VERSION}.json`);

if (!existsSync(dirName)) {
mkdirSync(dirName, {recursive: true});
}

if (!existsSync(schemaPath)) {
const data = loadResource(`schemas/${PREDEFINED_K8S_VERSION}.json`);
writeFileSync(schemaPath, String(data));
}
};
Loading

0 comments on commit 76c5dd5

Please sign in to comment.