Skip to content

Commit f0c70f5

Browse files
Merge pull request #57 from oracle/aux-docker-pull-creds
adding the ability to specify docker hub login credentials for pulling the default aux image base image
2 parents fbbefa4 + 3b6c4d5 commit f0c70f5

File tree

6 files changed

+72
-5
lines changed

6 files changed

+72
-5
lines changed

electron/app/locales/en/webui.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,12 @@
232232
"image-design-aux-image-tag-use-help": "The tag to use to identify the existing image containing the WebLogic Deploy Tooling installation and model to use to create the domain.",
233233
"image-design-aux-image-registry-address-label": "Auxiliary Image Registry Address",
234234
"image-design-aux-image-registry-address-help": "The auxiliary image registry hostname and port to use to log in to the registry, if required. This field's value is parsed from the Auxiliary Image Tag field and an empty value assumes Docker Hub is the registry being used.",
235+
"image-design-aux-default-base-image-use-authentication-label": "Specify Docker Hub Pull Credentials",
236+
"image-design-aux-default-base-image-use-authentication-help": "By default, the WebLogic Image Tool uses a base image from Docker Hub. While logging in is not strictly required, Docker Hub is limiting the number of anonymous pull requests so providing your Docker Hub credentials will avoid this limit.",
237+
"image-design-aux-default-base-image-pull-username-label": "Docker Hub Username",
238+
"image-design-aux-default-base-image-pull-username-help": "The user name to use to log into the Docker Hub image registry.",
239+
"image-design-aux-default-base-image-pull-password-label": "Docker Hub Password",
240+
"image-design-aux-default-base-image-pull-password-help": "The password to use to log into the Docker Hub image registry.",
235241
"image-design-aux-image-registry-push-requires-authentication-label": "Specify Auxiliary Image Push Credentials",
236242
"image-design-aux-image-registry-push-requires-authentication-help": "Whether you want to specify authentication credentials for pushing the new auxiliary image to the registry.",
237243
"image-design-aux-image-registry-push-username-label": "Auxiliary Image Registry Push Username",
@@ -631,6 +637,7 @@
631637
"ingress-design-ingress-annotations": "Optional Annotations",
632638
"ingress-design-ingress-route-name-help": "The name to be used for creating this ingress route.",
633639
"ingress-design-ingress-route-virtualhost-help": "The virtual host name is used as the host routing rule for this ingress route.",
640+
"ingress-design-ingress-route-virtualhost-help": "The virtual host name is used as the host routing rule for this ingress route.",
634641
"ingress-design-ingress-route-targetservice-help": "The target service is the where this ingress route will send the request to the backend Kubernetes service address.",
635642
"ingress-design-ingress-route-targetport-help": "The target port is the where this ingress route will send the request to the backend Kubernetes service port.",
636643
"ingress-design-ingress-route-path-help": "The URL path routing rule for this ingress route.",

webui/src/js/models/image-definition.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ define(['knockout', 'utils/observable-properties', 'utils/validation-helper'],
8080
this.auxImageTag.addValidator(...validationHelper.getImageTagValidators());
8181
this.createAuxImage = props.createProperty(true);
8282

83+
this.auxDefaultBaseImagePullRequiresAuthentication = props.createProperty(true);
84+
this.auxDefaultBaseImagePullUsername = props.createProperty().asCredential();
85+
this.auxDefaultBaseImagePullPassword = props.createProperty().asCredential();
86+
8387
this.auxImageRegistryPushRequireAuthentication = props.createProperty(true);
8488
this.auxImageRegistryPushUser = props.createProperty().asCredential();
8589
this.auxImageRegistryPushPassword = props.createProperty().asCredential();

webui/src/js/utils/image-script-generator.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,13 @@ define(['models/wkt-project', 'utils/script-generator-base'],
333333
this.adapter.addVariableDefinition('BASE_IMAGE_REGISTRY_PULL_USER', this.credentialMask);
334334
this.adapter.addVariableDefinition('BASE_IMAGE_REGISTRY_PULL_PASS', this.credentialMask);
335335
}
336-
this.adapter.addEmptyLine();
336+
} else {
337+
this.adapter.addVariableDefinition('USE_LOGIN_FOR_DOCKER_HUB',
338+
this.project.image.auxDefaultBaseImagePullRequiresAuthentication.value);
339+
this.adapter.addVariableDefinition('DOCKER_HUB_USER', this.credentialMask);
340+
this.adapter.addVariableDefinition('DOCKER_HUB_PASS', this.credentialMask);
337341
}
342+
this.adapter.addEmptyLine();
338343

339344
const wdtInstallerValue = this.project.image.wdtInstaller.value || this.fillMeInMask;
340345
const wdtInstallerVersion = this.project.image.wdtInstallerVersion.value || this.fillMeInMask;
@@ -390,8 +395,15 @@ define(['models/wkt-project', 'utils/script-generator-base'],
390395
const loginErrorMessage = `Failed to log into the base image registry ${baseImageRegistryName}`;
391396
this.adapter.addWitBaseImageArgsBlock('WIT_CREATE_AUX_IMAGE_ARGS', 'Handle Custom Base Image, if needed.',
392397
baseImageTag, baseImagePullRequiresAuthentication, host, user, password, builder, loginErrorMessage);
398+
} else {
399+
const loginToDockerHub = this.adapter.getVariableReference('USE_LOGIN_FOR_DOCKER_HUB');
400+
const user = this.adapter.getVariableReference('DOCKER_HUB_USER');
401+
const password = this.adapter.getVariableReference('DOCKER_HUB_PASS');
402+
const loginErrorMessage = 'Failed to log into Docker Hub';
403+
this.adapter.addDockerLoginBlock(loginToDockerHub, '', user, password, builder, loginErrorMessage)
393404
}
394-
405+
this.adapter.addEmptyLine();
406+
395407
this.adapter.addIfEqualCollectArgsBlock('WIT_CREATE_AUX_IMAGE_ARGS',
396408
this.adapter.getVariableReference('ALWAYS_PULL_BASE_IMAGE'), 'true', '--pull');
397409
const wdtHome = this.adapter.getVariableReference('WDT_HOME');

webui/src/js/utils/wit-aux-creator.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,19 +140,20 @@ function (WitActionsBase, project, wktConsole, wdtModelPreparer, i18n, projectIo
140140
// Populate the cache
141141
//
142142
const cacheConfig = {
143+
javaHome: javaHome,
143144
wdtInstaller: wdtInstaller,
144145
wdtInstallerVersion: wdtInstallerVersion
145146
};
146147
if (! await this.addInstallersToCache(cacheConfig, errTitle, errPrefix)) {
147148
return Promise.resolve(false);
148149
}
149150

150-
// if using custom base image and requires authentication, do build-tool login.
151151
busyDialogMessage = i18n.t('wit-aux-creator-builder-login-in-progress',
152152
{builderName: imageBuilderType, imageTag: this.project.image.auxBaseImage.value});
153153
dialogHelper.updateBusyDialog(busyDialogMessage, 10 / totalSteps);
154-
if (this.project.image.auxUseCustomBaseImage.value && this.project.image.auxBaseImage.value &&
154+
if (this.project.image.auxUseCustomBaseImage.value &&
155155
this.project.image.auxBaseImagePullRequiresAuthentication.value) {
156+
// if using custom base image and requires authentication, do build-tool login.
156157
const loginConfig = {
157158
requiresLogin: this.project.image.auxBaseImagePullRequiresAuthentication.value,
158159
host: this.project.image.internal.auxBaseImageRegistryAddress.value,
@@ -162,6 +163,17 @@ function (WitActionsBase, project, wktConsole, wdtModelPreparer, i18n, projectIo
162163
if (! await this.loginToImageRegistry(imageBuilderExe, loginConfig, errTitle, errPrefix)) {
163164
return Promise.resolve(false);
164165
}
166+
} else if (!this.project.image.auxUseCustomBaseImage.value &&
167+
this.project.image.auxDefaultBaseImagePullRequiresAuthentication.value) {
168+
// if using default base image and requires authentication, do build-tool login to Docker Hub.
169+
const loginConfig = {
170+
requiresLogin: this.project.image.auxDefaultBaseImagePullRequiresAuthentication.value,
171+
username: this.project.image.auxDefaultBaseImagePullUsername.value,
172+
password: this.project.image.auxDefaultBaseImagePullPassword.value
173+
};
174+
if (! await this.loginToImageRegistry(imageBuilderExe, loginConfig, errTitle, errPrefix)) {
175+
return Promise.resolve(false);
176+
}
165177
}
166178

167179
// run the image tool
@@ -202,6 +214,7 @@ function (WitActionsBase, project, wktConsole, wdtModelPreparer, i18n, projectIo
202214

203215
validationObject.addField('image-design-aux-image-tag-label',
204216
this.project.image.auxImageTag.validate(true), imageFormConfig);
217+
205218
if (!this.project.image.useLatestWdtVersion.value) {
206219
validationObject.addField('image-design-wdt-installer-label',
207220
validationHelper.validateRequiredField(this.project.image.wdtInstaller.value), imageFormConfig);
@@ -220,6 +233,13 @@ function (WitActionsBase, project, wktConsole, wdtModelPreparer, i18n, projectIo
220233
validationObject.addField('image-design-aux-base-image-pull-password-label',
221234
validationHelper.validateRequiredField(this.project.image.auxBaseImagePullPassword.value), imageFormConfig);
222235
}
236+
} else if (this.project.image.auxDefaultBaseImagePullRequiresAuthentication.value) {
237+
validationObject.addField('image-design-aux-default-base-image-pull-username-label',
238+
validationHelper.validateRequiredField(this.project.image.auxDefaultBaseImagePullUsername.value),
239+
imageFormConfig);
240+
validationObject.addField('image-design-aux-default-base-image-pull-password-label',
241+
validationHelper.validateRequiredField(this.project.image.auxDefaultBaseImagePullPassword.value),
242+
imageFormConfig);
223243
}
224244
return validationObject;
225245
}

webui/src/js/utils/wkt-actions-base.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ function(project, wktConsole, i18n, projectIo, dialogHelper) {
416416

417417
_closeBusyDialog(shouldCloseBusyDialog) {
418418
if (shouldCloseBusyDialog) {
419-
dialogHelper._closeBusyDialog();
419+
dialogHelper.closeBusyDialog();
420420
}
421421
}
422422
}

webui/src/js/views/image-design-view.html

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,30 @@ <h6 slot="header" class="wkt-subheading"><oj-bind-text value="[[labelMapper('aux
379379
readonly="true"
380380
help.instruction="[[labelMapper('aux-image-registry-address-help')]]">
381381
</oj-input-text>
382+
<oj-bind-if test="[[project.image.auxUseCustomBaseImage.observable() === false]]">
383+
<oj-switch label-hint="[[labelMapper('aux-default-base-image-use-authentication-label')]]"
384+
value="{{project.image.auxDefaultBaseImagePullRequiresAuthentication.observable}}"
385+
help.instruction="[[labelMapper('aux-default-base-image-use-authentication-help')]]">
386+
</oj-switch>
387+
</oj-bind-if>
388+
<div>
389+
<oj-bind-if test="[[project.image.auxUseCustomBaseImage.observable() === false &&
390+
project.image.auxDefaultBaseImagePullRequiresAuthentication.observable() == true]]">
391+
<oj-input-password label-hint="[[labelMapper('aux-default-base-image-pull-username-label')]]"
392+
mask-icon="visible"
393+
value="{{project.image.auxDefaultBaseImagePullUsername.observable}}"
394+
help.instruction="[[labelMapper('aux-default-base-image-pull-username-help')]]">
395+
</oj-input-password>
396+
</oj-bind-if>
397+
<oj-bind-if test="[[project.image.auxUseCustomBaseImage.observable() === false &&
398+
project.image.auxDefaultBaseImagePullRequiresAuthentication.observable() == true]]">
399+
<oj-input-password label-hint="[[labelMapper('aux-default-base-image-pull-password-label')]]"
400+
mask-icon="visible"
401+
value="{{project.image.auxDefaultBaseImagePullPassword.observable}}"
402+
help.instruction="[[labelMapper('aux-default-base-image-pull-password-help')]]">
403+
</oj-input-password>
404+
</oj-bind-if>
405+
</div>
382406
</oj-form-layout>
383407

384408
<oj-bind-if test="[[isBuildingAuxImage() === true]]">

0 commit comments

Comments
 (0)