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'),
|
||||
isAzure: notEmpty('azurecredentialConfig'),
|
||||
isDo: notEmpty('digitaloceancredentialConfig'),
|
||||
isGoogle: notEmpty('googlecredentialConfig'),
|
||||
isLinode: notEmpty('linodecredentialConfig'),
|
||||
isOCI: notEmpty('ocicredentialConfig'),
|
||||
isPNAP: notEmpty('pnapcredentialConfig'),
|
||||
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 {
|
||||
isAmazon,
|
||||
isAzure,
|
||||
isDo,
|
||||
isGoogle,
|
||||
isLinode,
|
||||
isOCI,
|
||||
isPNAP,
|
||||
isVMware
|
||||
isVMware,
|
||||
} = this;
|
||||
|
||||
if (isAmazon) {
|
||||
|
|
@ -41,6 +43,8 @@ const cloudCredential = Resource.extend({
|
|||
return 'Azure';
|
||||
} else if (isDo) {
|
||||
return 'Digital Ocean';
|
||||
} else if (isGoogle) {
|
||||
return 'Google';
|
||||
} else if (isLinode) {
|
||||
return 'Linode';
|
||||
} else if (isOCI) {
|
||||
|
|
|
|||
|
|
@ -27,6 +27,18 @@ const CRED_CONFIG_CHOICES = [
|
|||
driver: 'digitalocean',
|
||||
configField: 'digitaloceancredentialConfig',
|
||||
},
|
||||
{
|
||||
name: 'google',
|
||||
displayName: 'Google',
|
||||
driver: 'google',
|
||||
configField: 'googlecredentialConfig',
|
||||
},
|
||||
{
|
||||
name: 'linode',
|
||||
displayName: 'Linode',
|
||||
driver: 'linode',
|
||||
configField: 'linodecredentialConfig',
|
||||
},
|
||||
{
|
||||
name: 'oci',
|
||||
displayName: 'OCI',
|
||||
|
|
@ -39,12 +51,6 @@ const CRED_CONFIG_CHOICES = [
|
|||
driver: 'pnap',
|
||||
configField: 'pnapcredentialConfig',
|
||||
},
|
||||
{
|
||||
name: 'linode',
|
||||
displayName: 'Linode',
|
||||
driver: 'linode',
|
||||
configField: 'linodecredentialConfig',
|
||||
},
|
||||
{
|
||||
name: 'vmware',
|
||||
displayName: 'VMware vSphere',
|
||||
|
|
@ -152,6 +158,7 @@ export default Component.extend(ViewNewEdit, {
|
|||
case 'amazon':
|
||||
case 'digitalOcean':
|
||||
case 'linode':
|
||||
case 'google':
|
||||
return 'modalAddCloudKey.saving.validating';
|
||||
case 'oci':
|
||||
case 'pnap':
|
||||
|
|
@ -191,7 +198,7 @@ export default Component.extend(ViewNewEdit, {
|
|||
}
|
||||
|
||||
const { cloudCredentialType } = this;
|
||||
const keysThatWeCanValidate = ['amazon', 'digitalOcean', 'linode', 'oci'];
|
||||
const keysThatWeCanValidate = ['amazon', 'digitalOcean', 'linode', 'oci', 'google'];
|
||||
const auth = {
|
||||
type: 'validate',
|
||||
token: null,
|
||||
|
|
@ -268,6 +275,16 @@ export default Component.extend(ViewNewEdit, {
|
|||
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);
|
||||
|
|
@ -331,6 +348,24 @@ export default Component.extend(ViewNewEdit, {
|
|||
|
||||
parseAndCollectErrors() {
|
||||
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>
|
||||
</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")}}
|
||||
<div class="row">
|
||||
<div class="col span-6">
|
||||
<label class="acc-label" for="linode-token">
|
||||
{{t "modalAddCloudKey.linode.token.label"}}{{field-required}}
|
||||
{{t "modalAddCloudKey.linode.token.label"}}
|
||||
{{field-required}}
|
||||
</label>
|
||||
{{input
|
||||
type="password"
|
||||
|
|
|
|||
|
|
@ -1,38 +1,63 @@
|
|||
<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">
|
||||
{{#if canUpload}}
|
||||
{{#if showUploadLabel}}
|
||||
<button class="btn bg-link icon-btn" disabled={{disabled}} type="button" {{action "click"}}>
|
||||
<span class="darken"><i class="icon icon-upload text-small"/></span>
|
||||
<span>{{t "inputTextFile.tooltip"}}</span>
|
||||
<button
|
||||
class="btn bg-link icon-btn"
|
||||
disabled={{disabled}}
|
||||
type="button"
|
||||
{{action "click"}}
|
||||
>
|
||||
<span class="darken">
|
||||
<i class="icon icon-upload text-small"></i>
|
||||
</span>
|
||||
<span>
|
||||
{{t "inputTextFile.tooltip"}}
|
||||
</span>
|
||||
</button>
|
||||
{{else}}
|
||||
{{#tooltip-element 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
|
||||
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}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{yield}}
|
||||
</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>
|
||||
<hr/>
|
||||
</div>
|
||||
<hr class="mt-10 mb-10"/>
|
||||
<div class="row">
|
||||
<div class="col span-12 m-0 p-0">
|
||||
{{textarea-autogrow
|
||||
|
|
@ -47,4 +72,9 @@
|
|||
</div>
|
||||
</div>
|
||||
{{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