mirror of https://github.com/rancher/ui.git
update gke proxy calls to send cluster id if editing
This commit is contained in:
parent
caa794ec1f
commit
727b160b13
|
|
@ -151,10 +151,8 @@ export default Component.extend(ClusterDriver, {
|
||||||
loadZones(cb = () => {}) {
|
loadZones(cb = () => {}) {
|
||||||
set(this, 'errors', []);
|
set(this, 'errors', []);
|
||||||
|
|
||||||
const config = get(this, `cluster.${ this.configField }`);
|
|
||||||
|
|
||||||
return all([
|
return all([
|
||||||
this.google.fetchZones(config, this.saved),
|
this.google.fetchZones(this.cluster, this.saved),
|
||||||
]).then((resp) => {
|
]).then((resp) => {
|
||||||
const [zones] = resp;
|
const [zones] = resp;
|
||||||
|
|
||||||
|
|
@ -186,16 +184,16 @@ export default Component.extend(ClusterDriver, {
|
||||||
|
|
||||||
const config = get(this, `cluster.${ this.configField }`);
|
const config = get(this, `cluster.${ this.configField }`);
|
||||||
const promises = [
|
const promises = [
|
||||||
this.google.fetchVersions(config, this.saved),
|
this.google.fetchVersions(this.cluster, this.saved),
|
||||||
this.google.fetchMachineTypes(config, this.saved),
|
this.google.fetchMachineTypes(this.cluster, this.saved),
|
||||||
this.google.fetchNetworks(config, this.saved),
|
this.google.fetchNetworks(this.cluster, this.saved),
|
||||||
this.google.fetchSubnetworks(config, get(this, 'locationType'), this.saved),
|
this.google.fetchSubnetworks(this.cluster, get(this, 'locationType'), this.saved),
|
||||||
this.google.fetchSharedSubnets(config, this.saved),
|
this.google.fetchSharedSubnets(this.cluster, this.saved),
|
||||||
this.google.fetchServiceAccounts(config, this.saved),
|
this.google.fetchServiceAccounts(this.cluster, this.saved),
|
||||||
];
|
];
|
||||||
|
|
||||||
if (this.editing) {
|
if (this.editing) {
|
||||||
promises.push(this.google.fetchClusters(config, this.saved));
|
promises.push(this.google.fetchClusters(this.cluster, this.saved));
|
||||||
}
|
}
|
||||||
|
|
||||||
return all(promises).then((resp) => {
|
return all(promises).then((resp) => {
|
||||||
|
|
|
||||||
|
|
@ -84,10 +84,8 @@ export default Component.extend(ClusterDriver, {
|
||||||
checkServiceAccount(cb) {
|
checkServiceAccount(cb) {
|
||||||
set(this, 'errors', []);
|
set(this, 'errors', []);
|
||||||
|
|
||||||
const config = get(this, `cluster.${ this.configField }`);
|
|
||||||
|
|
||||||
return all([
|
return all([
|
||||||
this.google.fetchZones(config, this.saved),
|
this.google.fetchZones(this.model.cluster, this.saved),
|
||||||
]).then((resp) => {
|
]).then((resp) => {
|
||||||
const [zones] = resp;
|
const [zones] = resp;
|
||||||
|
|
||||||
|
|
@ -116,9 +114,7 @@ export default Component.extend(ClusterDriver, {
|
||||||
set(this, 'loadingClusters', true);
|
set(this, 'loadingClusters', true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const config = get(this, `cluster.${ this.configField }`);
|
allClusters = await this.google.fetchClusters(this.cluster, this.saved ?? false);
|
||||||
|
|
||||||
allClusters = await this.google.fetchClusters(config, this.saved ?? false);
|
|
||||||
|
|
||||||
setProperties(this, {
|
setProperties(this, {
|
||||||
allClusters: (allClusters || []).map((c) => {
|
allClusters: (allClusters || []).map((c) => {
|
||||||
|
|
|
||||||
|
|
@ -267,7 +267,7 @@ export default Service.extend({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
parseRequestData(url, config) {
|
parseRequestData(url, config, clusterId) {
|
||||||
const {
|
const {
|
||||||
googleCredentialSecret,
|
googleCredentialSecret,
|
||||||
projectID: projectId,
|
projectID: projectId,
|
||||||
|
|
@ -288,17 +288,22 @@ export default Service.extend({
|
||||||
if (!isEmpty(projectId)) {
|
if (!isEmpty(projectId)) {
|
||||||
set(data, 'projectId', projectId);
|
set(data, 'projectId', projectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isEmpty(clusterId)) {
|
||||||
|
set(data, 'clusterID', clusterId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return addQueryParams(url, data);
|
return addQueryParams(url, data);
|
||||||
},
|
},
|
||||||
|
|
||||||
async fetchClusters(config, saved = false) {
|
async fetchClusters(cluster, saved = false) {
|
||||||
if (saved) {
|
if (saved) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const config = get(cluster, 'gkeConfig');
|
||||||
|
|
||||||
let neuURL = this.parseRequestData('/meta/gkeClusters', config);
|
let neuURL = this.parseRequestData('/meta/gkeClusters', config, cluster?.id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const xhr = await this.request(neuURL, 'GET');
|
const xhr = await this.request(neuURL, 'GET');
|
||||||
|
|
@ -310,12 +315,13 @@ export default Service.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async fetchZones(config, saved = false) {
|
async fetchZones(cluster, saved = false) {
|
||||||
if (saved) {
|
if (saved) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const config = get(cluster, 'gkeConfig');
|
||||||
|
|
||||||
const neuURL = this.parseRequestData('/meta/gkeZones', config);
|
const neuURL = this.parseRequestData('/meta/gkeZones', config, cluster?.id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const xhr = await this.request(neuURL, 'GET');
|
const xhr = await this.request(neuURL, 'GET');
|
||||||
|
|
@ -336,10 +342,11 @@ export default Service.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async fetchVersions(config, saved = false) {
|
async fetchVersions(cluster, saved = false) {
|
||||||
if (saved) {
|
if (saved) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const config = get(cluster, 'gkeConfig');
|
||||||
|
|
||||||
const zone = get(config, 'zone') || `${ get(config, 'region') }-b`;
|
const zone = get(config, 'zone') || `${ get(config, 'region') }-b`;
|
||||||
const neuConfig = { ...config };
|
const neuConfig = { ...config };
|
||||||
|
|
@ -348,7 +355,7 @@ export default Service.extend({
|
||||||
|
|
||||||
set(neuConfig, 'zone', zone);
|
set(neuConfig, 'zone', zone);
|
||||||
|
|
||||||
const neuURL = this.parseRequestData('/meta/gkeVersions', neuConfig);
|
const neuURL = this.parseRequestData('/meta/gkeVersions', neuConfig, cluster?.id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const xhr = await this.request(neuURL, 'GET');
|
const xhr = await this.request(neuURL, 'GET');
|
||||||
|
|
@ -360,10 +367,11 @@ export default Service.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async fetchMachineTypes(config, saved = false) {
|
async fetchMachineTypes(cluster, saved = false) {
|
||||||
if (saved) {
|
if (saved) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const config = get(cluster, 'gkeConfig');
|
||||||
|
|
||||||
const zone = get(config, 'zone') || `${ get(config, 'region') }-b`;
|
const zone = get(config, 'zone') || `${ get(config, 'region') }-b`;
|
||||||
const neuConfig = { ...config };
|
const neuConfig = { ...config };
|
||||||
|
|
@ -372,7 +380,7 @@ export default Service.extend({
|
||||||
|
|
||||||
set(neuConfig, 'zone', zone);
|
set(neuConfig, 'zone', zone);
|
||||||
|
|
||||||
const neuURL = this.parseRequestData('/meta/gkeMachineTypes', neuConfig);
|
const neuURL = this.parseRequestData('/meta/gkeMachineTypes', neuConfig, cluster?.id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const xhr = await this.request(neuURL, 'GET');
|
const xhr = await this.request(neuURL, 'GET');
|
||||||
|
|
@ -384,10 +392,11 @@ export default Service.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async fetchNetworks(config, saved = false) {
|
async fetchNetworks(cluster, saved = false) {
|
||||||
if (saved) {
|
if (saved) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const config = get(cluster, 'gkeConfig');
|
||||||
|
|
||||||
const zone = get(config, 'zone') || `${ get(config, 'region') }-b`;
|
const zone = get(config, 'zone') || `${ get(config, 'region') }-b`;
|
||||||
const neuConfig = { ...config };
|
const neuConfig = { ...config };
|
||||||
|
|
@ -396,7 +405,7 @@ export default Service.extend({
|
||||||
|
|
||||||
set(neuConfig, 'zone', zone);
|
set(neuConfig, 'zone', zone);
|
||||||
|
|
||||||
const neuURL = this.parseRequestData('/meta/gkeNetworks', neuConfig);
|
const neuURL = this.parseRequestData('/meta/gkeNetworks', neuConfig, cluster?.id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const xhr = await this.request(neuURL, 'GET');
|
const xhr = await this.request(neuURL, 'GET');
|
||||||
|
|
@ -408,10 +417,11 @@ export default Service.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async fetchSubnetworks(config, locationType, saved = false) {
|
async fetchSubnetworks(cluster, locationType, saved = false) {
|
||||||
if (saved) {
|
if (saved) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const config = get(cluster, 'gkeConfig');
|
||||||
const region = locationType === this.defaultZoneType ? `${ config.zone.split('-')[0] }-${ config.zone.split('-')[1] }` : config.region;
|
const region = locationType === this.defaultZoneType ? `${ config.zone.split('-')[0] }-${ config.zone.split('-')[1] }` : config.region;
|
||||||
const neuConfig = { ...config };
|
const neuConfig = { ...config };
|
||||||
|
|
||||||
|
|
@ -419,7 +429,7 @@ export default Service.extend({
|
||||||
|
|
||||||
set(neuConfig, 'region', region);
|
set(neuConfig, 'region', region);
|
||||||
|
|
||||||
const neuURL = this.parseRequestData('/meta/gkeSubnetworks', neuConfig);
|
const neuURL = this.parseRequestData('/meta/gkeSubnetworks', neuConfig, cluster?.id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const xhr = await this.request(neuURL, 'GET');
|
const xhr = await this.request(neuURL, 'GET');
|
||||||
|
|
@ -431,16 +441,17 @@ export default Service.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async fetchSharedSubnets(config, saved = false) {
|
async fetchSharedSubnets(cluster, saved = false) {
|
||||||
if (saved) {
|
if (saved) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const config = get(cluster, 'gkeConfig');
|
||||||
const neuConfig = { ...config };
|
const neuConfig = { ...config };
|
||||||
|
|
||||||
delete neuConfig?.zone;
|
delete neuConfig?.zone;
|
||||||
delete neuConfig?.region;
|
delete neuConfig?.region;
|
||||||
|
|
||||||
const neuURL = this.parseRequestData('/meta/gkeSharedSubnets', neuConfig);
|
const neuURL = this.parseRequestData('/meta/gkeSharedSubnets', neuConfig, cluster?.id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const xhr = await this.request(neuURL, 'GET');
|
const xhr = await this.request(neuURL, 'GET');
|
||||||
|
|
@ -471,10 +482,11 @@ export default Service.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async fetchServiceAccounts(config, saved = false) {
|
async fetchServiceAccounts(cluster, saved = false) {
|
||||||
if (saved) {
|
if (saved) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const config = get(cluster, 'gkeConfig');
|
||||||
const zone = get(config, 'zone') || `${ get(config, 'region') }-b`;
|
const zone = get(config, 'zone') || `${ get(config, 'region') }-b`;
|
||||||
const neuConfig = { ...config };
|
const neuConfig = { ...config };
|
||||||
|
|
||||||
|
|
@ -482,7 +494,7 @@ export default Service.extend({
|
||||||
|
|
||||||
set(neuConfig, 'zone', zone);
|
set(neuConfig, 'zone', zone);
|
||||||
|
|
||||||
const neuURL = this.parseRequestData('/meta/gkeServiceAccounts', neuConfig);
|
const neuURL = this.parseRequestData('/meta/gkeServiceAccounts', neuConfig, cluster?.id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const xhr = await this.request(neuURL, 'GET');
|
const xhr = await this.request(neuURL, 'GET');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue