Skip to content

Commit

Permalink
fix(region) enable access to all regions in Alibaba Cloud
Browse files Browse the repository at this point in the history
  • Loading branch information
smallteeths committed Jan 20, 2025
1 parent b4ad0ae commit 63b493b
Showing 1 changed file with 8 additions and 88 deletions.
96 changes: 8 additions & 88 deletions component/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,74 +107,6 @@ const CLUSTER_TYPES = [
}
];

const REGIONS = [
{
label: 'cn-beijing',
value: 'cn-beijing',
managed: true,
}, {
label: 'cn-zhangjiakou',
value: 'cn-zhangjiakou'
}, {
label: 'cn-huhehaote',
value: 'cn-huhehaote'
}, {
label: 'cn-hangzhou',
value: 'cn-hangzhou',
managed: true,
}, {
label: 'cn-shanghai',
value: 'cn-shanghai',
managed: true,
}, {
label: 'cn-shenzhen',
value: 'cn-shenzhen'
}, {
label: 'cn-chengdu',
value: 'cn-chengdu'
}, {
label: 'cn-hongkong',
value: 'cn-hongkong'
}, {
label: 'ap-northeast-1',
value: 'ap-northeast-1'
}, {
label: 'ap-south-1',
value: 'ap-south-1',
managed: true,
}, {
label: 'ap-southeast-1',
value: 'ap-southeast-1',
managed: true,
}, {
label: 'ap-southeast-2',
value: 'ap-southeast-2'
}, {
label: 'ap-southeast-3',
value: 'ap-southeast-3',
managed: true,
}, {
label: 'ap-southeast-5',
value: 'ap-southeast-5',
managed: true,
}, {
label: 'us-east-1',
value: 'us-east-1'
}, {
label: 'us-west-1',
value: 'us-west-1'
}, {
label: 'me-east-1',
value: 'me-east-1',
managed: false
}, {
label: 'eu-west-1',
value: 'eu-west-1'
}, {
label: 'eu-central-1',
value: 'eu-central-1'
}];

const NODECIDRMASKS = [
{
label: 16,
Expand Down Expand Up @@ -320,6 +252,7 @@ export default Ember.Component.extend(ClusterDriver, {
zoneChoices: [],
systemDiskChoices: [],
dataDiskChoices: [],
clusterTypeChoices: CLUSTER_TYPES,
proxyModeChoices: MODES,
resourceGroups: null,
storageDiskChoices: null,
Expand Down Expand Up @@ -376,7 +309,7 @@ export default Ember.Component.extend(ClusterDriver, {
accessKeyId: null,
accessKeySecret: null,
addons: [{ name: 'flannel' }],
clusterType: KUBERNETES,
clusterType: MANAGED,
containerCidr: '172.20.0.0/16',
kubernetesVersion: DEFAULT_KUBERNETES_VERSION,
proxyMode: 'ipvs',
Expand Down Expand Up @@ -982,16 +915,6 @@ export default Ember.Component.extend(ClusterDriver, {
return get(this, 'config.clusterType') === KUBERNETES ? 0 : 1;
}),

clusterTypeChoices: computed('config.regionId', 'zoneChoices', function() {
const region = REGIONS.findBy('value', get(this, 'config.regionId'));

if ( region && get(region, 'managed') !== false ) {
return CLUSTER_TYPES;
} else {
return CLUSTER_TYPES.filter((type) => get(type, 'value') !== MANAGED);
}
}),

masterInstanceChargeTypeChoices: computed('intl.locale', function() {
const intl = get(this, 'intl');

Expand Down Expand Up @@ -1079,7 +1002,7 @@ export default Ember.Component.extend(ClusterDriver, {
showRegion: computed('regionChoices', 'config.regionId', function() {
return this.getChoicesLabel(get(this, 'regionChoices'), get(this, 'config.regionId'))
}),
showClusterType: computed('clusterTypeChoices', 'config.clusterType', function() {
showClusterType: computed('config.clusterType', function() {
return this.getChoicesLabel(get(this, 'clusterTypeChoices'), get(this, 'config.clusterType'))
}),
showMasterInstanceChargeType: computed('masterInstanceChargeTypeChoices', 'config.masterInstanceChargeType', function() {
Expand Down Expand Up @@ -1222,20 +1145,17 @@ export default Ember.Component.extend(ClusterDriver, {
const regions = await this.fetch('Region', 'Regions');
const transformRegions = [];

REGIONS.forEach((regionTemp) => {
const found = regions.findBy('value', get(regionTemp, 'value'));

if (found) {
regions.forEach((regionTemp) => {
if (regionTemp?.raw?.LocalName) {
transformRegions.pushObject({
...regionTemp,
label: found.raw.LocalName
label: regionTemp.raw.LocalName
});
} else {
transformRegions.pushObject(regionTemp);
transformRegions.pushObject(regionTemp)
}

set(this, 'regionChoices', transformRegions);
});
set(this, 'regionChoices', transformRegions);
},

async fetchCluster() {
Expand Down

0 comments on commit 63b493b

Please sign in to comment.