Merge pull request #4723 from WuJun2016/harvester-rke1

fix: add cluster driver filter when create a cloud credential
This commit is contained in:
codyrancher 2021-08-02 14:43:29 -07:00 committed by GitHub
commit 9094ae1f45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 54 additions and 40 deletions

View File

@ -17,12 +17,14 @@ const CRED_CONFIG_CHOICES = [
displayName: 'Amazon',
driver: 'amazonec2',
configField: 'amazonec2credentialConfig',
kontainerDriverId: 'amazonelasticcontainerservice'
},
{
name: 'azure',
displayName: 'Azure',
driver: 'azure',
configField: 'azurecredentialConfig',
kontainerDriverId: 'azurekubernetesservice'
},
{
name: 'digitalOcean',
@ -35,6 +37,7 @@ const CRED_CONFIG_CHOICES = [
displayName: 'Google',
driver: 'google',
configField: 'googlecredentialConfig',
kontainerDriverId: 'googlekubernetesengine'
},
{
name: 'harvester',
@ -47,6 +50,7 @@ const CRED_CONFIG_CHOICES = [
displayName: 'Linode',
driver: 'linode',
configField: 'linodecredentialConfig',
kontainerDriverId: 'linodekubernetesengine'
},
{
name: 'oci',
@ -95,11 +99,12 @@ export default Component.extend(ViewNewEdit, {
gkeProjectId: null,
clusters: null,
allNodeDrivers: null,
allKontainerDrivers: null,
init() {
this._super(...arguments);
let cloudCredentialType = 'amazon';
let cloudCredentialType = '';
let model = null;
const driverName = get(this, 'driverName') === 'aks' ? 'azure' : get(this, 'driverName');
@ -122,6 +127,7 @@ export default Component.extend(ViewNewEdit, {
}
this.feetchNodeDriver();
this.feetchKontainerDriver();
if (driverName === 'harvester' || cloudCredentialType === 'harvester') {
this.fetchCluster();
@ -197,7 +203,7 @@ export default Component.extend(ViewNewEdit, {
return get(model, configField);
}),
configChoices: computed('driverName', 'allNodeDrivers', function() {
configChoices: computed('driverName', 'allNodeDrivers', 'allKontainerDrivers', function() {
if (get(this, 'driverName')) {
// const { driverName } = this;
const driverName = get(this, 'driverName') === 'aks' ? 'azure' : get(this, 'driverName');
@ -214,9 +220,11 @@ export default Component.extend(ViewNewEdit, {
return [match];
} else {
if (get(this, 'allNodeDrivers')) {
if (get(this, 'allNodeDrivers') && get(this, 'allKontainerDrivers')) {
return (CRED_CONFIG_CHOICES.filter((N) => {
return (get(this, 'allNodeDrivers') || []).find((O) => O.id === N.driver && O.active === true) ? true : false;
const isActive = (get(this, 'allNodeDrivers') || []).find((O) => O.id === N.driver && O.active === true) || (get(this, 'allKontainerDrivers') || []).find((O) => O.id === N.kontainerDriverId && O.active === true);
return isActive ? true : false;
})).sortBy('displayName');
} else {
return CRED_CONFIG_CHOICES.sortBy('displayName');
@ -464,6 +472,12 @@ export default Component.extend(ViewNewEdit, {
});
},
feetchKontainerDriver() {
get(this, 'globalStore').findAll('kontainerDriver').then((allKontainerDrivers) => {
set(this, 'allKontainerDrivers', allKontainerDrivers);
});
},
fetchZones() {
let credentials = null;
let config = null;