Skip to content

Commit a259353

Browse files
Merge pull request #47 from oracle/aux-image-support
initial aux image support
2 parents 06adecf + 24f741c commit a259353

File tree

9 files changed

+277
-52
lines changed

9 files changed

+277
-52
lines changed

electron/app/js/ipcRendererPreload.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ contextBridge.exposeInMainWorld(
6565
'blur-focused-item',
6666
'start-prepare-model',
6767
'start-create-image',
68+
'start-create-aux-image',
6869
'start-push-image',
70+
'start-push-aux-image',
6971
'start-k8s-verify-connection',
7072
'start-wko-install',
7173
'start-ingress-install',
@@ -145,6 +147,7 @@ contextBridge.exposeInMainWorld(
145147
'do-image-registry-login',
146148
'validate-image-builder-exe',
147149
'wit-create-image',
150+
'wit-create-aux-image',
148151
'validate-image-exists-locally',
149152
'do-push-image',
150153
'kubectl-get-current-context',

electron/app/js/userSettings.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,6 @@ function _getUserSettings() {
268268
if (userSettingsFileContent && userSettingsFileContent.length > 0) {
269269
try {
270270
const userSettingsObject = JSON.parse(userSettingsFileContent);
271-
console.log('parsed userSettings object = %s', userSettingsObject);
272271
_userSettingsObject = _updateSettings(userSettingsObject);
273272
} catch (err) {
274273
throw new Error(`Failed to parse ${userSettingsFileName}: ${err}`);

electron/app/js/witCreate.js

Lines changed: 96 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ async function createImage(currentWindow, stdoutChannel, stderrChannel, createCo
1717
const bypassProxyHosts = getBypassProxyHosts();
1818

1919
const imageToolScript = getImagetoolShellScript();
20-
const [ args, argsContainCredentials ] = buildArgumentsList(createConfig, httpsProxyUrl);
20+
const [ args, argsContainCredentials ] = buildArgumentsListForCreate(createConfig, httpsProxyUrl);
2121
const env = {
2222
JAVA_HOME: createConfig.javaHome,
2323
DOCKER_BUILDKIT: '0',
@@ -35,9 +35,8 @@ async function createImage(currentWindow, stdoutChannel, stderrChannel, createCo
3535
};
3636

3737
return new Promise(resolve => {
38-
if (!argsContainCredentials) {
39-
getLogger().debug('Executing %s shell script with args %s and environment %s', imageToolScript, args, JSON.stringify(env));
40-
}
38+
const filteredArgs = argsContainCredentials ? filterArgsForLogging(args) : args;
39+
getLogger().debug('Executing %s shell script with args %s and environment %s', imageToolScript, filteredArgs, JSON.stringify(env));
4140
executeChildShellScript(currentWindow, imageToolScript, args, env, stdoutChannel,
4241
{ stderrEventName: stderrChannel })
4342
.then(exitCode => {
@@ -56,7 +55,47 @@ async function createImage(currentWindow, stdoutChannel, stderrChannel, createCo
5655
});
5756
}
5857

59-
function buildArgumentsList(createConfig, httpsProxyUrl) {
58+
async function createAuxImage(currentWindow, stdoutChannel, stderrChannel, createConfig) {
59+
const httpsProxyUrl = getHttpsProxyUrl();
60+
const bypassProxyHosts = getBypassProxyHosts();
61+
62+
const imageToolScript = getImagetoolShellScript();
63+
const args = buildArgumentsListForCreateAuxImage(createConfig, httpsProxyUrl);
64+
const env = {
65+
JAVA_HOME: createConfig.javaHome,
66+
DOCKER_BUILDKIT: '0',
67+
WLSIMG_BLDDIR: app.getPath('temp')
68+
};
69+
if (httpsProxyUrl) {
70+
env['HTTPS_PROXY'] = httpsProxyUrl;
71+
}
72+
if (bypassProxyHosts) {
73+
env['NO_PROXY'] = bypassProxyHosts;
74+
}
75+
76+
const result = {
77+
isSuccess: true
78+
};
79+
80+
return new Promise(resolve => {
81+
getLogger().debug('Executing %s shell script with args %s and environment %s', imageToolScript, args, JSON.stringify(env));
82+
executeChildShellScript(currentWindow, imageToolScript, args, env, stdoutChannel,
83+
{ stderrEventName: stderrChannel }).then(exitCode => {
84+
if (exitCode !== 0) {
85+
result.isSuccess = false;
86+
result.reason = i18n.t('wit-create-create-aux-image-exit-code-error-message', { exitCode: exitCode });
87+
}
88+
resolve(result);
89+
}).catch(err => {
90+
getLogger().error(err);
91+
result.isSuccess = false;
92+
result.reason = i18n.t('wit-create-create-aux-image-error-message', { error: err.message || err });
93+
resolve(result);
94+
});
95+
});
96+
}
97+
98+
function buildArgumentsListForCreate(createConfig, httpsProxyUrl) {
6099
const args = [ 'create' ];
61100

62101
if (createConfig.imageBuilderExe) {
@@ -81,6 +120,30 @@ function buildArgumentsList(createConfig, httpsProxyUrl) {
81120
return [ args, argsContainCredentials ];
82121
}
83122

123+
function buildArgumentsListForCreateAuxImage(createConfig, httpsProxyUrl) {
124+
const args = [ 'createAuxImage' ];
125+
126+
if (createConfig.imageBuilderExe) {
127+
args.push('--builder', createConfig.imageBuilderExe);
128+
}
129+
args.push('--tag', createConfig.imageTag);
130+
131+
if (httpsProxyUrl) {
132+
args.push('--httpsProxyUrl', httpsProxyUrl);
133+
}
134+
135+
if (createConfig.baseImage) {
136+
args.push('--fromImage', createConfig.baseImage);
137+
}
138+
if (createConfig.alwaysPullBaseImage) {
139+
args.push('--pull');
140+
}
141+
addInstallerArgs(args, createConfig);
142+
addWdtArgs(args, createConfig);
143+
addAdvancedArgs(args, createConfig);
144+
return args;
145+
}
146+
84147
function addInstallerArgs(args, createConfig) {
85148
if (createConfig.jdkInstallerVersion) {
86149
args.push('--jdkVersion', createConfig.jdkInstallerVersion);
@@ -148,6 +211,10 @@ function addWdtArgs(args, createConfig) {
148211
args.push('--wdtDomainHome', createConfig.domainHome);
149212
}
150213

214+
if (createConfig.wdtHome) {
215+
args.push('--wdtHome', createConfig.wdtHome);
216+
}
217+
151218
if (createConfig.modelHome) {
152219
args.push('--wdtModelHome', createConfig.modelHome);
153220
}
@@ -166,14 +233,33 @@ function addAdvancedArgs(args, createConfig) {
166233
args.push('--buildNetwork', createConfig.buildNetwork);
167234
}
168235

169-
if (createConfig.chownOwner || createConfig.chownGroup) {
170-
const owner = createConfig.chownOwner || 'oracle';
171-
const group = createConfig.chownGroup || 'oracle';
236+
if (createConfig.target) {
237+
args.push('--target', createConfig.target);
238+
}
239+
240+
if (createConfig.chownOwner && createConfig.chownGroup) {
241+
args.push('--chown', `${createConfig.chownOwner}:${createConfig.chownGroup}`);
242+
}
243+
}
172244

173-
args.push('--chown', `${owner}:${group}`);
245+
function filterArgsForLogging(args) {
246+
const filteredArgs = [];
247+
let filterNextArg = false;
248+
for (const arg of args) {
249+
if (filterNextArg) {
250+
filteredArgs.push('********');
251+
filterNextArg = false;
252+
} else {
253+
filteredArgs.push(arg);
254+
if (arg === '--user' || arg === '--password') {
255+
filterNextArg = true;
256+
}
257+
}
174258
}
259+
return filteredArgs;
175260
}
176261

177262
module.exports = {
178-
createImage
263+
createImage,
264+
createAuxImage
179265
};

electron/app/js/wktWindow.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,34 @@ class WktAppMenu {
269269
sendToWindow(focusedWindow,'start-push-image');
270270
}
271271
},
272+
{
273+
id: 'createAuxImage',
274+
label: i18n.t('menu-go-create-aux-image'),
275+
enabled: !this._hasOpenDialog,
276+
click(item, focusedWindow) {
277+
if (!focusedWindow) {
278+
return dialog.showErrorBox(
279+
i18n.t('menu-go-create-aux-image-error-title'),
280+
i18n.t('menu-go-create-aux-image-error-message')
281+
);
282+
}
283+
sendToWindow(focusedWindow,'start-create-aux-image');
284+
}
285+
},
286+
{
287+
id: 'pushAuxImage',
288+
label: i18n.t('menu-go-push-aux-image'),
289+
enabled: !this._hasOpenDialog,
290+
click(item, focusedWindow) {
291+
if (!focusedWindow) {
292+
return dialog.showErrorBox(
293+
i18n.t('menu-go-push-aux-image-error-title'),
294+
i18n.t('menu-go-push-aux-image-error-message')
295+
);
296+
}
297+
sendToWindow(focusedWindow,'start-push-aux-image');
298+
}
299+
},
272300
{
273301
id: 'verifyConnectivity',
274302
label: i18n.t('menu-go-kubectl-verify-connectivity'),

electron/app/locales/en/electron.json

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,18 @@
3030
"menu-go-prep-model-for-k8s": "Prepare Model for Kubernetes",
3131
"menu-go-prepare-model-error-title": "No Active Project Window",
3232
"menu-go-prepare-model-error-message": "Cannot run Prepare Model since there is no active window, and therefore no project with a model to prepare.",
33-
"menu-go-create-image": "Create Image",
33+
"menu-go-create-image": "Create Primary Image",
3434
"menu-go-create-image-error-title": "No Active Project Window",
35-
"menu-go-create-image-error-message": "Cannot run Create Image since there is no active window, and therefore no project with an image to create.",
36-
"menu-go-push-image": "Push Image to Registry",
35+
"menu-go-create-image-error-message": "Cannot run Create Primary Image since there is no active window, and therefore no project with an image to create.",
36+
"menu-go-push-image": "Push Primary Image to Registry",
3737
"menu-go-push-image-error-title": "No Active Project Window",
38-
"menu-go-push-image-error-message": "Cannot push image since there is no active window, and therefore no project with an image to push.",
38+
"menu-go-push-image-error-message": "Cannot push primary image since there is no active window, and therefore no project with an image to push.",
39+
"menu-go-create-aux-image": "Create Auxiliary Image",
40+
"menu-go-create-aux-image-error-title": "No Active Project Window",
41+
"menu-go-create-aux-image-error-message": "Cannot run Create Auxiliary Image since there is no active window, and therefore no project with an image to create.",
42+
"menu-go-push-aux-image": "Push Auxiliary Image to Registry",
43+
"menu-go-push-aux-image-error-title": "No Active Project Window",
44+
"menu-go-push-aux-image-error-message": "Cannot push primary image since there is no active window, and therefore no project with an image to push.",
3945
"menu-go-kubectl-verify-connectivity": "Verify Kubernetes Client Connection",
4046
"menu-go-kubectl-verify-connectivity-error-title": "No Active Project Window",
4147
"menu-go-kubectl-verify-connectivity-error-message": "Cannot verify Kubernetes client connectivity since there is no active window, and therefore no project with a Kubernetes configuration to verify.",
@@ -217,7 +223,9 @@
217223
"wit-cache-wdt-installer-cache-failed-error-message": "Failed to add the WebLogic Deploy Tooling installer to the WebLogic Image Tool cache: {{error}}.",
218224

219225
"wit-create-create-exit-code-error-message": "Create Image exited with non-zero exit code {{exitCode}} that indicates an error. Please consult the output window for more information.",
226+
"wit-create-create-aux-image-exit-code-error-message": "Create Auxiliary Image exited with non-zero exit code {{exitCode}} that indicates an error. Please consult the output window for more information.",
220227
"wit-create-create-error-message": "Creating image failed: {{error}}",
228+
"wit-create-create-aux-image-error-message": "Creating auxiliary image failed: {{error}}",
221229

222230
"image-builder-not-specified": "Image Builder executable was empty.",
223231
"image-builder-not-exists": "Image Builder executable {{imageBuilder}} does not exist.",

0 commit comments

Comments
 (0)