Skip to content

Commit 3fa9d20

Browse files
Merge pull request #75 from oracle/mac-env-changes
Mac env changes
2 parents 5185dc2 + 502e4ee commit 3fa9d20

31 files changed

+748
-220
lines changed

electron/app/js/imageBuilderUtils.js

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright (c) 2021, Oracle and/or its affiliates.
3+
* Copyright (c) 2021, 2022, Oracle and/or its affiliates.
44
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
55
*/
66
const fsUtils = require('./fsUtils');
@@ -36,18 +36,20 @@ async function validateImageBuilderExecutable(imageBuilderExe) {
3636
});
3737
}
3838

39-
async function validateImageExistsLocally(imageBuilderExe, imageTag) {
39+
async function validateImageExistsLocally(imageBuilderOptions, imageTag) {
40+
const imageBuilderExe = imageBuilderOptions.imageBuilderExe;
4041
const args = [
4142
'images',
4243
'-q',
4344
imageTag
4445
];
46+
const env = getDockerEnv(null, null, imageBuilderOptions);
4547
const result = {
4648
isSuccess: true,
4749
imageExists: true
4850
};
4951
return new Promise(resolve => {
50-
executeFileCommand(imageBuilderExe, args).then(stdoutMessage => {
52+
executeFileCommand(imageBuilderExe, args, env).then(stdoutMessage => {
5153
if (!/\S/.test(stdoutMessage.toString())) {
5254
result.imageExists = false;
5355
}
@@ -62,17 +64,18 @@ async function validateImageExistsLocally(imageBuilderExe, imageTag) {
6264
});
6365
}
6466

65-
async function doLogin(imageBuilderExe, options) {
67+
async function doLogin(imageBuilderOptions, options) {
6668
const i18n = require('./i18next.config');
6769
const httpsProxyUrl = getHttpsProxyUrl();
6870
const bypassProxyHosts = getBypassProxyHosts();
71+
const imageBuilderExe = imageBuilderOptions.imageBuilderExe;
6972

7073
const result = { isSuccess: true };
7174
if (!options.requiresLogin) {
7275
return Promise.resolve({ isSuccess: true });
7376
}
7477

75-
const env = getDockerEnv(httpsProxyUrl, bypassProxyHosts);
78+
const env = getDockerEnv(httpsProxyUrl, bypassProxyHosts, imageBuilderOptions);
7679
const args = [
7780
'login'
7881
];
@@ -105,14 +108,15 @@ async function doLogin(imageBuilderExe, options) {
105108
});
106109
}
107110

108-
async function doPushImage(currentWindow, stdoutChannel, stderrChannel, imageBuilderExe, imageTag, options) {
111+
async function doPushImage(currentWindow, stdoutChannel, stderrChannel, imageBuilderOptions, imageTag, options) {
109112
const i18n = require('./i18next.config');
110113
const httpsProxyUrl = getHttpsProxyUrl();
111114
const bypassProxyHosts = getBypassProxyHosts();
115+
const imageBuilderExe = imageBuilderOptions.imageBuilderExe;
112116

113117
const result = { isSuccess: true };
114118
if (options.requiresLogin) {
115-
const loginResult = await doLogin(imageBuilderExe, options);
119+
const loginResult = await doLogin(imageBuilderOptions, options);
116120
if (!loginResult.isSuccess) {
117121
result.isSuccess = false;
118122
result.reason = loginResult.reason;
@@ -121,7 +125,7 @@ async function doPushImage(currentWindow, stdoutChannel, stderrChannel, imageBui
121125
}
122126

123127
const args = [ 'push', imageTag ];
124-
const env = getDockerEnv(httpsProxyUrl, bypassProxyHosts);
128+
const env = getDockerEnv(httpsProxyUrl, bypassProxyHosts, imageBuilderOptions);
125129

126130
return new Promise(resolve => {
127131
executeChildProcess(currentWindow, imageBuilderExe, args, env, stdoutChannel,
@@ -139,11 +143,17 @@ async function doPushImage(currentWindow, stdoutChannel, stderrChannel, imageBui
139143
});
140144
}
141145

142-
function getDockerEnv(httpsProxyUrl, bypassProxyHosts) {
146+
function getDockerEnv(httpsProxyUrl, bypassProxyHosts, imageBuilderOptions) {
147+
let path = process.env.PATH;
148+
if (imageBuilderOptions && imageBuilderOptions.extraPathDirectories) {
149+
const extraPathDirectories = imageBuilderOptions.extraPathDirectories.join(path.delimiter);
150+
path += `${path.delimiter}${extraPathDirectories}`;
151+
}
152+
143153
let env = {
144154
DOCKER_BUILDKIT: '0',
145155
// podman relies on the PATH including other executables (e.g., newuidmap)...
146-
PATH: process.env.PATH
156+
PATH: path
147157
};
148158

149159
// Docker-specific environment variables that should be passed on
@@ -167,8 +177,18 @@ function getDockerEnv(httpsProxyUrl, bypassProxyHosts) {
167177
if (process.env.STORAGE_OPTS) {
168178
env['STORAGE_OPTS'] = process.env.STORAGE_OPTS;
169179
}
180+
if (process.env.TMPDIR) {
181+
env['TMPDIR'] = process.env.TMPDIR;
182+
}
183+
184+
if (!osUtils.isWindows()) {
185+
env['HOME'] = process.env.HOME;
186+
} else {
187+
env['USERPROFILE'] = process.env.USERPROFILE;
188+
env['PROGRAMDATA'] = process.env.PROGRAMDATA;
189+
}
170190

171-
// proxy-related environment variables
191+
// Proxy-related environment variables
172192
if (httpsProxyUrl) {
173193
env['HTTPS_PROXY'] = httpsProxyUrl;
174194
env['https_proxy'] = httpsProxyUrl;
@@ -178,12 +198,12 @@ function getDockerEnv(httpsProxyUrl, bypassProxyHosts) {
178198
env['no_proxy'] = bypassProxyHosts;
179199
}
180200

181-
if (!osUtils.isWindows()) {
182-
env['HOME'] = process.env.HOME;
183-
} else {
184-
env['USERPROFILE'] = process.env.USERPROFILE;
185-
env['PROGRAMDATA'] = process.env.PROGRAMDATA;
201+
if (imageBuilderOptions && imageBuilderOptions.extraEnvironmentVariables) {
202+
const extraEnvironmentVariables =
203+
osUtils.removeProtectedEnvironmentVariables(imageBuilderOptions.extraEnvironmentVariables);
204+
env = Object.assign(env, extraEnvironmentVariables);
186205
}
206+
187207
return env;
188208
}
189209

electron/app/js/ipcRendererPreload.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,9 @@ contextBridge.exposeInMainWorld(
232232
isLinux: () => osUtils.isLinux(),
233233
getApplicationName: () => wktApp.getApplicationName(),
234234
getVersion: () => wktApp.getApplicationVersion(),
235-
getArgv: (name) => osUtils.getArgv(name)
235+
getArgv: (name) => osUtils.getArgv(name),
236+
getPathDirectories: () => osUtils.getPathDirectories(),
237+
getEnvironmentVariables: () => osUtils.getEnvironmentVariables()
236238
},
237239
'i18n': {
238240
t: (keys, options) => {

electron/app/js/kubectlUtils.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright (c) 2021, Oracle and/or its affiliates.
3+
* Copyright (c) 2021, 2022, Oracle and/or its affiliates.
44
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
55
*/
66
'use strict';
@@ -602,7 +602,7 @@ async function apply(kubectlExe, fileData, options) {
602602
}
603603

604604
function getKubectlEnvironment(options, httpsProxyUrl, bypassProxyHosts) {
605-
const env = {
605+
let env = {
606606
PATH: process.env.PATH
607607
};
608608
if (options) {
@@ -631,6 +631,12 @@ function getKubectlEnvironment(options, httpsProxyUrl, bypassProxyHosts) {
631631
env['USERPROFILE'] = process.env.USERPROFILE;
632632
env['PROGRAMDATA'] = process.env.PROGRAMDATA;
633633
}
634+
635+
if (options && options.extraEnvironmentVariables) {
636+
const extraEnvironmentVariables =
637+
osUtils.removeProtectedEnvironmentVariables(options.extraEnvironmentVariables);
638+
env = Object.assign(env, extraEnvironmentVariables);
639+
}
634640
return env;
635641
}
636642

electron/app/js/osUtils.js

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
/**
22
* @license
3-
* Copyright (c) 2021, Oracle and/or its affiliates.
3+
* Copyright (c) 2021, 2022, Oracle and/or its affiliates.
44
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
55
*/
66
// Be careful what you put in terms of require statements in this file
77
// since it is used during bootstrapping of the app.
88
//
9+
const path = require('path');
10+
911
/* global process */
1012
function isWindows() {
1113
return process.platform === 'win32' || process.platform === 'cygwin' || process.platform === 'msys';
@@ -33,9 +35,47 @@ function getArgv(name) {
3335
return result;
3436
}
3537

38+
function getPathDirectories() {
39+
const result = [];
40+
const pathEnvVar = process.env.PATH;
41+
if (pathEnvVar) {
42+
result.push(...pathEnvVar.split(path.delimiter));
43+
}
44+
return result;
45+
}
46+
47+
function getEnvironmentVariables() {
48+
return JSON.parse(JSON.stringify(process.env));
49+
}
50+
51+
function removeProtectedEnvironmentVariables(extraEnvironmentVariablesObject) {
52+
const envCopy = Object.assign({}, extraEnvironmentVariablesObject);
53+
54+
if ('PATH' in envCopy) {
55+
delete envCopy['PATH'];
56+
}
57+
if ('HTTPS_PROXY' in envCopy) {
58+
delete envCopy['HTTPS_PROXY'];
59+
}
60+
if ('https_proxy' in envCopy) {
61+
delete envCopy['https_proxy'];
62+
}
63+
if ('NO_PROXY' in envCopy) {
64+
delete envCopy['NO_PROXY'];
65+
}
66+
if ('no_proxy' in envCopy) {
67+
delete envCopy['no_proxy'];
68+
}
69+
return envCopy;
70+
}
71+
72+
3673
module.exports = {
3774
getArgv,
75+
getEnvironmentVariables,
76+
getPathDirectories,
3877
isLinux,
3978
isMac,
40-
isWindows
79+
isWindows,
80+
removeProtectedEnvironmentVariables
4181
};

electron/app/js/witCreate.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright (c) 2021, Oracle and/or its affiliates.
3+
* Copyright (c) 2021, 2022, Oracle and/or its affiliates.
44
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
55
*/
66
'use strict';
@@ -76,7 +76,7 @@ async function createAuxImage(currentWindow, stdoutChannel, stderrChannel, creat
7676
}
7777

7878
function getCreateEnvironment(createConfig, httpsProxyUrl, bypassProxyHosts) {
79-
const env = getDockerEnv(httpsProxyUrl, bypassProxyHosts);
79+
const env = getDockerEnv(httpsProxyUrl, bypassProxyHosts, createConfig);
8080
env['JAVA_HOME'] = createConfig.javaHome;
8181
env['WLSIMG_BLDDIR'] = app.getPath('temp');
8282
return env;

electron/app/js/witInspect.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright (c) 2021, Oracle and/or its affiliates.
3+
* Copyright (c) 2021, 2022, Oracle and/or its affiliates.
44
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
55
*/
66
'use strict';
@@ -19,7 +19,7 @@ async function inspectImage(imageTag, options) {
1919
isSuccess: true
2020
};
2121
return new Promise(resolve => {
22-
callImageToolInspect(options.javaHome, imageTag, { buildEngine: options.imageBuilder }).then(response => {
22+
callImageToolInspect(options.javaHome, imageTag, options).then(response => {
2323
getLogger().debug('inspectResponse is a %s and equals: %s', typeof response, response);
2424
try {
2525
inspectResults['contents'] = JSON.parse(response);
@@ -57,16 +57,16 @@ function getInspectEnvironment(javaHome, options, httpsProxyUrl, bypassProxyHost
5757
if (options && 'useProxy' in options && options.useProxy && !httpsProxyUrl) {
5858
throw new Error('Image tool inspection called with useProxy option but user settings has no proxy URL set.');
5959
}
60-
const env = getDockerEnv(httpsProxyUrl, bypassProxyHosts);
60+
const env = getDockerEnv(httpsProxyUrl, bypassProxyHosts, options);
6161
env['JAVA_HOME'] = javaHome;
6262
env['WLSIMG_BLDDIR'] = app.getPath('temp');
6363
return env;
6464
}
6565

6666
function getImageToolInspectArgs(imageTag, options) {
6767
const args = [ 'inspect', `--image=${imageTag}`, '--patches', '--format=JSON' ];
68-
if ('buildEngine' in options && options.buildEngine) {
69-
args.push(`--builder=${options['buildEngine']}`);
68+
if ('imageBuilderExe' in options && options.imageBuilderExe) {
69+
args.push(`--builder=${options['imageBuilderExe']}`);
7070
}
7171
return args;
7272
}

electron/app/locales/en/webui.json

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@
4040
"kubectl-config-file-help": "The Kubernetes client configuration file(s) to use. Leave this empty to use the default location.",
4141
"kubectl-config-context-label": "Kubectl Config Context to Use",
4242
"kubectl-config-context-help": "The Kubernetes config file context name for the cluster to which you want to connect. The default is to use whatever the current context is, if any.",
43-
"kubectl-add-row-icon-text": "Add Extra Kubernetes Client Path Directory",
44-
"kubectl-choose-path-icon-text": "Choose Extra Kubernetes Client Path Directory",
45-
"kubectl-delete-row-icon-text": "Remove Extra Kubernetes Client Path Directory",
46-
"kubectl-extra-path-directory-header": "Extra Kubernetes Client Path Directories",
4743
"kubectl-helm-exe-file-path-label": "Helm Executable to Use",
4844
"kubectl-helm-exe-file-path-help": "The full path to the Helm executable that is used to install the WebLogic Kubernetes Operator and some ingress controllers in your Kubernetes cluster.",
4945
"kubectl-list-aksCompleteLabel": "Microsoft documentation",
@@ -66,8 +62,8 @@
6662
"kubectl-list-verifyInstall": "Open a command line and run {{command}} to verify the installation before proceeding.",
6763
"kubectl-list-versionSkew": "When installing kubectl, please install a version that is compatible with the target Kubernetes cluster. Please refer to the {{link}} for more information.",
6864
"kubectl-list-versionSkewLabel": "Kubernetes Version Skew Policy",
69-
"kubectl-list-extraPathDirectories": "On MacOS, add the directory where the {{executable}} executable is installed to the Extra Kubernetes Client Path Directories list.",
70-
"kubectl-list-eks-extraPathDirectories": "On MacOS, add the directory where the either the {{executable1}} or the {{executable2}} executable is installed to the Extra Kubernetes Client Path Directories list.",
65+
"kubectl-list-extraPathDirectories": "On macOS, add the directory where the {{executable}} executable is installed to the Extra Path Directories list on the Project Settings page.",
66+
"kubectl-list-eks-extraPathDirectories": "On macOS, add the directory where the either the {{executable1}} or the {{executable2}} executable is installed to the Extra Path Directories list on the Project Settings page.",
7167
"kubectl-button-verifyKubectlConnectivity": "Verify Connectivity",
7268
"kubectl-hints-verifyKubectlConnectivity": "Verify Kubernetes Client Connectivity to Cluster",
7369

@@ -84,6 +80,20 @@
8480

8581
"project-settings-form-name": "Project Settings",
8682
"project-settings-title": "Project Settings",
83+
"project-settings-mac-environment-question": "For macOS, do you need to add directories to the PATH or define other environment variables for Docker/Podman or Kubernetes?",
84+
"project-settings-add-path-row-icon-text": "Add Extra Path Directory",
85+
"project-settings-choose-path-icon-text": "Choose Extra Path Directory",
86+
"project-settings-delete-path-row-icon-text": "Remove Extra Path Directory",
87+
"project-settings-extra-path-directory-header": "Extra Path Directories",
88+
"project-settings-hints-macos-path-directories": "Show System Path Directories",
89+
"project-settings-button-macos-path-directories": "Show System Path",
90+
"project-settings-add-env-var-row-icon-text": "Add Extra Environment Variable",
91+
"project-settings-delete-env-var-row-icon-text": "Remove Extra Environment Variable",
92+
"project-settings-extra-environment-variable-name-header": "Extra Environment Variable Names",
93+
"project-settings-extra-environment-variable-value-header": "Extra Environment Variable Values",
94+
"project-settings-hints-macos-environment-variables": "Show System Environment Variables",
95+
"project-settings-button-macos-environment-variables": "Show System Environment",
96+
"project-settings-mac-environment-answer-message": "On macOS, applications started from the Launchpad, Dock, Finder, and Spotlight do not inherit the user's environment. As such, this application may not have the environment necessary to invoke Docker/Podman, kubectl, and Helm. Use this section to add extra directories to the PATH and define the extra environment variables needed. Please note that this extra environment configuration is only used when invoking Docker/Podman, kubectl, and Helm.",
8797
"project-settings-domain-location-title": "Target Oracle Fusion Middleware Domain Location",
8898
"project-settings-domain-location-question": "Where would you like the target Oracle Fusion Middleware domain to live?",
8999
"project-settings-domain-location-help": "Where and when the Oracle Fusion Middleware domain will be created.",
@@ -133,6 +143,12 @@
133143
"project-settings-credential-store-none-label": "Not Stored",
134144
"project-settings-credential-store-policy-answer-message": "The Credential Store Policy controls how credentials are handled when the project is saved and loaded. The options are to store them in the machine's native credential store, store them in the project file encrypted with a passphrase, or not store them at all.",
135145

146+
"macos-path-directories-dialog-title": "Inherited PATH Environment Variable Directories",
147+
148+
"macos-environment-variables-dialog-title": "Inherited Environment Variables",
149+
"macos-environment-variables-dialog-name-header": "Name",
150+
"macos-environment-variables-dialog-value-header": "Value",
151+
136152
"user-settings-dialog-log-level-error": "Error",
137153
"user-settings-dialog-log-level-warn": "Warning",
138154
"user-settings-dialog-log-level-info": "Information",
@@ -816,7 +832,7 @@
816832
"wdt-validator-validate-failed-error-message": "Validate Model failed: {{error}}. See Console window output for more information.",
817833
"wdt-validator-validate-catch-all-error-message": "Validate Model failed with an unexpected error: {{error}}",
818834
"wdt-validator-validate-complete-title": "Validate Model Complete",
819-
"wdt-validator-validate-complete-message": "Validate Model successfully prepared the model.",
835+
"wdt-validator-validate-complete-message": "Validate Model successfully validated the model.",
820836

821837
"wdt-preparer-aborted-error-title": "Prepare Model Aborted",
822838
"wdt-preparer-domain-in-pv-message": "Prepare Model has no meaning when the target domain location is an externally created Kubernetes persistent volume.",
@@ -1278,7 +1294,7 @@
12781294
"quickstart-page2-list-item-4": "Accessing Docker Hub, GitHub Container Registry, and any other remote Image registries the project specifies.",
12791295
"quickstart-page2-list-item-5": "Accessing any remote Kubernetes cluster the project configuration specifies.",
12801296
"quickstart-page2-paragraph-1": "As such, it is critical that you review the application preferences to make sure that the Proxy Configuration is correct for your environment.",
1281-
"quickstart-page2-paragraph-2": "To access the application preferences, use the Preferences menu item, which is located in the File menu on Windows and Linux and in the application menu on MacOS.",
1297+
"quickstart-page2-paragraph-2": "To access the application preferences, use the Preferences menu item, which is located in the File menu on Windows and Linux and in the application menu on macOS.",
12821298
"quickstart-page2-paragraph-3": "Should you have to change the Proxy Configuration, restart the application to make sure the application provides you all the help possible for the default values.",
12831299

12841300
"quickstart-page3-title": "WKT Project File",

0 commit comments

Comments
 (0)