mirror of https://github.com/rancher/ui.git
Merge pull request #4504 from westlywright/feature.gce.cloudcreds
Google Cloud Credentials
This commit is contained in:
commit
2effea7bbf
|
|
@ -18,21 +18,23 @@ const cloudCredential = Resource.extend({
|
||||||
isAmazon: notEmpty('amazonec2credentialConfig'),
|
isAmazon: notEmpty('amazonec2credentialConfig'),
|
||||||
isAzure: notEmpty('azurecredentialConfig'),
|
isAzure: notEmpty('azurecredentialConfig'),
|
||||||
isDo: notEmpty('digitaloceancredentialConfig'),
|
isDo: notEmpty('digitaloceancredentialConfig'),
|
||||||
|
isGoogle: notEmpty('googlecredentialConfig'),
|
||||||
isLinode: notEmpty('linodecredentialConfig'),
|
isLinode: notEmpty('linodecredentialConfig'),
|
||||||
isOCI: notEmpty('ocicredentialConfig'),
|
isOCI: notEmpty('ocicredentialConfig'),
|
||||||
isPNAP: notEmpty('pnapcredentialConfig'),
|
isPNAP: notEmpty('pnapcredentialConfig'),
|
||||||
isVMware: notEmpty('vmwarevspherecredentialConfig'),
|
isVMware: notEmpty('vmwarevspherecredentialConfig'),
|
||||||
|
|
||||||
|
|
||||||
displayType: computed('amazonec2credentialConfig', 'azurecredentialConfig', 'digitaloceancredentialConfig', 'linodecredentialConfig', 'ocicredentialConfig', 'pnapcredentialConfig', 'vmwarevspherecredentialConfig', function() {
|
displayType: computed('amazonec2credentialConfig', 'azurecredentialConfig', 'digitaloceancredentialConfig', 'googlecredentialConfig', 'linodecredentialConfig', 'ocicredentialConfig', 'pnapcredentialConfig', 'vmwarevspherecredentialConfig', function() {
|
||||||
const {
|
const {
|
||||||
isAmazon,
|
isAmazon,
|
||||||
isAzure,
|
isAzure,
|
||||||
isDo,
|
isDo,
|
||||||
|
isGoogle,
|
||||||
isLinode,
|
isLinode,
|
||||||
isOCI,
|
isOCI,
|
||||||
isPNAP,
|
isPNAP,
|
||||||
isVMware
|
isVMware,
|
||||||
} = this;
|
} = this;
|
||||||
|
|
||||||
if (isAmazon) {
|
if (isAmazon) {
|
||||||
|
|
@ -41,6 +43,8 @@ const cloudCredential = Resource.extend({
|
||||||
return 'Azure';
|
return 'Azure';
|
||||||
} else if (isDo) {
|
} else if (isDo) {
|
||||||
return 'Digital Ocean';
|
return 'Digital Ocean';
|
||||||
|
} else if (isGoogle) {
|
||||||
|
return 'Google';
|
||||||
} else if (isLinode) {
|
} else if (isLinode) {
|
||||||
return 'Linode';
|
return 'Linode';
|
||||||
} else if (isOCI) {
|
} else if (isOCI) {
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,18 @@ const CRED_CONFIG_CHOICES = [
|
||||||
driver: 'digitalocean',
|
driver: 'digitalocean',
|
||||||
configField: 'digitaloceancredentialConfig',
|
configField: 'digitaloceancredentialConfig',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'google',
|
||||||
|
displayName: 'Google',
|
||||||
|
driver: 'google',
|
||||||
|
configField: 'googlecredentialConfig',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'linode',
|
||||||
|
displayName: 'Linode',
|
||||||
|
driver: 'linode',
|
||||||
|
configField: 'linodecredentialConfig',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'oci',
|
name: 'oci',
|
||||||
displayName: 'OCI',
|
displayName: 'OCI',
|
||||||
|
|
@ -39,12 +51,6 @@ const CRED_CONFIG_CHOICES = [
|
||||||
driver: 'pnap',
|
driver: 'pnap',
|
||||||
configField: 'pnapcredentialConfig',
|
configField: 'pnapcredentialConfig',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: 'linode',
|
|
||||||
displayName: 'Linode',
|
|
||||||
driver: 'linode',
|
|
||||||
configField: 'linodecredentialConfig',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: 'vmware',
|
name: 'vmware',
|
||||||
displayName: 'VMware vSphere',
|
displayName: 'VMware vSphere',
|
||||||
|
|
@ -152,6 +158,7 @@ export default Component.extend(ViewNewEdit, {
|
||||||
case 'amazon':
|
case 'amazon':
|
||||||
case 'digitalOcean':
|
case 'digitalOcean':
|
||||||
case 'linode':
|
case 'linode':
|
||||||
|
case 'google':
|
||||||
return 'modalAddCloudKey.saving.validating';
|
return 'modalAddCloudKey.saving.validating';
|
||||||
case 'oci':
|
case 'oci':
|
||||||
case 'pnap':
|
case 'pnap':
|
||||||
|
|
@ -191,7 +198,7 @@ export default Component.extend(ViewNewEdit, {
|
||||||
}
|
}
|
||||||
|
|
||||||
const { cloudCredentialType } = this;
|
const { cloudCredentialType } = this;
|
||||||
const keysThatWeCanValidate = ['amazon', 'digitalOcean', 'linode', 'oci'];
|
const keysThatWeCanValidate = ['amazon', 'digitalOcean', 'linode', 'oci', 'google'];
|
||||||
const auth = {
|
const auth = {
|
||||||
type: 'validate',
|
type: 'validate',
|
||||||
token: null,
|
token: null,
|
||||||
|
|
@ -268,6 +275,16 @@ export default Component.extend(ViewNewEdit, {
|
||||||
return this.setError(`${ err.message }`);
|
return this.setError(`${ err.message }`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cloudCredentialType === 'google') {
|
||||||
|
return this.fetchZones().then(() => {
|
||||||
|
set(this, 'validatingKeys', false);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}).catch((err) => {
|
||||||
|
return this.setError(`${ err.message }`);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
set(this, 'validatingKeys', false);
|
set(this, 'validatingKeys', false);
|
||||||
|
|
@ -331,6 +348,24 @@ export default Component.extend(ViewNewEdit, {
|
||||||
|
|
||||||
parseAndCollectErrors() {
|
parseAndCollectErrors() {
|
||||||
throw new Error('parseAndCollectErrors action is required!');
|
throw new Error('parseAndCollectErrors action is required!');
|
||||||
}
|
},
|
||||||
|
|
||||||
|
fetchZones() {
|
||||||
|
const credentials = get(this, 'config.authEncodedJson');
|
||||||
|
const config = JSON.parse(credentials || '{}');
|
||||||
|
const { project_id: projectId } = config;
|
||||||
|
|
||||||
|
return get(this, 'globalStore').rawRequest({
|
||||||
|
url: '/meta/gkeZones',
|
||||||
|
method: 'POST',
|
||||||
|
data: {
|
||||||
|
credentials,
|
||||||
|
projectId,
|
||||||
|
}
|
||||||
|
}).then(() => {
|
||||||
|
return Promise.resolve();
|
||||||
|
}).catch((xhr) => {
|
||||||
|
return Promise.reject({ message: xhr?.body?.error });
|
||||||
|
});
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -145,11 +145,35 @@
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{{else if (eq cloudCredentialType "google")}}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col span-12">
|
||||||
|
{{#input-text-file
|
||||||
|
label="clusterNew.googlegke.credential.label"
|
||||||
|
value=config.authEncodedJson
|
||||||
|
accept="text/*, .json"
|
||||||
|
minHeight=60
|
||||||
|
canChangeName=false
|
||||||
|
nameRequired=true
|
||||||
|
placeholder="clusterNew.googlegke.credential.placeholder"
|
||||||
|
concealValue=true as |section|
|
||||||
|
}}
|
||||||
|
{{#if (eq section "description")}}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col span-12 wrap mb-0">
|
||||||
|
{{t "clusterNew.googlegke.credential.helpText" htmlSafe=true}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
{{/input-text-file}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{{else if (eq cloudCredentialType "linode")}}
|
{{else if (eq cloudCredentialType "linode")}}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col span-6">
|
<div class="col span-6">
|
||||||
<label class="acc-label" for="linode-token">
|
<label class="acc-label" for="linode-token">
|
||||||
{{t "modalAddCloudKey.linode.token.label"}}{{field-required}}
|
{{t "modalAddCloudKey.linode.token.label"}}
|
||||||
|
{{field-required}}
|
||||||
</label>
|
</label>
|
||||||
{{input
|
{{input
|
||||||
type="password"
|
type="password"
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,63 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
{{!-- <div class="col span-6 clip vertical-middle"> --}}
|
|
||||||
{{#if (and canChangeName shouldChangeName)}}
|
|
||||||
{{input value=name placeholder=(if namePlaceholder (t namePlaceholder) "")}}
|
|
||||||
{{else}}
|
|
||||||
<h4 class="mb-0 vertical-middle">
|
|
||||||
{{#if label}}
|
|
||||||
{{t label}}
|
|
||||||
{{else}}
|
|
||||||
{{name}}
|
|
||||||
{{/if}}
|
|
||||||
{{#if nameRequired}}{{field-required}}{{/if}}
|
|
||||||
{{#if canChangeName}}
|
|
||||||
<button class="btn btn-sm bg-link p-0 pl-10 acc-label-hover" type="button" {{action "wantsChange"}}>{{t "action.edit"}}</button>
|
|
||||||
{{/if}}
|
|
||||||
</h4>
|
|
||||||
{{/if}}
|
|
||||||
{{!-- </div> --}}
|
|
||||||
<div class="pull-right vertical-middle">
|
<div class="pull-right vertical-middle">
|
||||||
{{#if canUpload}}
|
{{#if canUpload}}
|
||||||
{{#if showUploadLabel}}
|
{{#if showUploadLabel}}
|
||||||
<button class="btn bg-link icon-btn" disabled={{disabled}} type="button" {{action "click"}}>
|
<button
|
||||||
<span class="darken"><i class="icon icon-upload text-small"/></span>
|
class="btn bg-link icon-btn"
|
||||||
<span>{{t "inputTextFile.tooltip"}}</span>
|
disabled={{disabled}}
|
||||||
|
type="button"
|
||||||
|
{{action "click"}}
|
||||||
|
>
|
||||||
|
<span class="darken">
|
||||||
|
<i class="icon icon-upload text-small"></i>
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
|
{{t "inputTextFile.tooltip"}}
|
||||||
|
</span>
|
||||||
</button>
|
</button>
|
||||||
{{else}}
|
{{else}}
|
||||||
{{#tooltip-element type="tooltip-basic" model=(t "inputTextFile.tooltip") tooltipTemplate="tooltip-static" aria-describedby="tooltip-base" tooltipFor="inputTextFile"}}
|
{{#tooltip-element
|
||||||
<button type="button" class="btn bg-link" {{action "click"}}><i class="icon icon-upload"></i></button>
|
type="tooltip-basic"
|
||||||
|
model=(t "inputTextFile.tooltip")
|
||||||
|
tooltipTemplate="tooltip-static"
|
||||||
|
aria-describedby="tooltip-base"
|
||||||
|
tooltipFor="inputTextFile"
|
||||||
|
}}
|
||||||
|
<button type="button" class="btn bg-link" {{action "click"}}>
|
||||||
|
<i class="icon icon-upload"></i>
|
||||||
|
</button>
|
||||||
{{/tooltip-element}}
|
{{/tooltip-element}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{yield}}
|
{{yield}}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col span-6 clip vertical-middle mt-5 mb-5">
|
||||||
|
{{#if (and canChangeName shouldChangeName)}}
|
||||||
|
{{input value=name placeholder=(if namePlaceholder (t namePlaceholder) "")}}
|
||||||
|
{{else}}
|
||||||
|
<h4 class="mb-0">
|
||||||
|
{{#if label}}
|
||||||
|
{{t label}}
|
||||||
|
{{else}}
|
||||||
|
{{name}}
|
||||||
|
{{/if}}
|
||||||
|
{{#if nameRequired}}
|
||||||
|
{{field-required}}
|
||||||
|
{{/if}}
|
||||||
|
{{#if canChangeName}}
|
||||||
|
<button
|
||||||
|
class="btn btn-sm bg-link acc-label-hover"
|
||||||
|
type="button"
|
||||||
|
{{action "wantsChange"}}
|
||||||
|
>
|
||||||
|
{{t "action.edit"}}
|
||||||
|
</button>
|
||||||
|
{{/if}}
|
||||||
|
</h4>
|
||||||
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
<hr/>
|
</div>
|
||||||
|
<hr class="mt-10 mb-10"/>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col span-12 m-0 p-0">
|
<div class="col span-12 m-0 p-0">
|
||||||
{{textarea-autogrow
|
{{textarea-autogrow
|
||||||
|
|
@ -47,4 +72,9 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{yield "description"}}
|
{{yield "description"}}
|
||||||
<input type="file" accept="{{actualAccept}}" multiple={{multiple}} class="hide">
|
<input
|
||||||
|
type="file"
|
||||||
|
accept="{{actualAccept}}"
|
||||||
|
multiple={{multiple}}
|
||||||
|
class="hide"
|
||||||
|
/>
|
||||||
Loading…
Reference in New Issue