Skip to content

Commit

Permalink
Handle upgrade of missing chart version
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent99 committed Jan 15, 2021
1 parent 6dd8cb7 commit d20719b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 23 deletions.
14 changes: 7 additions & 7 deletions pages/c/_cluster/apps/install.vue
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,14 @@ export default {
});
} catch (e) {
console.error(e); // eslint-disable-line no-console
throw e;
this.versionInfo = null;
}
if ( this.version && process.client ) {
await this.loadValuesComponent();
}
const required = (this.version.annotations?.[CATALOG_ANNOTATIONS.REQUIRES_GVK] || '').split(/\s*,\s*/).filter(x => !!x).reverse();
const required = (this.version?.annotations?.[CATALOG_ANNOTATIONS.REQUIRES_GVK] || '').split(/\s*,\s*/).filter(x => !!x).reverse();
if ( required.length ) {
for ( const gvr of required ) {
Expand Down Expand Up @@ -242,7 +242,7 @@ export default {
}
this.removeGlobalValuesFrom(userValues);
this.chartValues = merge(merge({}, this.versionInfo.values), userValues);
this.chartValues = merge(merge({}, this.versionInfo?.values || {}), userValues);
this.valuesYaml = jsyaml.safeDump(this.chartValues || {});
if ( this.valuesYaml === '{}\n' ) {
Expand All @@ -254,8 +254,8 @@ export default {
this.originalYamlValues = this.valuesYaml;
}
this.loadedVersionValues = this.versionInfo.values;
this.loadedVersion = this.version.key;
this.loadedVersionValues = this.versionInfo?.values || {};
this.loadedVersion = this.version?.key;
}
},
Expand Down Expand Up @@ -437,9 +437,9 @@ export default {
const {
currentCluster,
catalogOSAnnotation,
chart: { versions = [] },
version: { version: selectedVersion },
} = this;
const versions = this.chart?.versions || [];
const selectedVersion = this.version?.version;
const clusterProvider = currentCluster.status.provider || 'other';
const out = [];
Expand Down
33 changes: 19 additions & 14 deletions store/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,24 +324,29 @@ export const actions = {
const key = `${ repoType }/${ repoName }/${ chartName }/${ versionName }`;
let info = state.versionInfos[key];

if ( !info ) {
const repo = getters['repo']({ repoType, repoName });
try {
if ( !info ) {
const repo = getters['repo']({ repoType, repoName });

if ( !repo ) {
throw new Error('Repo not found');
}
if ( !repo ) {
throw new Error('Repo not found');
}

info = await repo.followLink('info', {
url: addParams(repo.links.info, {
chartName,
version: versionName
})
});
info = await repo.followLink('info', {
url: addParams(repo.links.info, {
chartName,
version: versionName
})
});

commit('cacheVersion', { key, info });
}
commit('cacheVersion', { key, info });
}

return info;
return info;
} catch (e) {
console.log(e);
debugger;
}
},
};

Expand Down
6 changes: 4 additions & 2 deletions store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -571,8 +571,10 @@ export const actions = {
dispatch('prefs/loadTheme');
},

loadingError({ commit, redirect }, err) {
loadingError({ commit, state }, err) {
commit('setError', err);
redirect('/fail-whale');
const router = state.$router;

router.replace('/fail-whale');
}
};

0 comments on commit d20719b

Please sign in to comment.