stackdriver: fix bug when multiple projects connected to service account

We had incorrectly assumed that a service account could only be connected
to one project.
This commit is contained in:
Daniel Lee
2018-09-24 10:17:06 +02:00
parent 636d8421d0
commit e101bcdb13
4 changed files with 22 additions and 18 deletions

View File

@ -30,9 +30,7 @@ export class StackdriverQueryCtrl extends QueryCtrl {
aliasBy: string;
};
defaultDropdownValue = 'select metric';
defaultFilterValue = 'select value';
defaultRemoveGroupByValue = '-- remove group by --';
defaultRemoveFilterValue = '-- remove filter --';
loadLabelsPromise: Promise<any>;
stackdriverConstants;
@ -75,7 +73,6 @@ export class StackdriverQueryCtrl extends QueryCtrl {
this.getCurrentProject()
.then(this.getMetricTypes.bind(this))
.then(this.getLabels.bind(this));
this.initSegments();
}
@ -97,12 +94,7 @@ export class StackdriverQueryCtrl extends QueryCtrl {
async getCurrentProject() {
try {
const projects = await this.datasource.getProjects();
if (projects && projects.length > 0) {
this.target.project = projects[0];
} else {
throw new Error('No projects found');
}
this.target.project = await this.datasource.getDefaultProject();
} catch (error) {
let message = 'Projects cannot be fetched: ';
message += error.statusText ? error.statusText + ': ' : '';