-
Notifications
You must be signed in to change notification settings - Fork 360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WM-2461] Add support for running private workflows on Azure #7373
Changes from all commits
6ba6ec1
16d47a2
21e8180
57eb0fd
2d3f09c
81bad06
b9adb74
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,12 @@ | |
import akka.actor.ActorRef | ||
import akka.pattern.{AskSupport, AskTimeoutException} | ||
import akka.util.Timeout | ||
import cats.data.Validated.{Invalid, Valid} | ||
import cats.implicits.catsSyntaxValidatedId | ||
import com.typesafe.config.Config | ||
import com.typesafe.scalalogging.StrictLogging | ||
import common.validation.ErrorOr.ErrorOr | ||
import cromwell.cloudsupport.azure.AzureCredentials | ||
import cromwell.languages.util.ImportResolver.{GithubImportAuthProvider, ImportAuthProvider} | ||
import cromwell.services.auth.GithubAuthVending.{ | ||
GithubAuthRequest, | ||
|
@@ -13,16 +18,16 @@ | |
NoGithubAuthResponse | ||
} | ||
|
||
import net.ceedubs.ficus.Ficus._ | ||
import scala.concurrent.{ExecutionContext, Future} | ||
|
||
trait GithubAuthVendingSupport extends AskSupport with StrictLogging { | ||
|
||
def serviceRegistryActor: ActorRef | ||
|
||
implicit val timeout: Timeout | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't necessarily have an objection, just curious - why is the timeout implicit rather than overridden by classes that extend this trait? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reason I removed it from here and put it as implicit parameter for each method was to address this comment. But in regards to your specific question, I am not really sure. I have seen this pattern for timeout being implicit in other actor classes and my understanding was making them implicit means it could be extracted from the context indirectly (as long as it is in the context) when needed instead of each class having to supply it. But my understanding is basic. Maybe @cjllanwarne knows more? |
||
implicit val ec: ExecutionContext | ||
|
||
def importAuthProvider(token: String): ImportAuthProvider = new GithubImportAuthProvider { | ||
def importAuthProvider(token: String)(implicit timeout: Timeout): ImportAuthProvider = new GithubImportAuthProvider { | ||
override def authHeader(): Future[Map[String, String]] = | ||
serviceRegistryActor | ||
.ask(GithubAuthRequest(token)) | ||
|
@@ -42,4 +47,16 @@ | |
Future.failed(new Exception("Failed to resolve github auth token", error)) | ||
} | ||
} | ||
|
||
def importAuthProvider(config: Config)(implicit timeout: Timeout): ErrorOr[Option[ImportAuthProvider]] = { | ||
val isAuthAzure = config.as[Boolean]("services.GithubAuthVending.config.auth.azure") | ||
|
||
if (isAuthAzure) { | ||
val azureToken = AzureCredentials.getAccessToken() | ||
azureToken match { | ||
case Valid(token) => Option(importAuthProvider(token)).validNel | ||
case Invalid(err) => s"Failed to fetch Azure token. Error: ${err.toString}".invalidNel | ||
} | ||
} else None.validNel | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love being able to just hook this in!