From 32fcf98fda0484949d799e870d7ac9945c695932 Mon Sep 17 00:00:00 2001 From: Taras Madan Date: Thu, 25 Jul 2024 14:10:10 +0200 Subject: dashboard/app: support scopes for batch jobs --- dashboard/app/config.go | 1 + dashboard/app/coverage_batch.go | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/dashboard/app/config.go b/dashboard/app/config.go index 0236eb186..36e06fc98 100644 --- a/dashboard/app/config.go +++ b/dashboard/app/config.go @@ -128,6 +128,7 @@ type Config struct { type CoverageConfig struct { BatchProject string BatchServiceAccount string + BatchScopes []string } // DiscussionEmailConfig defines the correspondence between an email and a DiscussionSource. diff --git a/dashboard/app/coverage_batch.go b/dashboard/app/coverage_batch.go index d60f10eb4..1e87ef127 100644 --- a/dashboard/app/coverage_batch.go +++ b/dashboard/app/coverage_batch.go @@ -54,7 +54,8 @@ func handleBatchCoverage(w http.ResponseWriter, r *http.Request) { ctx, nsConfig.Coverage.BatchProject, nsConfig.Coverage.BatchServiceAccount, - batchScript(ns, repo, branch, 7, dates)); err != nil { + batchScript(ns, repo, branch, 7, dates), + nsConfig.Coverage.BatchScopes); err != nil { log.Errorf(ctx, "failed to batchScript(): %s", err.Error()) } } @@ -80,7 +81,7 @@ func batchScript(ns, repo, branch string, days int, datesTo []civil.Date) string } // from https://cloud.google.com/batch/docs/samples/batch-create-script-job -func createScriptJob(ctx context.Context, projectID, serviceAccount, script string) error { +func createScriptJob(ctx context.Context, projectID, serviceAccount, script string, scopes []string) error { region := "us-central1" jobName := fmt.Sprintf("coverage-merge-%s", uuid.New().String()) @@ -126,7 +127,8 @@ func createScriptJob(ctx context.Context, projectID, serviceAccount, script stri }, }}, ServiceAccount: &batchpb.ServiceAccount{ - Email: serviceAccount, + Email: serviceAccount, + Scopes: scopes, }, } -- cgit mrf-deployment