Skip to content

Commit

Permalink
Add OciRegistries.gitHubContainerRegistry
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtSilvio committed Jul 23, 2024
1 parent 4cfbf74 commit adf2f23
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface OciRegistries {

fun registry(name: String, configuration: Action<in OciRegistry>): OciRegistry
fun dockerHub(configuration: Action<in OciRegistry>): OciRegistry
fun gitHubContainerRegistry(configuration: Action<in OciRegistry>): OciRegistry
}

interface OciRegistry : Named {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ internal abstract class OciRegistriesImpl @Inject constructor(
return registry
}

final override fun gitHubContainerRegistry(configuration: Action<in OciRegistry>): 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) {
Expand Down

0 comments on commit adf2f23

Please sign in to comment.