Skip to content

Commit fbbefa4

Browse files
committed
more environment variable-related changes for podman
1 parent fef9650 commit fbbefa4

File tree

3 files changed

+28
-40
lines changed

3 files changed

+28
-40
lines changed

electron/app/js/imageBuilderUtils.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,18 @@ function getDockerEnv(httpsProxyUrl, bypassProxyHosts) {
142142
PATH: process.env.PATH
143143
};
144144

145+
// podman-specific environment variable
146+
if (process.env.STORAGE_DRIVER) {
147+
env['STORAGE_DRIVER'] = process.env.STORAGE_DRIVER;
148+
}
149+
145150
if (httpsProxyUrl) {
146151
env['HTTPS_PROXY'] = httpsProxyUrl;
152+
env['https_proxy'] = httpsProxyUrl;
147153
}
148154
if (bypassProxyHosts) {
149155
env['NO_PROXY'] = bypassProxyHosts;
156+
env['no_proxy'] = bypassProxyHosts;
150157
}
151158

152159
if (!osUtils.isWindows()) {
@@ -161,6 +168,7 @@ function getDockerEnv(httpsProxyUrl, bypassProxyHosts) {
161168
module.exports = {
162169
doLogin,
163170
doPushImage,
171+
getDockerEnv,
164172
validateImageBuilderExecutable,
165173
validateImageExistsLocally
166174
};

electron/app/js/witCreate.js

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,15 @@ const { getLogger } = require('./wktLogging');
1111
const { getImagetoolShellScript } = require('./wktTools');
1212
const { getHttpsProxyUrl, getBypassProxyHosts } = require('./userSettings');
1313
const { executeChildShellScript } = require('./childProcessExecutor');
14+
const { getDockerEnv } = require('./imageBuilderUtils');
1415

1516
async function createImage(currentWindow, stdoutChannel, stderrChannel, createConfig) {
1617
const httpsProxyUrl = getHttpsProxyUrl();
1718
const bypassProxyHosts = getBypassProxyHosts();
1819

1920
const imageToolScript = getImagetoolShellScript();
2021
const [ args, argsContainCredentials ] = buildArgumentsListForCreate(createConfig, httpsProxyUrl);
21-
const env = {
22-
JAVA_HOME: createConfig.javaHome,
23-
DOCKER_BUILDKIT: '0',
24-
WLSIMG_BLDDIR: app.getPath('temp')
25-
};
26-
// imagetool only honors the lower-cased versions of these variables...
27-
if (httpsProxyUrl) {
28-
env['HTTPS_PROXY'] = httpsProxyUrl;
29-
env['https_proxy'] = httpsProxyUrl;
30-
}
31-
if (bypassProxyHosts) {
32-
env['NO_PROXY'] = bypassProxyHosts;
33-
env['no_proxy'] = bypassProxyHosts;
34-
}
22+
const env = getCreateEnvironment(createConfig, httpsProxyUrl, bypassProxyHosts);
3523

3624
const result = {
3725
isSuccess: true
@@ -64,18 +52,7 @@ async function createAuxImage(currentWindow, stdoutChannel, stderrChannel, creat
6452

6553
const imageToolScript = getImagetoolShellScript();
6654
const args = buildArgumentsListForCreateAuxImage(createConfig, httpsProxyUrl);
67-
const env = {
68-
JAVA_HOME: createConfig.javaHome,
69-
DOCKER_BUILDKIT: '0',
70-
WLSIMG_BLDDIR: app.getPath('temp')
71-
};
72-
if (httpsProxyUrl) {
73-
env['HTTPS_PROXY'] = httpsProxyUrl;
74-
}
75-
if (bypassProxyHosts) {
76-
env['NO_PROXY'] = bypassProxyHosts;
77-
}
78-
55+
const env = getCreateEnvironment(createConfig, httpsProxyUrl, bypassProxyHosts);
7956
const result = {
8057
isSuccess: true
8158
};
@@ -98,6 +75,13 @@ async function createAuxImage(currentWindow, stdoutChannel, stderrChannel, creat
9875
});
9976
}
10077

78+
function getCreateEnvironment(createConfig, httpsProxyUrl, bypassProxyHosts) {
79+
const env = getDockerEnv(httpsProxyUrl, bypassProxyHosts);
80+
env['JAVA_HOME'] = createConfig.javaHome;
81+
env['WLSIMG_BLDDIR'] = app.getPath('temp');
82+
return env;
83+
}
84+
10185
function buildArgumentsListForCreate(createConfig, httpsProxyUrl) {
10286
const args = [ 'create' ];
10387

electron/app/js/witInspect.js

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
*/
66
'use strict';
77

8+
const { app } = require('electron');
89
const i18n = require('./i18next.config');
910
const { executeScriptCommand } = require('./childProcessExecutor');
1011
const userSettings = require('./userSettings');
1112
const { getImagetoolShellScript } = require('./wktTools');
1213
const { getLogger } = require('./wktLogging');
1314
const { getErrorMessage } = require('./errorUtils');
15+
const { getDockerEnv } = require('./imageBuilderUtils');
1416

1517
async function inspectImage(imageTag, options) {
1618
const inspectResults = {
@@ -42,9 +44,7 @@ async function callImageToolInspect(javaHome, imageTag, options) {
4244
const bypassProxyHosts = userSettings.getBypassProxyHosts();
4345

4446
return new Promise((resolve, reject) => {
45-
const env = { JAVA_HOME: javaHome };
46-
getProxyEnvironment(env, options, httpsProxyUrl, bypassProxyHosts);
47-
47+
const env = getInspectEnvironment(javaHome, options, httpsProxyUrl, bypassProxyHosts);
4848
const scriptName = getImagetoolShellScript();
4949
const args = getImageToolInspectArgs(imageTag, options);
5050
executeScriptCommand(scriptName, args, env).then(results => {
@@ -53,18 +53,14 @@ async function callImageToolInspect(javaHome, imageTag, options) {
5353
});
5454
}
5555

56-
function getProxyEnvironment(env, options, httpsProxyUrl, bypassProxyHosts) {
57-
if (options && 'useProxy' in options && options.useProxy) {
58-
if (httpsProxyUrl) {
59-
env['HTTPS_PROXY'] = httpsProxyUrl;
60-
} else {
61-
throw new Error('Image tool inspection called with useProxy option but user settings has no proxy URL set.');
62-
}
63-
64-
if (bypassProxyHosts) {
65-
env['NO_POXY'] = bypassProxyHosts;
66-
}
56+
function getInspectEnvironment(javaHome, options, httpsProxyUrl, bypassProxyHosts) {
57+
if (options && 'useProxy' in options && options.useProxy && !httpsProxyUrl) {
58+
throw new Error('Image tool inspection called with useProxy option but user settings has no proxy URL set.');
6759
}
60+
const env = getDockerEnv(httpsProxyUrl, bypassProxyHosts);
61+
env['JAVA_HOME'] = javaHome;
62+
env['WLSIMG_BLDDIR'] = app.getPath('temp');
63+
return env;
6864
}
6965

7066
function getImageToolInspectArgs(imageTag, options) {

0 commit comments

Comments
 (0)