mirror of https://github.com/rancher/ui.git
Merge pull request #4791 from catherineluse/app-upgrade
Use currentVersion parameter to upgrade legacy apps
This commit is contained in:
commit
b17134067b
|
|
@ -21,18 +21,29 @@ export default Route.extend({
|
||||||
model(params, transition) {
|
model(params, transition) {
|
||||||
const { store, clusterStore } = this;
|
const { store, clusterStore } = this;
|
||||||
|
|
||||||
const dependencies = {
|
let dependencies = { namespaces: clusterStore.findAll('namespace') };
|
||||||
tpl: get(this, 'catalog').fetchTemplate(params.template),
|
|
||||||
namespaces: clusterStore.findAll('namespace')
|
|
||||||
};
|
|
||||||
|
|
||||||
if ( params.upgrade ) {
|
|
||||||
dependencies.upgrade = get(this, 'catalog').fetchTemplate(`${ params.template }-${ params.upgrade }`, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (params.appId) {
|
if (params.appId) {
|
||||||
dependencies.app = store.find('app', params.appId);
|
dependencies.app = store.find('app', params.appId);
|
||||||
|
dependencies.app.then((appData) => {
|
||||||
|
const getCurrentVersion = (app) => {
|
||||||
|
const externalId = app.externalId;
|
||||||
|
const splitId = externalId.split('version=')
|
||||||
|
const currentVersion = splitId[1];
|
||||||
|
|
||||||
|
return currentVersion;
|
||||||
}
|
}
|
||||||
|
const currentVersion = getCurrentVersion(appData);
|
||||||
|
|
||||||
|
dependencies.upgrade = get(this, 'catalog').fetchTemplate(`${ params.template }-${ params.upgrade }`, true, currentVersion);
|
||||||
|
dependencies.tpl = get(this, 'catalog').fetchTemplate(params.template, false, currentVersion);
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
throw new Error(err);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (params.appName) {
|
if (params.appName) {
|
||||||
dependencies.app = store.find('app', null, { filter: { name: params.appName } }).then((apps) => get(apps, 'firstObject'));
|
dependencies.app = store.find('app', null, { filter: { name: params.appName } }).then((apps) => get(apps, 'firstObject'));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -216,6 +216,7 @@ const App = Resource.extend(StateCounts, EndpointPorts, {
|
||||||
const catalogId = get(this, 'externalIdInfo.catalog');
|
const catalogId = get(this, 'externalIdInfo.catalog');
|
||||||
const vKeys = Object.keys(get(this, 'catalogTemplate.versionLinks'));
|
const vKeys = Object.keys(get(this, 'catalogTemplate.versionLinks'));
|
||||||
const latestVersion = vKeys[vKeys.length - 1];
|
const latestVersion = vKeys[vKeys.length - 1];
|
||||||
|
const currentVersion = get(this, 'externalIdInfo.version')
|
||||||
|
|
||||||
get(this, 'router').transitionTo('catalog-tab.launch', templateId, {
|
get(this, 'router').transitionTo('catalog-tab.launch', templateId, {
|
||||||
queryParams: {
|
queryParams: {
|
||||||
|
|
@ -223,7 +224,8 @@ const App = Resource.extend(StateCounts, EndpointPorts, {
|
||||||
catalog: catalogId,
|
catalog: catalogId,
|
||||||
namespaceId: get(this, 'targetNamespace'),
|
namespaceId: get(this, 'targetNamespace'),
|
||||||
upgrade: latestVersion,
|
upgrade: latestVersion,
|
||||||
istio: get(this, 'isIstio')
|
istio: get(this, 'isIstio'),
|
||||||
|
currentVersion
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ export default Service.extend({
|
||||||
let extInfo = parseHelmExternalId(app.get('externalId'));
|
let extInfo = parseHelmExternalId(app.get('externalId'));
|
||||||
|
|
||||||
if ( extInfo && extInfo.templateId ) {
|
if ( extInfo && extInfo.templateId ) {
|
||||||
deps.push(this.fetchTemplate(extInfo.templateId, false));
|
deps.push(this.fetchTemplate(extInfo.templateId, false, extInfo.version));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -81,7 +81,7 @@ export default Service.extend({
|
||||||
let extInfo = get(app, 'externalIdInfo');
|
let extInfo = get(app, 'externalIdInfo');
|
||||||
|
|
||||||
if ( extInfo && extInfo.templateId ) {
|
if ( extInfo && extInfo.templateId ) {
|
||||||
deps.push(this.fetchTemplate(extInfo.templateId, false));
|
deps.push(this.fetchTemplate(extInfo.templateId, false, extInfo.version));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -108,8 +108,9 @@ export default Service.extend({
|
||||||
return get(this, 'globalStore').getById('templateversion', id);
|
return get(this, 'globalStore').getById('templateversion', id);
|
||||||
},
|
},
|
||||||
|
|
||||||
fetchTemplate(id, upgrade = false) {
|
fetchTemplate(id, upgrade = false, currentVersion) {
|
||||||
let type, cached, params;
|
let type, cached, params;
|
||||||
|
const clusterName = get(this, 'scope.currentCluster.id');
|
||||||
|
|
||||||
if ( upgrade === true ) {
|
if ( upgrade === true ) {
|
||||||
type = 'templateversions';
|
type = 'templateversions';
|
||||||
|
|
@ -117,13 +118,24 @@ export default Service.extend({
|
||||||
} else {
|
} else {
|
||||||
type = 'templates';
|
type = 'templates';
|
||||||
// we cant check for cached here anylonger because the clusterName is used to build a dynamic versions list of compatible versions for this clusters kube version
|
// we cant check for cached here anylonger because the clusterName is used to build a dynamic versions list of compatible versions for this clusters kube version
|
||||||
params = { clusterName: get(this, 'scope.currentCluster.id') };
|
params = {
|
||||||
|
clusterName,
|
||||||
|
currentVersion
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( cached ) {
|
if ( cached ) {
|
||||||
return resolve(cached);
|
return resolve(cached);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
params = {
|
||||||
|
// currentVersion allows legacy apps to be upgraded
|
||||||
|
// after Rancher is upgraded to a version higher than the app's max
|
||||||
|
// supported Rancher version
|
||||||
|
clusterName,
|
||||||
|
currentVersion,
|
||||||
|
}
|
||||||
|
|
||||||
let url = this._addLimits(`${ get(this, 'app.apiEndpoint') }/${ type }/${ id }`, params);
|
let url = this._addLimits(`${ get(this, 'app.apiEndpoint') }/${ type }/${ id }`, params);
|
||||||
|
|
||||||
return get(this, 'globalStore').request({ url });
|
return get(this, 'globalStore').request({ url });
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue