Skip to content

Commit

Permalink
Add OciImageTask interface
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtSilvio committed Dec 18, 2024
1 parent 0a2e25a commit bb0f072
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ import io.github.sgtsilvio.gradle.oci.metadata.OciImageReference
import io.github.sgtsilvio.oci.registry.DistributionRegistryStorage
import io.github.sgtsilvio.oci.registry.OciRegistryHandler
import org.apache.commons.lang3.SystemUtils
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.options.Option
import org.gradle.kotlin.dsl.property
import org.gradle.kotlin.dsl.setProperty
import org.gradle.process.ExecOperations
import org.gradle.work.DisableCachingByDefault
import reactor.netty.http.server.HttpServer
Expand Down Expand Up @@ -65,19 +61,4 @@ abstract class LoadOciImagesTask @Inject constructor(private val execOperations:
@DisableCachingByDefault(because = "Loading to an external Docker daemon")
abstract class LoadOciImageTask @Inject constructor(
execOperations: ExecOperations
) : LoadOciImagesTask(execOperations) {

@get:Internal
@get:Option(
option = "name",
description = "Names the image. If not specified, the imageName defined in the image definition is used.",
)
val imageName = project.objects.property<String>()

@get:Internal
@get:Option(
option = "tag",
description = "Tags the image. Option can be specified multiple times. The value '.' translates to the imageTag defined in the image definition. If not specified, the imageTag defined in the image definition is used.",
)
val imageTags = project.objects.setProperty<String>()
}
) : LoadOciImagesTask(execOperations), OciImageTask
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import io.github.sgtsilvio.gradle.oci.platform.PlatformSelector
import io.github.sgtsilvio.gradle.oci.platform.toPlatform
import org.apache.commons.io.FileUtils
import org.gradle.api.DefaultTask
import org.gradle.api.provider.Property
import org.gradle.api.provider.Provider
import org.gradle.api.provider.SetProperty
import org.gradle.api.tasks.*
import org.gradle.api.tasks.options.Option
import org.gradle.kotlin.dsl.listProperty
Expand Down Expand Up @@ -185,3 +187,20 @@ private val EMPTY_LAYER_DIFF_IDS = setOf(
"sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef".toOciDigest(),
"sha512:8efb4f73c5655351c444eb109230c556d39e2c7624e9c11abc9e3fb4b9b9254218cc5085b454a9698d085cfa92198491f07a723be4574adc70617b73eb0b6461".toOciDigest(),
)

interface OciImageTask {

@get:Internal
@get:Option(
option = "name",
description = "Names the image. If not specified, the imageName defined in the image definition is used.",
)
val imageName: Property<String>

@get:Internal
@get:Option(
option = "tag",
description = "Tags the image. Option can be specified multiple times. The value '.' translates to the imageTag defined in the image definition. If not specified, the imageTag defined in the image definition is used.",
)
val imageTags: SetProperty<String>
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -324,3 +324,8 @@ private fun formatBytesString(bytes: Long): String = when {
if (tenthMegaBytes == 0L) "$megaBytes MB" else "$megaBytes.$tenthMegaBytes MB"
}
}

@DisableCachingByDefault(because = "Pushing to an external registry")
abstract class PushOciImageTask @Inject constructor(
workerExecutor: WorkerExecutor,
) : PushOciImagesTask(workerExecutor), OciImageTask

0 comments on commit bb0f072

Please sign in to comment.