-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Major Refactor #180
Major Refactor #180
Changes from 29 commits
dc4e101
7610db6
8f01cc6
e0de281
46de0b7
2383b00
e5b5ce3
ed32d1e
f49f088
82f5dd5
1558d04
0660889
f05d9d7
989cbe3
3427101
91f3e9b
0dd8f70
e88acf3
85a3672
08f2b40
6d5eeee
107c0e5
4a4c3e5
d4aa580
461530f
4d2afc5
cb79379
a5a0e24
a989023
eeec11a
9b599a0
772d922
1ce019b
c284b1d
fb287ea
9f8917e
78f4cef
48b0dcd
e35e98b
b4ce1e1
5553ebb
b44f47b
ab09e8a
1249eb4
a9b839c
1dfab9d
f851550
0096a9c
ddc35f2
fc9c91c
353b049
61e03cd
bceeef0
bdf96ff
7073bbb
13c52f6
955ea29
58fbdf7
c877ecd
48718a7
6cb9b25
d9e0c44
77ab59e
85aeaa6
e641fee
b392b3e
d318a82
3d89036
901e592
b27ec70
05d0133
1447dac
0c22f63
ed6b5bf
e87fb3a
7649fc6
0adc288
b7a3b2b
4f91714
8e780c2
02b6a19
37a90af
a95dfbd
78e1777
7869a06
6c2c9ce
09834eb
fa8886f
2b5ab07
f72226f
543762a
f2f0ecb
3b104f5
9180578
fff1709
61c6200
738b6f0
d79c021
9318d4b
e03f261
ca17edd
cdebefe
d5a0704
ad31f8e
7ff580f
d0ffc07
ed4776f
f270746
b9e7548
60ef912
046af97
8ac5bb6
281b48f
542cf80
0b2ba8c
fb2486c
338585e
4394cad
79f5420
725cc3f
3f56a11
4e02307
b08f8df
c0b0893
bbfe3b6
de7835e
968458f
4f8f067
b098fdd
9ec8658
f20c239
4564ee3
e70a664
0ea3670
82a4149
65519fd
2091fee
8dc51a5
02878ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ import { ProgressStore } from "../storage/ProgressStore"; | |
import * as fs from 'fs'; | ||
import { ConfigurationStore } from '../storage/ConfigurationStore'; | ||
import { InstallationArgs } from '../types/stateInterfaces'; | ||
import { FALLBACK_SCHEMA } from '../renderer/components/common/Constants'; | ||
|
||
function removeRuntimeFromPath(path: string) | ||
{ | ||
|
@@ -50,12 +51,143 @@ class Installation { | |
if(!uploadYaml.status){ | ||
return {status: false, details: `Error uploading yaml configuration: ${uploadYaml.details}`}; | ||
} | ||
return {status: true, details: "upload yaml success"}; | ||
return {status: true, details: "Successfully uploaded yaml config"}; | ||
} catch (error) { | ||
return {status: false, details: error.message}; | ||
} | ||
} | ||
|
||
parseExampleYamlFromPax = function(catPath: string, yaml: any){ | ||
const jobOutputSplit = JSON.stringify(yaml).split(`cat ${catPath}\\r\\n`) | ||
if(jobOutputSplit[1]){ | ||
const trimmedYamlSchema = jobOutputSplit[1].split(`+ echo 'Script finished.'`)[0].split(`Script finished.`); | ||
// console.log("\n\n *** trimmedYamlSchema[0]: ", trimmedYamlSchema[0].replaceAll(`\\r\\n`, `\r\n`).replaceAll(`\\"`, `"`)); | ||
return trimmedYamlSchema[0].replaceAll(`\\r\\n`, `\r\n`).replaceAll(`\\"`, `"`); | ||
} | ||
return ""; | ||
} | ||
|
||
parseSchemaFromPax = function(inputString: string, catPath: string){ | ||
const jobOutputSplit = inputString.split(`cat ${catPath}\\r\\n`) | ||
if(jobOutputSplit[1]){ | ||
const trimmedYamlSchema = jobOutputSplit[1].split(`Script finished.`)[0].split(`Script finished.`); | ||
// console.log("trimmed schema:", trimmedYamlSchema[0].replaceAll(`\\r\\n`, `\r\n`).replaceAll(`\\"`, `"`).replaceAll(`\\\\"`, `\\"`)) | ||
return trimmedYamlSchema[0].replaceAll(`\\r\\n`, `\r\n`).replaceAll(`\\"`, `"`).replaceAll(`\\\\"`, `\\"`); | ||
} | ||
return ""; | ||
} | ||
|
||
mergeYamlAndInstallationArgs = function(yamlObj: any, installationArgs: InstallationArgs){ | ||
if (installationArgs.installationDir) { | ||
yamlObj.zowe.runtimeDirectory = installationArgs.installationDir; | ||
} | ||
if (installationArgs.workspaceDir) { | ||
yamlObj.zowe.workspaceDirectory = installationArgs.workspaceDir; | ||
} | ||
if (installationArgs.logDir) { | ||
yamlObj.zowe.logDirectory = installationArgs.logDir; | ||
} | ||
if (installationArgs.extensionDir) { | ||
yamlObj.zowe.extensionDirectory = installationArgs.extensionDir; | ||
} | ||
if (installationArgs.rbacProfile) { | ||
yamlObj.zowe.rbacProfileIdentifier = installationArgs.rbacProfile; | ||
} | ||
if (installationArgs.jobName) { | ||
yamlObj.zowe.job.name = installationArgs.jobName; | ||
} | ||
if (installationArgs.jobPrefix) { | ||
yamlObj.zowe.job.prefix = installationArgs.jobPrefix; | ||
} | ||
if (installationArgs.cookieId) { | ||
yamlObj.zowe.cookieIdentifier = installationArgs.cookieId; | ||
} | ||
if (installationArgs.javaHome) { | ||
yamlObj.java.home = installationArgs.javaHome; | ||
} | ||
if (installationArgs.nodeHome) { | ||
yamlObj.node.home = installationArgs.nodeHome; | ||
} | ||
if (installationArgs.zosmfHost) { | ||
yamlObj.zOSMF.host = installationArgs.zosmfHost; | ||
} | ||
if (installationArgs.zosmfPort) { | ||
yamlObj.zOSMF.port = installationArgs.zosmfPort; | ||
} | ||
if (installationArgs.zosmfApplId) { | ||
yamlObj.zOSMF.applId = installationArgs.zosmfApplId; | ||
} | ||
} | ||
|
||
public async smpeGetExampleYamlAndSchemas ( | ||
connectionArgs: IIpcConnectionArgs, | ||
installationArgs: InstallationArgs, | ||
): Promise<IResponse> { | ||
try{ | ||
const currentConfig: any = ConfigurationStore.getConfig(); | ||
let yamlObj | ||
const zoweRuntimePath = installationArgs.installationDir; | ||
let readPaxYamlAndSchema = await this.readExampleYamlAndSchema(connectionArgs, zoweRuntimePath); | ||
let parsedSchema = false, parsedYaml = false; | ||
if(readPaxYamlAndSchema.details.yaml){ | ||
const yamlFromPax = this.parseExampleYamlFromPax(`${zoweRuntimePath}/example-zowe.yaml`, readPaxYamlAndSchema.details.yaml); | ||
if(yamlFromPax){ | ||
try { | ||
yamlObj = parse(yamlFromPax); | ||
if (currentConfig) { | ||
// console.log("currentConfig: ", JSON.stringify(currentConfig)); | ||
yamlObj = Object.assign({}, currentConfig, yamlObj); | ||
} | ||
this.mergeYamlAndInstallationArgs(yamlObj, installationArgs); | ||
// console.log('Setting merged yaml:', JSON.stringify(yamlObj)); | ||
ConfigurationStore.setConfig(yamlObj); | ||
ProgressStore.set('downloadUnpax.getExampleYaml', true); | ||
parsedYaml = true; | ||
} catch(e) { | ||
console.log('error parsing example-zowe.yaml:', e); | ||
ProgressStore.set('downloadUnpax.getExampleYaml', false); | ||
return {status: false, details: {message: e.message}} | ||
} | ||
} else { | ||
console.log("no yaml found from pax"); | ||
ProgressStore.set('downloadUnpax.getExampleYaml', false); | ||
return {status: false, details: {message: "no yaml found from pax"}} | ||
} | ||
|
||
//No reason not to always set schema to latest if user is re-running installation | ||
if(readPaxYamlAndSchema.details.yamlSchema && readPaxYamlAndSchema.details.serverCommon){ | ||
try { | ||
let yamlSchema = JSON.parse(this.parseSchemaFromPax(JSON.stringify(readPaxYamlAndSchema.details.yamlSchema), `${zoweRuntimePath}/schemas/zowe-yaml-schema.json`)); | ||
const serverCommon = JSON.parse(this.parseSchemaFromPax(JSON.stringify(readPaxYamlAndSchema.details.serverCommon), `${zoweRuntimePath}/schemas/server-common.json`)); | ||
if(yamlSchema && serverCommon){ | ||
yamlSchema.additionalProperties = true; | ||
yamlSchema.properties.zowe.properties.setup.properties.dataset.properties.parmlibMembers.properties.zis = serverCommon.$defs.datasetMember; | ||
yamlSchema.properties.zowe.properties.setup.properties.certificate.properties.pkcs12.properties.directory = serverCommon.$defs.path; | ||
if(yamlSchema.$defs?.networkSettings?.properties?.server?.properties?.listenAddresses?.items){ | ||
delete yamlSchema.$defs?.networkSettings?.properties?.server?.properties?.listenAddresses?.items?.ref; | ||
yamlSchema.$defs.networkSettings.properties.server.properties.listenAddresses.items = serverCommon.$defs.ipv4 | ||
} | ||
// console.log('Setting schema from runtime dir:', JSON.stringify(yamlSchema)); | ||
ConfigurationStore.setSchema(yamlSchema); | ||
parsedSchema = true; | ||
ProgressStore.set('downloadUnpax.getSchemas', true); | ||
} | ||
} catch (e) { | ||
console.log('error setting schema from pax:', e); | ||
ProgressStore.set('downloadUnpax.getSchemas', false); | ||
ConfigurationStore.setSchema(FALLBACK_SCHEMA); | ||
return {status: false, details: {message: e.message}} | ||
} | ||
} | ||
return {status: parsedSchema && parsedYaml, details: {message: "Successfully retrieved example-zowe.yaml and schemas", mergedYaml: yamlObj}} | ||
} | ||
} catch (e) { | ||
ConfigurationStore.setSchema(FALLBACK_SCHEMA); | ||
return {status: false, details: e.message}; | ||
} | ||
|
||
} | ||
|
||
public async downloadUnpax ( | ||
connectionArgs: IIpcConnectionArgs, | ||
installationArgs: InstallationArgs, | ||
|
@@ -140,64 +272,17 @@ class Installation { | |
let readPaxYamlAndSchema = await this.readExampleYamlAndSchema(connectionArgs, zoweRuntimePath); | ||
let parsedSchema = false, parsedYaml = false; | ||
if(readPaxYamlAndSchema.details.yaml){ | ||
const parseExampleYamlFromPax = function(catPath: string){ | ||
const jobOutputSplit = JSON.stringify(readPaxYamlAndSchema.details.yaml).split(`cat ${catPath}\\r\\n`) | ||
if(jobOutputSplit[1]){ | ||
const trimmedYamlSchema = jobOutputSplit[1].split(`+ echo 'Script finished.'`)[0].split(`Script finished.`); | ||
// console.log("\n\n *** trimmedYamlSchema[0]: ", trimmedYamlSchema[0].replaceAll(`\\r\\n`, `\r\n`).replaceAll(`\\"`, `"`)); | ||
return trimmedYamlSchema[0].replaceAll(`\\r\\n`, `\r\n`).replaceAll(`\\"`, `"`); | ||
} | ||
return ""; | ||
} | ||
const yamlFromPax = parseExampleYamlFromPax(`${zoweRuntimePath}/example-zowe.yaml`); | ||
const yamlFromPax = this.parseExampleYamlFromPax(`${zoweRuntimePath}/example-zowe.yaml`, readPaxYamlAndSchema.details.yaml); | ||
if(yamlFromPax){ | ||
try { | ||
yamlObj = parse(yamlFromPax); | ||
if (currentConfig) { | ||
// console.log("current config:", JSON.stringify(currentConfig)); | ||
// console.log("yamlObj: ", JSON.stringify(yamlObj)); | ||
yamlObj = {...currentConfig, ...yamlObj} | ||
yamlObj = yamlObj = Object.assign({}, yamlObj, currentConfig); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like a typo |
||
// console.log("merged yamlObj: ", JSON.stringify(yamlObj)); | ||
} | ||
if (yamlObj.zowe.runtimeDirectory === undefined && installationArgs.installationDir) { | ||
yamlObj.zowe.runtimeDirectory = installationArgs.installationDir; | ||
} | ||
if (yamlObj.zowe.workspaceDirectory === undefined && installationArgs.workspaceDir) { | ||
yamlObj.zowe.workspaceDirectory = installationArgs.workspaceDir; | ||
} | ||
if (yamlObj.zowe.logDirectory === undefined && installationArgs.logDir) { | ||
yamlObj.zowe.logDirectory = installationArgs.logDir; | ||
} | ||
if (yamlObj.zowe.extensionDirectory === undefined && installationArgs.extensionDir) { | ||
yamlObj.zowe.extensionDirectory = installationArgs.extensionDir; | ||
} | ||
if (yamlObj.zowe.rbacProfileIdentifier === undefined && installationArgs.rbacProfile) { | ||
yamlObj.zowe.rbacProfileIdentifier = installationArgs.rbacProfile; | ||
} | ||
if (yamlObj.zowe.job.name === undefined && installationArgs.jobName) { | ||
yamlObj.zowe.job.name = installationArgs.jobName; | ||
} | ||
if (yamlObj.zowe.job.prefix === undefined && installationArgs.jobPrefix) { | ||
yamlObj.zowe.job.prefix = installationArgs.jobPrefix; | ||
} | ||
if (yamlObj.zowe.cookieIdentifier === undefined && installationArgs.cookieId) { | ||
yamlObj.zowe.cookieIdentifier = installationArgs.cookieId; | ||
} | ||
if (yamlObj.java.home === undefined && installationArgs.javaHome) { | ||
yamlObj.java.home = installationArgs.javaHome; | ||
} | ||
if (yamlObj.node.home === undefined && installationArgs.nodeHome) { | ||
yamlObj.node.home = installationArgs.nodeHome; | ||
} | ||
if (yamlObj.zOSMF.host === undefined && installationArgs.zosmfHost) { | ||
yamlObj.zOSMF.host = installationArgs.zosmfHost; | ||
} | ||
if (yamlObj.zOSMF.port === undefined && installationArgs.zosmfPort) { | ||
yamlObj.zOSMF.port = installationArgs.zosmfPort; | ||
} | ||
if (yamlObj.zOSMF.applId === undefined && installationArgs.zosmfApplId) { | ||
yamlObj.zOSMF.applId = installationArgs.zosmfApplId; | ||
} | ||
this.mergeYamlAndInstallationArgs(yamlObj, installationArgs); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason why we do this merge with installationArgs values one by one, if it should have been done a line above with yamlObj = Object.assign({}, yamlObj, currentConfig); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At one point, during the very first run of Zen current config did not exist. I haven't confirmed this behavior in a while but in my head i dont think it should ever not exist currently. |
||
if (zoweConfig) { | ||
yamlObj = {...yamlObj, ...zoweConfig}; | ||
} | ||
|
@@ -215,17 +300,9 @@ class Installation { | |
|
||
//No reason not to always set schema to latest if user is re-running installation | ||
if(readPaxYamlAndSchema.details.yamlSchema && readPaxYamlAndSchema.details.serverCommon){ | ||
const parseSchemaFromPax = function(inputString: string, catPath: string){ | ||
const jobOutputSplit = inputString.split(`cat ${catPath}\\r\\n`) | ||
if(jobOutputSplit[1]){ | ||
const trimmedYamlSchema = jobOutputSplit[1].split(`Script finished.`)[0].split(`Script finished.`); | ||
return trimmedYamlSchema[0].replaceAll(`\\r\\n`, `\r\n`).replaceAll(`\\"`, `"`).replaceAll(`\\\\"`, `\\"`); | ||
} | ||
return ""; | ||
} | ||
try { | ||
let yamlSchema = JSON.parse(parseSchemaFromPax(JSON.stringify(readPaxYamlAndSchema.details.yamlSchema), `${zoweRuntimePath}/schemas/zowe-yaml-schema.json`)); | ||
const serverCommon = JSON.parse(parseSchemaFromPax(JSON.stringify(readPaxYamlAndSchema.details.serverCommon), `${zoweRuntimePath}/schemas/server-common.json`)); | ||
let yamlSchema = JSON.parse(this.parseSchemaFromPax(JSON.stringify(readPaxYamlAndSchema.details.yamlSchema), `${zoweRuntimePath}/schemas/zowe-yaml-schema.json`)); | ||
const serverCommon = JSON.parse(this.parseSchemaFromPax(JSON.stringify(readPaxYamlAndSchema.details.serverCommon), `${zoweRuntimePath}/schemas/server-common.json`)); | ||
// console.log('yaml schema:', parseSchemas(JSON.stringify(readPaxYamlAndSchema.details.yamlSchema), `${zoweRuntimePath}/schemas/zowe-yaml-schema.json`)); | ||
// console.log('server common', parseSchemas(JSON.stringify(readPaxYamlAndSchema.details.serverCommon), `${zoweRuntimePath}/schemas/server-common.json`)); | ||
if(yamlSchema && serverCommon){ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,7 +108,6 @@ const createWindow = (): void => { | |
return res; | ||
}); | ||
|
||
|
||
ipcMain.handle('get-schema', async (event, schema: any) => { | ||
const res: any = await ConfigurationStore.getSchema(); | ||
return {status: true, details: res}; | ||
|
@@ -205,6 +204,11 @@ const createWindow = (): void => { | |
return res; | ||
}); | ||
|
||
ipcMain.handle('get-yaml-schema', async (event, connectionArgs, installationArgs) => { | ||
const res = await installActions.smpeGetExampleYamlAndSchemas(connectionArgs, installationArgs); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't this be called "getExampleYamlAndSchemas" I only see this used in 2 places, 1 in Stepper which is conditional to not SMPE and 2 in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure |
||
return res; | ||
}); | ||
|
||
ipcMain.handle('init-certificates', async (event, connectionArgs, installationArgs, zoweConfig) => { | ||
const res = await installActions.runInitCertificates(connectionArgs, installationArgs, zoweConfig); | ||
return res; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is different about smpe installation schemas to have this code separately?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good point, i changed it to reuse this function in the downloadUnpax function to reduce duplication