forked from broadinstitute/cromwell
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into cromwell-83
- Loading branch information
Showing
45 changed files
with
2,034 additions
and
505 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
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
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
dockerHashing/src/main/scala/cromwell/docker/registryv2/flows/aws/AmazonEcr.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 cromwell.docker.registryv2.flows.aws | ||
|
||
import cats.effect.IO | ||
import cromwell.docker.{DockerImageIdentifier, DockerInfoActor, DockerRegistryConfig} | ||
import org.http4s.AuthScheme | ||
import org.http4s.client.Client | ||
import org.slf4j.{Logger, LoggerFactory} | ||
import software.amazon.awssdk.services.ecr.EcrClient | ||
|
||
import scala.compat.java8.OptionConverters._ | ||
import scala.concurrent.Future | ||
|
||
class AmazonEcr(override val config: DockerRegistryConfig, ecrClient: EcrClient = EcrClient.create()) extends AmazonEcrAbstract(config) { | ||
private val logger: Logger = LoggerFactory.getLogger(this.getClass) | ||
|
||
override protected val authorizationScheme: AuthScheme = AuthScheme.Basic | ||
|
||
/** | ||
* e.g 123456789012.dkr.ecr.us-east-1.amazonaws.com | ||
*/ | ||
override protected def registryHostName(dockerImageIdentifier: DockerImageIdentifier): String = { | ||
var hostname = dockerImageIdentifier.hostAsString | ||
if (hostname.lastIndexOf("/").equals(hostname.length -1)) { | ||
hostname = hostname.substring(0, hostname.length -1) | ||
} | ||
hostname | ||
} | ||
/** | ||
* Returns true if this flow is able to process this docker image, | ||
* false otherwise | ||
*/ | ||
override def accepts(dockerImageIdentifier: DockerImageIdentifier): Boolean = dockerImageIdentifier.hostAsString.contains("amazonaws.com") | ||
|
||
override protected def getToken(dockerInfoContext: DockerInfoActor.DockerInfoContext)(implicit client: Client[IO]): IO[Option[String]] = { | ||
logger.info("obtaining access token for '{}'", dockerInfoContext.dockerImageID.fullName) | ||
val eventualMaybeToken = Future(ecrClient.getAuthorizationToken | ||
.authorizationData() | ||
.stream() | ||
.findFirst() | ||
.asScala | ||
.map(_.authorizationToken())) | ||
|
||
IO.fromFuture(IO(eventualMaybeToken)) | ||
} | ||
} |
Oops, something went wrong.