mirror of https://github.com/rancher/ui.git
AKS use existing cloud cred
This commit is contained in:
parent
2c930af33b
commit
8af68ca25b
|
|
@ -175,7 +175,8 @@ export default Component.extend(ClusterDriver, {
|
|||
},
|
||||
async loadRegions(cb) {
|
||||
const store = get(this, 'globalStore')
|
||||
const { selectedCloudCredential, regionsWithAZs } = this;
|
||||
const selectedCloudCredential = this.selectedCloudCredential;
|
||||
const regionsWithAZs = this.regionsWithAZs
|
||||
const data = {
|
||||
cloudCredentialId: get(selectedCloudCredential, 'id'),
|
||||
// tenantId: get(this, 'config.tenantId'),
|
||||
|
|
@ -218,9 +219,11 @@ export default Component.extend(ClusterDriver, {
|
|||
})
|
||||
}
|
||||
} catch (error) {
|
||||
cb(false, error);
|
||||
this.send('errorHandler', error);
|
||||
cb(false);
|
||||
}
|
||||
},
|
||||
|
||||
authenticate(cb) {
|
||||
const store = get(this, 'globalStore')
|
||||
const { selectedCloudCredential } = this;
|
||||
|
|
@ -469,10 +472,8 @@ export default Component.extend(ClusterDriver, {
|
|||
return this.mode === 'edit' && !this.hasProvisioned;
|
||||
}),
|
||||
|
||||
cloudCredentials: computed('model.cloudCredentials', function() {
|
||||
const { model: { cloudCredentials } } = this;
|
||||
|
||||
return cloudCredentials.filter((cc) => {
|
||||
cloudCredentials: computed('config.azureCredentialSecret', 'model.cloudCredentials', function() {
|
||||
const out = this.model.cloudCredentials.filter((cc) => {
|
||||
const isAzure = Object.prototype.hasOwnProperty.call(cc, 'azurecredentialConfig');
|
||||
|
||||
if (isAzure) {
|
||||
|
|
@ -481,18 +482,36 @@ export default Component.extend(ClusterDriver, {
|
|||
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
let cur = this.config?.azureCredentialSecret;
|
||||
|
||||
if ( cur && !cur.startsWith('cattle-global-data:') ) {
|
||||
cur = `cattle-global-data:${ cur }`;
|
||||
}
|
||||
|
||||
if ( cur && !out.find((x) => x.id === cur ) ) {
|
||||
const obj = this.globalStore.createRecord({
|
||||
name: `${ cur.replace(/^cattle-global-data:/, '') } (current)`,
|
||||
id: cur,
|
||||
type: 'cloudCredential',
|
||||
azurecredentialConfig: {},
|
||||
});
|
||||
|
||||
out.push(obj);
|
||||
}
|
||||
|
||||
return out;
|
||||
}),
|
||||
|
||||
selectedCloudCredential: computed('config.azureCredentialSecret', function() {
|
||||
const {
|
||||
model: { cloudCredentials = [] },
|
||||
config: { azureCredentialSecret }
|
||||
} = this;
|
||||
selectedCloudCredential: computed('cloudCredentials.@each.id', 'config.azureCredentialSecret', function() {
|
||||
const cur = this.config?.azureCredentialSecret;
|
||||
const cloudCredentials = this.cloudCredentials;
|
||||
|
||||
if (isEmpty(cloudCredentials) && isEmpty(azureCredentialSecret)) {
|
||||
if (isEmpty(cloudCredentials) && isEmpty(cur)) {
|
||||
return null;
|
||||
} else {
|
||||
return cloudCredentials.findBy('id', azureCredentialSecret.includes('cattle-global-data:') ? azureCredentialSecret : `cattle-global-data:${ azureCredentialSecret }`);
|
||||
return cloudCredentials.findBy('id', cur.includes('cattle-global-data:') ? cur : `cattle-global-data:${ cur }`);
|
||||
}
|
||||
}),
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue