Skip to content

Commit 24c0dd8

Browse files
Verrazzano Support (#154)
* intermediate checkpoint * Verrazzano Install page complete * adding Go menu items for Verrazzano install and fixing list issues * first pass at Verrazzano components * changing the tab name for Verrazzano Installation * fixing an issue with the punycode 2.1.1 module SHA changing * intermediate checkpoint for applications * fixing lint issue * more intermediate fixes * more intermediate fixes * Avoid error when dialog cancelled * Added bottom margin to add component button * Treat a property as defined if it is set to false * Treat a property as defined if it is set to false * Correct typo in component key list * Added edit fields for trait types; minor fixes for accordion * Removed log message * Set a flag for project dirty flag if component attribute is changed * Refresh the accordion control when a component is added * Remove unused require * Ensure accordion is ready before refreshing * scripts and actions finished * removing UID from Ingress Trait rule path elements in generated application resource * getting new version of punycode * adding domain Node Selector support * initial cut at removing prepare model-relaated restrictions for Verrazzaano * Set replica count in resource files. based on model * Set replica count in resource files, based on model * fixing prepare model domain parsing for verrazzano target * Use copy of original rule for prompt dialog Co-authored-by: Richard Killen <[email protected]>
1 parent 953d07a commit 24c0dd8

File tree

92 files changed

+7574
-450
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+7574
-450
lines changed

electron/app/js/githubUtils.js

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
/**
2+
* @license
3+
* Copyright (c) 2022, Oracle and/or its affiliates.
4+
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
5+
*/
6+
'use strict';
7+
8+
const HttpsProxyAgent = require('https-proxy-agent');
9+
const fetch = require('node-fetch');
10+
11+
// WARNING: This file contains functions that are called by build scripts
12+
// (where this code is not running in Electron). As such, do not
13+
// require files like userSettings.js, wktLogging.js, or
14+
// wktTools.js, all of which execute code during that requires an
15+
// electron environment to function properly.
16+
//
17+
async function getReleaseVersions(name, baseUrl, options = undefined) {
18+
const proxyAgent = await getProxyAgent(options);
19+
return new Promise((resolve, reject) => {
20+
const releasesUrl = `${baseUrl}/releases`;
21+
fetch(releasesUrl, getFetchOptions(proxyAgent)).then(res => {
22+
res.json().then(fetchResults => {
23+
const results = fetchResults.map(fetchResult => {
24+
return {
25+
name: fetchResult.name,
26+
tag: fetchResult.tag_name,
27+
};
28+
});
29+
resolve(results);
30+
});
31+
}).catch(err => reject(new Error(`Failed to get release versions for ${name} from ${releasesUrl}: ${err}`)));
32+
});
33+
}
34+
35+
async function getLatestReleaseObject(name, baseUrl, options = undefined) {
36+
const proxyAgent = await getProxyAgent(options);
37+
return new Promise((resolve, reject) => {
38+
const latestUrl = baseUrl + '/releases/latest';
39+
fetch(latestUrl, getFetchOptions(proxyAgent)).then(res => {
40+
const results = res.json();
41+
resolve(results);
42+
}).catch(err => reject(new Error(`Failed to get the latest release of ${name} from ${latestUrl}: ${err}`)));
43+
});
44+
}
45+
46+
async function getSpecifiedReleaseObject(name, tag, baseUrl, options = undefined) {
47+
const proxyAgent = await getProxyAgent(options);
48+
return new Promise((resolve, reject) => {
49+
const releaseUrl = baseUrl + '/releases/tags/' + tag;
50+
fetch(releaseUrl, getFetchOptions(proxyAgent))
51+
.then(res => resolve(res.json()))
52+
.catch(err => reject(new Error(`Failed to get the ${tag} release of ${name} from ${releaseUrl}: ${err}`)));
53+
});
54+
}
55+
56+
async function getProxyOptionsFromPreferences() {
57+
return new Promise((resolve, reject) => {
58+
try {
59+
// This require statement for userSettings should be safe since the build
60+
// scripts always pass a non-empty options object, which means that
61+
// getProxyAgent() will never call this function in a build scripts context.
62+
//
63+
const httpsProxyUrl = require('./userSettings').getHttpsProxyUrl();
64+
if (httpsProxyUrl) {
65+
resolve({ httpsProxyUrl: httpsProxyUrl });
66+
} else {
67+
resolve();
68+
}
69+
} catch (err) {
70+
reject(err);
71+
}
72+
});
73+
}
74+
75+
async function getProxyAgent(options = undefined) {
76+
const proxyOptions = options || await getProxyOptionsFromPreferences();
77+
const httpsProxyUrl = _getHttpsProxyUrl(proxyOptions);
78+
79+
let proxyAgent;
80+
if (httpsProxyUrl) {
81+
proxyAgent = new HttpsProxyAgent(httpsProxyUrl);
82+
}
83+
return proxyAgent;
84+
}
85+
86+
function getFetchOptions(proxyAgent) {
87+
let options = {};
88+
if (proxyAgent) {
89+
options = {
90+
agent: proxyAgent
91+
};
92+
}
93+
return options;
94+
}
95+
96+
function _getHttpsProxyUrl(options) {
97+
const myOptions = _getOptions(options, {httpsProxyUrl: undefined});
98+
return myOptions.httpsProxyUrl;
99+
}
100+
101+
function _getOptions(options, defaultOptions) {
102+
if (options === null || options === undefined || typeof options === 'function') {
103+
return defaultOptions;
104+
}
105+
106+
if (typeof options === 'string') {
107+
defaultOptions = {...defaultOptions};
108+
defaultOptions.httpsProxy = options;
109+
options = defaultOptions;
110+
} else if (typeof options !== 'object') {
111+
throw new Error(`Invalid options argument type: ${typeof options}`);
112+
}
113+
return options;
114+
}
115+
116+
module.exports = {
117+
getFetchOptions,
118+
getLatestReleaseObject,
119+
getProxyOptionsFromPreferences,
120+
getProxyAgent,
121+
getReleaseVersions,
122+
getSpecifiedReleaseObject,
123+
};

electron/app/js/ipcRendererPreload.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const fsUtils = require('./fsUtils');
1212
const WktApp = require('./wktApp');
1313
const osUtils = require('./osUtils');
1414
const i18n = require('./i18next.webui.config');
15+
const { compareVersions } = require('./versionUtils');
1516

1617
const wktApp = new WktApp();
1718

@@ -85,6 +86,12 @@ contextBridge.exposeInMainWorld(
8586
'start-k8s-domain-deploy',
8687
'start-k8s-domain-undeploy',
8788
'start-get-k8s-domain-status',
89+
'start-verrazzano-install',
90+
'start-get-verrazzano-install-status',
91+
'start-deploy-verrazzano-component',
92+
'start-undeploy-verrazzano-component',
93+
'start-deploy-verrazzano-application',
94+
'start-undeploy-verrazzano-application',
8895
'start-app-quit',
8996
'start-window-close'
9097
];
@@ -207,7 +214,22 @@ contextBridge.exposeInMainWorld(
207214
'get-wrc-home-directory',
208215
'get-wrc-app-image',
209216
'wrc-get-home-default-value',
210-
'wrc-set-home-and-start'
217+
'wrc-set-home-and-start',
218+
'get-verrazzano-release-versions',
219+
'is-verrazzano-installed',
220+
'install-verrazzano-platform-operator',
221+
'verify-verrazzano-platform-operator-install',
222+
'install-verrazzano',
223+
'verify-verrazzano-install-status',
224+
'deploy-verrazzano-components',
225+
'undeploy-verrazzano-components',
226+
'get-verrazzano-component-names',
227+
'get-verrazzano-secret-names',
228+
'get-verrazzano-cluster-names',
229+
'get-verrazzano-deployment-names-all-namespaces',
230+
'deploy-verrazzano-project',
231+
'deploy-verrazzano-application',
232+
'undeploy-verrazzano-application',
211233
];
212234
return new Promise((resolve, reject) => {
213235
if (validChannels.includes(channel)) {
@@ -256,6 +278,7 @@ contextBridge.exposeInMainWorld(
256278
},
257279
'utils': {
258280
generateUuid: () => uuid.v4(),
281+
compareVersions: (version, otherVersion) => compareVersions(version, otherVersion),
259282
mainModule: mainModule
260283
}
261284
}

0 commit comments

Comments
 (0)