Skip to content

Commit

Permalink
dashboard/app: support scopes for batch jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
tarasmadan committed Jul 25, 2024
1 parent 466a14e commit 32fcf98
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions dashboard/app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 5 additions & 3 deletions dashboard/app/coverage_batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}
Expand All @@ -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())

Expand Down Expand Up @@ -126,7 +127,8 @@ func createScriptJob(ctx context.Context, projectID, serviceAccount, script stri
},
}},
ServiceAccount: &batchpb.ServiceAccount{
Email: serviceAccount,
Email: serviceAccount,
Scopes: scopes,
},
}

Expand Down

0 comments on commit 32fcf98

Please sign in to comment.