-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
295 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ test-output/ | |
*.log | ||
/config/ | ||
.bloop | ||
|
||
.bsp | ||
*.pid | ||
.DS_Store | ||
.metals |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# Repository-specific configuration | ||
|
||
# pullRequests.frequency allows to control how often or when Scala Steward | ||
# is allowed to create pull requests. | ||
# | ||
# Possible values: | ||
# @asap | ||
# PRs are created without delay. | ||
# | ||
# <timespan> | ||
# PRs are created only again after the given timespan since the last PR | ||
# has passed. Example values are "36 hours", "1 day", or "14 days". | ||
|
||
# <CRON expression> | ||
# PRs are created roughly according to the given CRON expression. | ||
# | ||
# CRON expressions consist of five fields: | ||
# minutes, hour of day, day of month, month, and day of week. | ||
# | ||
# See https://www.alonsodomin.me/cron4s/userguide/index.html#parsing for | ||
# more information about the CRON expressions that are supported. | ||
# | ||
# Note that the date parts of the CRON expression are matched exactly | ||
# while the the time parts are only used to abide to the frequency of | ||
# the given expression. | ||
# | ||
# Default: @asap | ||
# | ||
#pullRequests.frequency = "0 0 ? * 3" # every thursday on midnight | ||
pullRequests.frequency = "15 days" | ||
|
||
# Only these dependencies which match the given patterns are updated. | ||
# | ||
# Each pattern must have `groupId`, and may have `artifactId` and `version`. | ||
# Defaults to empty `[]` which mean Scala Steward will update all dependencies. | ||
# updates.allow = [ { groupId = "com.example" } ] | ||
|
||
# The dependencies which match the given version pattern are updated. | ||
# Dependencies that are not listed will be updated. | ||
# | ||
# Each pattern must have `groupId`, `version` and optional `artifactId`. | ||
# Defaults to empty `[]` which mean Scala Steward will update all dependencies. | ||
# the following example will allow to update foo when version is 1.1.x | ||
updates.pin = [ { groupId = "org.broadinstitute.dsde", artifactId="rawls-model", version = "0.1-2356e282" } ] | ||
|
||
# The dependencies which match the given pattern are NOT updated. | ||
# | ||
# Each pattern must have `groupId`, and may have `artifactId` and `version`. | ||
# Defaults to empty `[]` which mean Scala Steward will not ignore dependencies. | ||
updates.ignore = [] | ||
|
||
# If set, Scala Steward will only attempt to create or update `n` PRs. | ||
# Useful if running frequently and/or CI build are costly | ||
# Default: None | ||
|
||
# By default, Scala Steward does not update scala version since its tricky, error-prone | ||
# and results in bad PRs and/or failed builds | ||
# If set to true, Scala Steward will attempt to update the scala version | ||
# Since this feature is experimental, the default is set to false | ||
# Default: false | ||
updates.includeScala = true | ||
|
||
# The extensions of files that should be updated. | ||
# Default: [".scala", ".sbt", ".sbt.shared", ".sc", ".yml", "pom.xml"] | ||
updates.fileExtensions = [".scala", ".sbt", ".sbt.shared", ".sc", ".yml", ".md", ".markdown", ".txt"] | ||
|
||
# If "on-conflicts", Scala Steward will update the PR it created to resolve conflicts as | ||
# long as you don't change it yourself. | ||
# If "always", Scala Steward will always update the PR it created as long as | ||
# you don't change it yourself. | ||
# If "never", Scala Steward will never update the PR | ||
# Default: "on-conflicts" | ||
updatePullRequests = "always" | "on-conflicts" | "never" | ||
|
||
# If set, Scala Steward will use this message template for the commit messages and PR titles. | ||
# Supported variables: ${artifactName}, ${currentVersion}, ${nextVersion} and ${default} | ||
# Default: "${default}" which is equivalent to "Update ${artifactName} to ${nextVersion}" | ||
commits.message = "Update ${artifactName} from ${currentVersion} to ${nextVersion}" | ||
|
||
# If true and when upgrading version in .scalafmt.conf, Scala Steward will perform scalafmt | ||
# and add a separate commit when format changed. So you don't need reformat manually and can merge PR. | ||
# If false, Scala Steward will not perform scalafmt, so your CI may abort when reformat needed. | ||
# Default: true | ||
scalafmt.runAfterUpgrading = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...e2/src/main/scala/org/broadinstitute/dsde/workbench/google2/GoogleSubscriptionAdmin.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.broadinstitute.dsde.workbench.google2 | ||
|
||
import java.nio.file.Path | ||
|
||
import cats.effect.{Resource, Sync, Timer} | ||
import cats.mtl.Ask | ||
import com.google.api.gax.core.FixedCredentialsProvider | ||
import com.google.auth.oauth2.ServiceAccountCredentials | ||
import com.google.cloud.pubsub.v1.{SubscriptionAdminClient, SubscriptionAdminSettings} | ||
import com.google.pubsub.v1.{ProjectSubscriptionName, Subscription} | ||
import fs2.Stream | ||
import io.chrisdavenport.log4cats.StructuredLogger | ||
import org.broadinstitute.dsde.workbench.model.TraceId | ||
import org.broadinstitute.dsde.workbench.model.google.GoogleProject | ||
|
||
trait GoogleSubscriptionAdmin[F[_]] { | ||
def list(project: GoogleProject)(implicit ev: Ask[F, TraceId]): Stream[F, Subscription] | ||
def delete(projectSubscriptionName: ProjectSubscriptionName)(implicit ev: Ask[F, TraceId]): F[Unit] | ||
} | ||
|
||
object GoogleSubscriptionAdmin { | ||
def fromCredentialPath[F[_]: StructuredLogger: Sync: Timer]( | ||
pathToCredential: Path | ||
): Resource[F, GoogleSubscriptionAdmin[F]] = | ||
for { | ||
credential <- credentialResource(pathToCredential.toString) | ||
topicAdmin <- fromServiceAccountCredential(credential) | ||
} yield topicAdmin | ||
|
||
def fromServiceAccountCredential[F[_]: StructuredLogger: Sync: Timer]( | ||
serviceAccountCredentials: ServiceAccountCredentials | ||
): Resource[F, GoogleSubscriptionAdmin[F]] = | ||
for { | ||
client <- Resource.make( | ||
Sync[F].delay( | ||
SubscriptionAdminClient.create( | ||
SubscriptionAdminSettings | ||
.newBuilder() | ||
.setCredentialsProvider(FixedCredentialsProvider.create(serviceAccountCredentials)) | ||
.build() | ||
) | ||
) | ||
)(client => Sync[F].delay(client.shutdown())) | ||
} yield new GoogleSubscriptionAdminInterpreter[F](client) | ||
} |
35 changes: 35 additions & 0 deletions
35
.../scala/org/broadinstitute/dsde/workbench/google2/GoogleSubscriptionAdminInterpreter.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.broadinstitute.dsde.workbench.google2 | ||
|
||
import cats.effect.{Sync, Timer} | ||
import cats.mtl.Ask | ||
import com.google.cloud.pubsub.v1.SubscriptionAdminClient | ||
import com.google.pubsub.v1.{ProjectName, ProjectSubscriptionName, Subscription} | ||
import fs2.Stream | ||
import io.chrisdavenport.log4cats.StructuredLogger | ||
import org.broadinstitute.dsde.workbench.model.TraceId | ||
import org.broadinstitute.dsde.workbench.model.google.GoogleProject | ||
|
||
import scala.collection.JavaConverters._ | ||
|
||
private[google2] class GoogleSubscriptionAdminInterpreter[F[_]: Timer](client: SubscriptionAdminClient)(implicit | ||
F: Sync[F], | ||
logger: StructuredLogger[F] | ||
) extends GoogleSubscriptionAdmin[F] { | ||
def list(project: GoogleProject)(implicit ev: Ask[F, TraceId]): Stream[F, Subscription] = { | ||
val fa = F.delay(client.listSubscriptions(ProjectName.of(project.value))) | ||
for { | ||
resp <- Stream.eval( | ||
tracedLogging(fa, s"com.google.cloud.pubsub.v1.SubscriptionAdminClient.listSubscriptions(${project.value})") | ||
) | ||
pagedResponse <- Stream.fromIterator(resp.iteratePages().iterator().asScala) | ||
subscription <- Stream.fromIterator(pagedResponse.getValues.iterator().asScala) | ||
} yield subscription | ||
} | ||
|
||
def delete(projectSubscriptionName: ProjectSubscriptionName)(implicit ev: Ask[F, TraceId]): F[Unit] = { | ||
val fa = F.delay(client.deleteSubscription(projectSubscriptionName)) | ||
tracedLogging(fa, | ||
s"com.google.cloud.pubsub.v1.SubscriptionAdminClient.deleteSubscription(${projectSubscriptionName})" | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.