stackdriver: only load project name if it's not already stored in the ds info json

This commit is contained in:
Erik Sundell 2018-10-09 17:02:41 +02:00
parent cd7b454e25
commit 9fb1d3a9a6

View File

@ -222,12 +222,19 @@ export default class StackdriverDatasource {
async getDefaultProject() {
try {
const projects = await this.getProjects();
if (projects && projects.length > 0) {
const test = projects.filter(p => p.id === this.projectName)[0];
return test;
if (this.projectName) {
return {
id: this.projectName,
name: this.projectName,
};
} else {
throw new Error('No projects found');
const projects = await this.getProjects();
if (projects && projects.length > 0) {
const test = projects.filter(p => p.id === this.projectName)[0];
return test;
} else {
throw new Error('No projects found');
}
}
} catch (error) {
let message = 'Projects cannot be fetched: ';