From adf2f236d487996278a88a659798be56c0a5ad2c Mon Sep 17 00:00:00 2001 From: Silvio Giebl Date: Tue, 23 Jul 2024 14:25:57 +0200 Subject: [PATCH] Add OciRegistries.gitHubContainerRegistry --- .../io/github/sgtsilvio/gradle/oci/dsl/OciRegistries.kt | 1 + .../gradle/oci/internal/dsl/OciRegistriesImpl.kt | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/main/kotlin/io/github/sgtsilvio/gradle/oci/dsl/OciRegistries.kt b/src/main/kotlin/io/github/sgtsilvio/gradle/oci/dsl/OciRegistries.kt index c404bf1f..5386f4ff 100644 --- a/src/main/kotlin/io/github/sgtsilvio/gradle/oci/dsl/OciRegistries.kt +++ b/src/main/kotlin/io/github/sgtsilvio/gradle/oci/dsl/OciRegistries.kt @@ -18,6 +18,7 @@ interface OciRegistries { fun registry(name: String, configuration: Action): OciRegistry fun dockerHub(configuration: Action): OciRegistry + fun gitHubContainerRegistry(configuration: Action): OciRegistry } interface OciRegistry : Named { diff --git a/src/main/kotlin/io/github/sgtsilvio/gradle/oci/internal/dsl/OciRegistriesImpl.kt b/src/main/kotlin/io/github/sgtsilvio/gradle/oci/internal/dsl/OciRegistriesImpl.kt index 4b21e7a8..2b180970 100644 --- a/src/main/kotlin/io/github/sgtsilvio/gradle/oci/internal/dsl/OciRegistriesImpl.kt +++ b/src/main/kotlin/io/github/sgtsilvio/gradle/oci/internal/dsl/OciRegistriesImpl.kt @@ -83,6 +83,14 @@ internal abstract class OciRegistriesImpl @Inject constructor( return registry } + final override fun gitHubContainerRegistry(configuration: Action): OciRegistry { + val registry = getOrCreateRegistry("ghcr") { + url.convention(URI("https://ghcr.io")) + } + configuration.execute(registry) + return registry + } + private inline fun getOrCreateRegistry(name: String, init: OciRegistry.() -> Unit = {}): OciRegistry { var registry = list.findByName(name) if (registry == null) {